Claude Code: An Analysis — Southbridge AI
URL: https://www.southbridge.ai/blog/claude-code-an-analysis
Author: Southbridge AI (Hrishi)
Published: 2026
Summary
An AI-generated architectural analysis of Claude Code — created by having Claude Opus 4.6 and other models analyze the system through ~300K tokens of intermediate reasoning. Not a true decompilation, but a didactic architectural overview that surfaces novel components and design patterns.
Key Claims
- Streaming architecture: Real-time LLM responses, tool execution, and UI updates handled through a six-phase async generator (
ttfunction). Supports recursive turns for unlimited conversation depth. - Tool categorization by side effects: Read-only tools run in parallel; write operations serialize. This is the key safety design — parallelism only where safe.
- AgentTool = hierarchical decomposition: Sub-agents can be spawned and their findings synthesized. Enables multi-level task decomposition.
- Streaming JSON parser with recovery: Handles partial LLM responses gracefully — crucial for real-time streaming.
- React in a terminal: Unconventional dependency choice using
yoga-layout. Enables rich interactive terminal UI. - ANR detection (borrowed from mobile dev): Uses worker threads to detect when the main thread is unresponsive — prevents the agent from silently hanging.
- Three-stage message representation: Messages transform through stages as they move from user input → LLM processing → tool execution.
- Security is multiple independent layers: Permission cascades through scopes; each fails safely. Not a single security system.
- The process: Five batches × four rounds with subagents (mostly Gemini 2.5 Pro), ~300K intermediate tokens, then condensed and rewritten by Opus 4. Took one day; would have taken months pre-LLM.
Notable Architecture Insight
Context compaction triggers automatically when context approaches limits — enabling long-running sessions without the user managing context manually.