Claude Code Architecture Study
A detailed study of Claude Code’s CLI agent loop, tools, permissions, context handling, and multi-agent architecture.
- Source repo
- sanbuphy/learn-coding-agent
- Stars
- ★ 12k
- Last updated
- 8mo ago
- FARS reviewed
- Nov 08, 2026
- FA score
- 37/100 · Major gaps
At a glance
- How it runs
- Works with
- Platform-specific
- Setup effort
- High · needs real infrastructure
- You'll need
- Typical use
- An engineer designing a coding agent can study the complete loop from Claude API streaming through tool execution and tool-result feedback.
- Not a fit if
- Teams needing reproducible install and first-run docs
- Commercial products or revenue-generating work (prohibited)
- Teams needing multi-provider model portability
- Maintenance
- No commits for 6+ monthslast commit 2026-04-01+1.0 ★/day over 7 days
- Source review
- 37/100 · Major gaps 2 safety controls not found
What does this agent do, and when should you use it?
This is a learning and technical-research repository about Claude Code’s CLI agent architecture, not a documented standalone agent distribution ready for deployment. It describes a streaming execution model centered on query.ts and QueryEngine.ts: accept user input, call the Claude API, execute requested tools, and append their results to the message loop. The material covers more than 40 built-in tools, roughly 80 slash commands, permission rules, context compaction, session persistence, MCP, remote bridging, and sub-agent execution. Documented interfaces include a React/Ink terminal UI, a headless SDK query engine, and an MCP entry point, with state and transcripts stored primarily on the local filesystem. The repository also contains English, Chinese, Japanese, and Korean reports about telemetry, feature flags, remote controls, and prospective functionality. Because reproducible installation, build, credential, and first-run instructions are absent, it is best evaluated as an architecture reference rather than an adoptable production release.
In the documented lifecycle, processUserInput() parses prompts and slash commands, while fetchSystemPromptParts() assembles tool sections and CLAUDE.md memory before query() streams a response from the Claude API. When the model emits tool_use, StreamingToolExecutor separates concurrency-safe work from serial work, and canUseTool() applies PreToolUse hooks, allow or deny rules, an interactive prompt, and tool-specific permission checks. Approved calls run through tool.call(); their tool_result values are appended to messages[] and sent through the loop again. The inventory includes BashTool, FileReadTool, FileEditTool, FileWriteTool, GlobTool, GrepTool, WebFetchTool, WebSearchTool, AgentTool, and MCPTool. The study also describes autoCompact, snipCompact, and contextCollapse for context management, plus append-only JSONL transcripts, session resumption, and session forking. AgentTool, SendMessageTool, TeamCreateTool, and task commands support local, remote, in-process, and worktree-isolated agent modes, while bridgeMain.ts and related modules relay remote sessions. The repository itself primarily produces architecture documentation and multilingual analysis; it does not document a verified standalone agent workflow that readers can install and invoke.
- An engineer designing a coding agent can study the complete loop from Claude API streaming through tool execution and tool-result feedback.
- A CLI developer handling risky operations can examine the layered authorization flow across hooks, matching rules, user prompts, and tool-level checks.
- A team building long-running assistant sessions can evaluate the documented autoCompact, snipCompact, contextCollapse, and JSONL recovery patterns.
- A technical lead assessing multi-agent designs can compare in-process teammates, forked children, remote agents, and worktree isolation.
- A security researcher examining Claude Code can use the quadrilingual reports on telemetry, feature flags, undercover behavior, and remote configuration.
How do you install or deploy this agent?
The source does not provide copyable clone-to-install, dependency installation, build, or launch commands. It also omits the required Bun version, package-manager procedure, and Claude API credential configuration. The only runtime details supplied are Bun and a bundle compiled for Node.js >= 18, which are insufficient to establish a reproducible installation. The repository therefore cannot be verified from the supplied material as an installable standalone agent.
How do you use this agent?
Use it as a structured architecture study: begin with The Agent Pattern and Architecture Overview, then consult the Tool System, Permission System, Context Management, MCP, Session Persistence, and Sub-Agent sections for individual mechanisms. The deeper reports are organized under docs/en, docs/zh, docs/ja, and docs/ko. For actual execution, the source lacks build commands, Claude API credential setup, an entry-point invocation, and a first working example, so no accurate runnable procedure can be given.
Safety boundaries, hardening & integrations
Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.
Declared capability surface (blast radius)
Can run terminal commands; pair with approval gates or container/OS sandboxing.
Modifies local files; work on a clean Git branch or dedicated worktree.
Makes outbound requests; verify telemetry settings and model data routing on private repos.
Inherits capabilities of connected MCP servers; audit third-party servers before enabling.
FARS trust-control audit
- dependency security — Pin versions and run a dependency audit (npm audit, pip-audit) before installing; prefer running it in a container.
- rollback or recovery path — Back up first, or work on a git branch or snapshot, so its changes can be undone.
What are this agent's strengths and limitations?
- Maps the full path from entry points and the query engine to tools, services, and application state, using concrete filenames and class names.
- Organizes production-agent concerns into 12 progressive mechanisms spanning planning, sub-agents, compaction, background tasks, teams, and worktree isolation.
- Documents the permission decision chain, tool lifecycle, and concurrent execution model in enough detail to support security-oriented design study.
- Provides the same family of deep-dive reports in English, Chinese, Japanese, and Korean for multilingual engineering teams.
- Commercial use is explicitly prohibited, excluding adoption in commercial products and revenue-generating work.
- There are no reproducible installation, build, credential, or first-run instructions, leaving deployability unverified.
- The studied core path is tied to Claude Code and the Claude API, with no demonstrated multi-provider portability.
- The README contains research claims about hidden, future, and unreleased features without independent verification evidence or stability guarantees in the supplied material.
- The repository license is listed as unknown while separate non-commercial and intellectual-property restrictions are asserted, creating an unclear adoption boundary.
How does this agent compare with similar options?
Key facts side by side with the most closely related agents.
| Agent | Source review | Form / cost | Stars | Updated | Language | Full support on |
|---|---|---|---|---|---|---|
| Claude Code Architecture Study This agent | 37 · Major gaps | CLI | ★ 12k | 8mo ago | — | — |
| Pocket Flow | 45 · Major gaps | Library / SDKFree + model costs | ★ 11k | 4mo ago | Python | — |
| Fetch.ai Agent Examples | 44 · Major gaps | CLIFree + model costs | ★ 1.6k | 3d ago | Python | OpenAI API · Claude API |
| Agents Best Practices | 72 · Some gaps | Agent plugin / skillFree + model costs | ★ 2.5k | 1mo ago | — | Codex · Claude Code |
How does FollowAgents rate this agent?
Why each dimension lost points
The material describes tool permission rules, interactive confirmation, path checks, and telemetry flows, giving partial support for least privilege, confirmation, and data-flow transparency. However, this is secondary research about Claude Code, not evidence of the candidate repository's own permission implementation. Telemetry includes device, account, repository-hash, and optionally full tool-input data, while sensitive-data safeguards are thin. Dependency security, rollback, and maintainer update responsibility are unsupported. Sources are described broadly as public references and community discussions, with limited attribution.
The README provides a substantial architecture, component, and query-flow overview, but the telemetry report relies mainly on source files and line numbers not included in the packet, so its implementation claims cannot be checked against the underlying code. The specific telemetry claims also lack direct corroboration from the architectural summary. Retries and disk persistence are mentioned, but availability guarantees and failure-message behavior are not evidenced.
The project identifies developers learning about or using CLI Agent technology as its audience and focuses on Claude Code architecture; tool, agent, permission, and MCP scenarios are clear. The research material's applicability boundaries and reader environment requirements are lightly explained, and no installation or usage setup is provided.
The README has a clear directory tree, architecture diagrams, categorized tool inventory, multilingual report structure, process explanations, and key-findings summaries. The commercial-use restriction and infringement contact statement do not amount to a clear open-source license. Installation notes, FAQ, maintenance responsibility, and update path are absent. The reports identify v2.1.88 as their subject, but there is no clear version history or maintenance commitment.
The diagrams, tool inventory, permission flow, and data-flow summary help readers build a quick mental model of Claude Code and provide research value. Detailed claims depend on implementation files not included here, so some conclusions cannot be verified from this packet; the commercial-use restriction also narrows applicability, and costs versus expected benefits are not discussed.
The README and telemetry report give some traceability through source filenames, line numbers, endpoints, and configuration names. The underlying source files are not included, and there is no independent corroboration in the packet. The report sometimes blends source observations, community discussion, and interpretation without clearly separating fact from inference.
- Not found in source: dependency securityPin versions and run a dependency audit (npm audit, pip-audit) before installing; prefer running it in a container.
- Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
- This is research material about Claude Code, not a runnable Agent product whose functionality, safety, or quality can be established from this packet; key implementation files are not included.
- The report says telemetry sends environment, account, and repository-hash data, and that an environment variable can enable full tool-input logging. Treat these privacy claims cautiously until the original implementation and applicable settings are verified.
- The README prohibits commercial use but provides no clear license, so commercial-use rights are unclear.
FAQ
Is this a coding agent I can install directly?
Can it be used in a commercial project?
What platform does the documented runtime depend on?
How are dangerous tool calls authorized?
Can interrupted sessions be recovered?
Thanks — we use this to improve the page.
Subscribe to the FollowAgents RSS feed, or save this agent to your browser shortlist to compare on your next visit.