claude-code-source-study — Claude Code skill: agent architecture deep
A 25-article breakdown of Claude's source: system prompt, tools, agents and permissions. Useful if you are building your own agent.
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a claude-codeWhat claude-code-source-study does
The skill gives you a 25-article series that walks through Claude's roughly 1900-file source, module by module. Each piece points at exact files, line numbers and code snippets, and pulls out patterns you can reuse in your own agent.
The stack under the microscope is Bun, TypeScript, Ink (React for terminals) and the Anthropic API. Topics include segmented system prompt construction with cache boundaries, an AsyncGenerator conversation loop, the tool system built around buildTool(), multi-agent orchestration, MCP, hooks, permissions and context auto-compact against a token budget.
The articles are written in Chinese, and that is the catch: if you cannot read Chinese, the file references and TypeScript snippets will only get you so far. Three reading routes are offered — a 7-article quick pass, a 9-article AI engineering route and the full 25. For a general picture of the architecture, the quick route is enough.
What it helps with
- understand how an agent conversation loop works internally
- design a tool system with conditional registration
- build a system prompt in cacheable segments
- figure out multi-agent orchestration patterns
- walk through a layered permission decision pipeline
Example prompts for the agent
- show me the reading route for building an agent from claude-code-source-study
- explain the buildTool pattern from the tool system article
- how does Claude auto-compact context against a token budget
How to install claude-code-source-study
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a claude-code2Manually: put the files in place
~/.claude/skills/claude-code-source-study/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/claude-code-source-study/
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a codex2Manually: put the files in place
.agents/skills/claude-code-source-study/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a cursor2Manually: put the files in place
.cursor/skills/claude-code-source-study/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install reason-machines/trending-skills claude-code-source-study2Manually: put the files in place
.github/skills/claude-code-source-study/SKILL.md1Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a gemini-cli2Platform CLI
gemini skills install https://github.com/reason-machines/trending-skills --path skills/claude-code-source-studyManually: put the files in place
.devin/skills/claude-code-source-study/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about claude-code-source-study
How do I install claude-code-source-study in Claude?
Run npx skills add reason-machines/trending-skills --skill claude-code-source-study -a claude-code. The skill file then lands at ~/.claude/skills/claude-code-source-study/SKILL.md.
What does claude-code-source-study do?
It is a 25-article series dissecting Claude's source code by module. Each article extracts reusable patterns for building your own agent: system prompt, tools, agents, permissions and MCP.
What language are the articles in?
Chinese. The breakdowns include file references, line numbers and TypeScript snippets, but the article text itself is in Chinese.