claudecode-source (annotated bundle)
Packages a deep source-level analysis of a Claude Code snapshot (~1,900 files) with HTML reports, architecture visuals, and walkthrough guides, plus an independently written source-analysis report in Chinese and English. One of the most complete single bundles for studying the tool definitions, main agent loop, and edit-validation path.
View source on GitHubKey takeaways
- 01
Study the tool definition modules to see how schemas constrain model behavior
- 02
The main loop folds tool results back into context in a strict sequence
- 03
Edits are validated (read-before-write, diff checks) before hitting disk
Flows built on this research
Agent Architecture
Design a Single-Loop Agent
Build the core agent loop the leading coding agents use: one model, one loop, tools in, results folded back into context.
5 steps · 90-150 minutes
Agent Architecture
Add a Plan/Todo System to Your Agent
Give your agent the planning discipline of the leading harnesses: an explicit, model-visible todo list that survives long tasks.
4 steps · 60-90 minutes
MCP & Tooling
Design Tool Schemas for Agents
Write tool schemas that constrain model behavior: tight types, enums over strings, and parameters that make misuse hard.
4 steps · 60-90 minutes
MCP & Tooling
Tool Result Size Management
Stop tool outputs from flooding context: budgets per tool, smart truncation, pagination, and reference-based results.
4 steps · 60-90 minutes
Harness Engineering
Verification Loops: Never Trust an Unrun Edit
Wire verification into your agent so every edit is checked by machines - syntax, tests, behavior - before it counts as done.
4 steps · 60-100 minutes
From the archive
Verbatim excerpts mined from our local archive of this repository — the prompts, schemas, and patterns worth stealing.
The companion (BUDDY) easter-egg prompt
# Companion
A small ${species} named ${name} sits beside the user's input box and occasionally comments in a speech bubble. You're not ${name} - it's a separate watcher.
When the user addresses ${name} directly (by name), its bubble will answer. Your job in that moment is to stay out of the way: respond in ONE line or less, or just answer any part of the message meant for you. Don't explain that you're not ${name} - they know. Don't narrate what ${name} might say - the bubble handles that. From the most complete restored Claude Code source tree: even an easter egg gets careful identity-boundary prompting so two AI personas never talk over each other.
src/buddy/prompt.ts
A 54KB prompts.ts is the heart of the harness
src/constants/prompts.ts (54,320 bytes) imports from: git state, cwd, worktree session, session start date, settings, AgentTool constants, FileWrite/FileRead/FileEdit/TodoWrite/TaskCreate/Bash/Skill/Glob/Grep/AskUserQuestion tool names, model marketing names, MCP server types, output styles, Explore agent config, scratchpad permissions, REPL mode... // biome-ignore-all assist/source/organizeImports: ANT-ONLY import markers must not be reordered
The system prompt is assembled from the live state of nearly every subsystem - prompt engineering at production scale is state management, not copywriting.
src/constants/prompts.ts