
Claude Code Source Study
Study Claude Code’s real codebase to copy production patterns for system prompts, tools, permissions, and multi-agent orchestration in your own agent.
Overview
Claude Code Source Study is an agent skill most often used in Build (also Idea/discover) that deep-dives Claude Code source to teach production AI agent architecture patterns.
Install
npx skills add https://github.com/aradotso/trending-skills --skill claude-code-source-studyWhat is this skill?
- 25-article deep dive into Claude Code’s large TypeScript/Bun codebase with file and line references
- Covers system prompt engineering, tool system design, permission security, and terminal UI (Ink)
- Extracts multi-agent orchestration and startup/state patterns from Anthropic’s shipping CLI
- Chinese-language series with indexed reading path (docs/00 index through modular topics)
- Triggers on queries like implement agent like claude code and claude code tool system design
- 25-article deep-dive series
- ~1900-file Claude Code codebase scope described in skill overview
Adoption & trust: 515 installs on skills.sh; 31 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You want to build a coding agent but only have blog posts—not a grounded map of how a shipped product wires prompts, tools, and permissions.
Who is it for?
Solo developers cloning serious agent UX who learn best from real shipped code paths and indexed deep dives.
Skip if: Beginners who only need quick Cursor rules, or builders who refuse to read source and want a one-shot code generator.
When should I use this skill?
User asks to study Claude Code source, learn production AI agent architecture, understand internal system prompt or tool design, or build an agent like Claude Code.
What do I get? / Deliverables
You follow a 25-article, file-referenced study path and can apply concrete Claude Code patterns to your own agent or CLI design.
- Guided reading path through architecture articles
- Reusable design notes for prompts, tools, and orchestration
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Building agent products maps to Build/agent-tooling where architecture decisions are implemented. Agent-tooling is the shelf for skills that teach how coding agents are structured, not just how to prompt them once.
Where it fits
Compare Claude Code’s permission model against your MVP agent idea before picking a framework.
Walk the indexed articles on tool registration while scaffolding your own Bun/TS agent CLI.
Study permission-security chapters before hardening tool allowlists in your shipping agent.
How it compares
Research curriculum skill—not an MCP server or a deploy integration; pair with implementation skills when you move from reading to coding.
Common Questions / FAQ
Who is claude-code-source-study for?
Indie agent builders and senior devs who want Anthropic-grade patterns from Claude Code’s actual repo, not abstract diagrams.
When should I use claude-code-source-study?
In Idea/discover when choosing agent architecture; in Build/agent-tooling when implementing tools, permissions, or multi-agent flows; before committing to a Claude-like CLI stack.
Is claude-code-source-study safe to install?
It guides study of public analysis material—check the Security Audits panel on this page and treat any cloned third-party repos with normal supply-chain caution.
SKILL.md
READMESKILL.md - Claude Code Source Study
# Claude Code Source Study > Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection. A 25-article deep-dive into Claude Code's ~1900-file source code, covering System Prompt engineering, multi-agent orchestration, tool systems, permission security, and terminal UI. Learn production-grade AI agent patterns from Anthropic's real CLI product. ## What This Project Is This is a **Chinese-language source code analysis series** that dissects Claude Code (Anthropic's AI CLI coding assistant) module by module — with exact file references, line numbers, and code snippets. Each article extracts reusable design patterns for building your own AI agent applications. **Tech stack covered:** Bun + TypeScript + Ink (React for terminals) + Anthropic API ## Repository Structure ``` claude-code-source-study/ ├── docs/ │ ├── 00-目录与阅读指引.md # Index and reading guide │ ├── 01-项目全景.md # Project overview │ ├── 02-启动优化.md # Startup optimization │ ├── 03-状态管理.md # State management │ ├── 04-System-Prompt-工程.md # System prompt engineering │ ├── 05-对话循环.md # Conversation loop │ ├── 06-上下文管理.md # Context management │ ├── 07-Prompt-Cache.md # Prompt caching │ ├── 08-Thinking-与推理控制.md # Thinking & reasoning │ ├── 09-工具系统设计.md # Tool system design │ ├── 10-BashTool-深度剖析.md # BashTool deep dive │ ├── 11-命令系统.md # Command system │ ├── 12-Agent-系统.md # Agent system │ ├── 13-内置Agent设计模式.md # Built-in agent patterns │ ├── 14-任务系统.md # Task system │ ├── 15-MCP-协议实现.md # MCP protocol │ ├── 16-权限系统.md # Permission system │ ├── 17-Settings-系统.md # Settings system │ ├── 18-Hooks系统.md # Hooks system │ ├── 19-Feature-Flag与编译期优化.md │ ├── 20-API调用与错误恢复.md # API retry/recovery │ ├── 21-Ink框架深度定制.md # Ink UI customization │ ├── 22-设计系统.md # Design system │ ├── 23-Memory系统.md # Memory system │ ├── 24-Skill-Plugin开发实战.md # Plugin development │ └── 25-架构模式总结.md # Architecture patterns summary └── README.md ``` ## Reading Routes ### ⚡ Quick Route (7 articles) — Global understanding ``` 01 → 02 → 03 → 05 → 09 → 12 → 25 ``` ### 🤖 AI Engineering Route (9 articles) — Deep AI core ``` 01 → 03 → 04 → 05 → 06 → 08 → 09 → 12 → 13 ``` ### 📚 Complete Route (25 articles) Read docs/01 through docs/25 in order. ## Key Patterns Extracted from Claude Code ### 1. Tool Builder Pattern (`buildTool()`) Claude Code registers tools using a builder with three-layer conditional registration: ```typescript // Pattern extracted from docs/09-工具系统设计.md const buildTool = <TInput, TOutput>(config: { name: string description: string inputSchema: ZodSchema<TInput> handler: (input: TInput, context: ToolContext) => Promise<TOutput> isEnabled?: (context: AppContext) => boolean requiresPermission?: PermissionLevel }) => config // Registration with conditions const tools = [ buildTool({ name: 'bash', ... }), buildTool({ name: 'read_file', ... }), buildTool({ name: 'write_file', ... }), ].filter(tool => tool.isEnabled?.(ctx) ?? true) ``` ### 2. AsyncGenerator Conversation Loop (`docs/05`) ```typescript // Pattern: state-machine conversation loop using AsyncGenerator async function* conversationLoop( messages: Message[], tools: Tool[] ): AsyncGenerator<StreamEvent> { while (true) { const stream = await anthropic.messages.stream({ model: 'claude-opus-4-5', messages,