# claude-code-source-study

A 25-article breakdown of Claude's source: system prompt, tools, agents and permissions. Useful if you are building your own agent.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 616 installs · ★ 88
- Author: reason-machines
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/reason-machines/trending-skills/tree/HEAD/skills/claude-code-source-study/SKILL.md
- Updated: 2026-10-09
- HTML: https://affpapa.org/en/nevibecode/skills/claude-code-source-study

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/claude-code-source-study/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/claude-code-source-study/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/claude-code-source-study/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/claude-code-source-study/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install reason-machines/trending-skills claude-code-source-study
```

2. **Manually: put the files in place**
- File: `.github/skills/claude-code-source-study/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/reason-machines/trending-skills --path skills/claude-code-source-study
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/claude-code-source-study/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add reason-machines/trending-skills --skill claude-code-source-study -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/reason-machines/trending-skills/tree/HEAD/skills/claude-code-source-study/SKILL.md

## When to use it
- 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
- 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

## Similar
- [agents-best-practices](https://affpapa.org/en/nevibecode/skills/agents-best-practices.md) — skill · 1000 installs
- [open-source](https://affpapa.org/en/nevibecode/skills/open-source.md) — skill · 3500 installs
- [developer-case-study](https://affpapa.org/en/nevibecode/skills/developer-case-study.md) — skill · 10400 installs
- [Claude Code Ultimate Guide](https://affpapa.org/en/nevibecode/mcp/claude-code-ultimate-guide.md) — MCP server · ★ 6237
- [diary-study-plan](https://affpapa.org/en/nevibecode/skills/diary-study-plan.md) — skill · 2100 installs
- [holoscan-install-source](https://affpapa.org/en/nevibecode/skills/holoscan-install-source.md) — skill · 1800 installs

From the same set: [reason-machines/trending-skills](https://affpapa.org/en/nevibecode/by/reason-machines/trending-skills.md) — 49 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
