Claude Code Source Code Deep Analysis (in pdf)

The articles attached are contributed by NetMind.AI's Algorithm Lead Bin Liang.

After reading through a lot of the existing coverage, he found that most posts stopped at the architecture-summary layer: "40+ tools," "QueryEngine.ts is huge," "there is even a virtual pet." Interesting, sure, but not the kind of material that gives advanced technical readers a real understanding of how Claude Code is actually built.

That is why he took a different approach, not here to repeat the headline facts people already know. These writeups are for readers who want to understand the system at the implementation level: how the architecture is organized, how the security boundaries are enforced, how prompt and context construction really work, and how performance and terminal UX are engineered in practice. he only focused on the parts that become visible when you read the source closely, especially the parts that still have not been clearly explained elsewhere.

The Full Series:

  1. Architecture — entry points, startup flow, agent loop, tool system, MCP integration, state management
  2. Security — sandbox, permissions, dangerous patterns, filesystem protection, prompt injection defense
  3. Prompt System — system prompt construction, CLAUDE.md loading, context injection, token management, cache strategy
  4. Performance & UX — lazy loading, streaming renderer, cost tracking, Vim mode, keybinding system, voice input


Overall

The core is a streaming agentic loop (query.ts) that starts executing tools while the model is still generating output. There are 40+ built-in tools, a 3-tier multi-agent orchestration system (sub-agents, coordinators, and teams), and workers can run in isolated Git worktrees so they don't step on each other.

A bunch of unreleased features are hidden in feature flags:

User-Agent: