![](https://southbridge-research.notion.site/images/page-cover/rijksmuseum_mignons_1660.jpg) 💡 This entire report was generated by [[Claude Opus]] 4, with the help of almost all of the major flagship models. However, the 4000 word write-up on [[the process]] of making this report was manually written with no AI assistance. Coming soon. I should note that this is not a true decompilation or reverse engineering attempt in any real sense, more of an homage to the wonderful work done by the Claude team. None of the examples provided are guaranteed to be in Claude Code (or directly derived/copied from source) - the primary intent is didactic value in learning new ways to orchestrate AI agents. If you want the most interesting read, start with [✨ Novel Components: The Innovations That Define Claude Code](https://southbridge-research.notion.site/Novel-Components-The-Innovations-That-Define-Claude-Code-2055fec70db181fdae5bd485823986c4?pvs=24). If you want the most fun read, start with [🤖 An LLM's Perspective: What It's Actually Like to Receive These Instructions](https://southbridge-research.notion.site/An-LLM-s-Perspective-What-It-s-Actually-Like-to-Receive-These-Instructions-2055fec70db18195b9f6ef655745749c?pvs=24). ✉️ ### A Note from me This project started with simple curiosity. I wanted to understand Claude Code, which to me is the best Agentic coding tool (even though the competition is close). Initially, I thought it would be straightforward—just an LLM and a few tools in a loop. I was wrong. It turned out to be far more complex, with tons of novel components I hadn't expected. To tackle this, I worked with multiple AI subagents operating on different pieces of inference. I manually ferried questions and insights back and forth, reviewed outputs to check for hallucinations, and double-checked results. [[The process]] involved: Five batches of four rounds with completely new subagents (mostly Gemini 2.5 Pro) Generating about 300K tokens worth of intermediate analysis Condensing everything into a comprehensive report What's remarkable is that this only took a day and taught me a lot. Before LLMs, this kind of analysis would have taken months—if it was possible at all. To Opus 4, who took my condensed report and transformed it into the comprehensive analysis you're about to read: thank you! —Hrishi ### Why Claude Code Matters Claude Code has a number of very interesting parts: Safety Systems that provide security without disrupting workflow Tool Design that elegantly bridges AI reasoning and system execution Prompt Engineering that reliably controls complex LLM behavior Let’s jump in! Each heading is a link to the full section. ### 🔖Dependencies: The Foundation of Claude Code's Architecture Why React in a terminal? What's yoga-layout doing here? ### 📊Data Structures & The Information Architecture How messages transform through the system Follow data from [[user input]] through LLM processing to tool execution. Understand the three-stage message representation, the ContentBlock polymorphism, and how weak references prevent memory bloat. [[Key Insight]]: The CliMessage wrapper maintains UI state while preserving API compatibility—enabling rich interactions without protocol changes. ### 🔄Control Flow & The Orchestration Engine Inside the tt function Explore the six-phase async generator that orchestrates everything. See how parallel tool execution works, why context compaction triggers automatically, and how recursive turns enable unlimited conversation depth. [[Key Insight]]: Tools are categorized by side effects—read-only tools run in parallel while write operations serialize for safety. ### 🛠️Tools & The Execution Engine From LLM decisions to system actions Each tool is a carefully designed state machine. Examine the permission system, progress reporting, and error handling. Special focus on BashTool's sandbox mode and EditTool's line number handling. [[Key Insight]]: The AgentTool implements hierarchical task decomposition—spawning sub-agents and synthesizing their findings. ### 🏗️Architecture: The Engine Room Event-driven, streaming-first, security-conscious Understand the layered architecture from React UI to system calls. Learn how permissions cascade through scopes, why ANR detection uses worker threads, and how three telemetry systems provide complete observability. [[Key Insight]]: Security isn't one system—it's multiple independent layers that fail safely. ### ✨Novel Components: The Innovations That Define Claude Code The clever fixes to hard problems Discover components that make Claude Code special: streaming JSON parsing with recovery, intelligent data truncation, and multi-agent result synthesis. These aren't just features—they're innovative solutions to fundamental challenges. [[Key Insight]]: The normalizeToSize algorithm iteratively reduces object depth based on actual byte count—preserving maximum information within constraints. ### ✏️File Editing: AI-Assisted Code Modification Why three different editing tools? Deep dive into the file editing pipeline. Learn why line numbers cause problems, how sequential edits detect conflicts, and [[what happens]] when files change externally. [[Key Insight]]: Every conceivable editing mistake has a specific validation—from external modifications to encoding issues. ### 💬Prompt Engineering: The Art of Instructing AI The instructions that make it all work Examine the actual prompts that control Claude Code. From conciseness enforcement to the 500+ word BashTool safety instructions, see how careful wording shapes behavior. [[Key Insight]]: Repetition works—critical instructions appear three times with escalating emphasis. ### 🤖An LLM's Perspective: What It's Actually Like to Receive These Instructions What these prompts feel like from the other side In a unique section, an LLM (me) provides honest commentary on receiving these instructions. Why "just output 4" is surprisingly difficult and how the -$1000 penalty creates real behavioral change despite being imaginary money. [[Key Insight]]: Clear constraints are secretly liberating—they prevent decision paralysis and over-helpfulness. ### Technical Themes Throughout the analysis, several design principles emerge: Streaming First: Every operation designed for incremental updates Safety Through Layers: Multiple independent protection mechanisms Explicit Instructions: Verbose prompts prevent ambiguous behavior Architecture Over Optimization: Performance through design, not tweaks Understanding LLM Psychology: Exploiting how models actually behave ## Sections[🔖](https://southbridge-research.notion.site/Dependencies-The-Foundation-of-Claude-Code-s-Architecture-2055fec70db181b3bb72cdfe615fad3c?pvs=25) [ Dependencies: The Foundation of Claude Code's Architecture ](https://southbridge-research.notion.site/Dependencies-The-Foundation-of-Claude-Code-s-Architecture-2055fec70db181b3bb72cdfe615fad3c?pvs=25)[📊](https://southbridge-research.notion.site/Data-Structures-The-Information-Architecture-2055fec70db1814ba2a7c5fa2879ac21?pvs=25) [ Data Structures & The Information Architecture ](https://southbridge-research.notion.site/Data-Structures-The-Information-Architecture-2055fec70db1814ba2a7c5fa2879ac21?pvs=25)[🔄](https://southbridge-research.notion.site/Control-Flow-The-Orchestration-Engine-2055fec70db181d0b215e1b8584d03fa?pvs=25) [ Control Flow & The Orchestration Engine ](https://southbridge-research.notion.site/Control-Flow-The-Orchestration-Engine-2055fec70db181d0b215e1b8584d03fa?pvs=25)[🛠️](https://southbridge-research.notion.site/Tools-The-Execution-Engine-2055fec70db181088a53cb43ae9168dc?pvs=25) [ Tools & The Execution Engine ](https://southbridge-research.notion.site/Tools-The-Execution-Engine-2055fec70db181088a53cb43ae9168dc?pvs=25)[🏗️](https://southbridge-research.notion.site/Architecture-The-Engine-Room-2055fec70db18192963cd6b3a5326476?pvs=25) [ Architecture: The Engine Room ](https://southbridge-research.notion.site/Architecture-The-Engine-Room-2055fec70db18192963cd6b3a5326476?pvs=25)[✨](https://southbridge-research.notion.site/Novel-Components-The-Innovations-That-Define-Claude-Code-2055fec70db181fdae5bd485823986c4?pvs=25) [ Novel Components: The Innovations That Define Claude Code ](https://southbridge-research.notion.site/Novel-Components-The-Innovations-That-Define-Claude-Code-2055fec70db181fdae5bd485823986c4?pvs=25)[✏️](https://southbridge-research.notion.site/File-Editing-AI-Assisted-Code-Modification-2055fec70db18100803ff7287c24c6cc?pvs=25) [ File Editing: AI-Assisted Code Modification ](https://southbridge-research.notion.site/File-Editing-AI-Assisted-Code-Modification-2055fec70db18100803ff7287c24c6cc?pvs=25)[💬](https://southbridge-research.notion.site/Prompt-Engineering-The-Art-of-Instructing-AI-2055fec70db181369002dcdea7d9e732?pvs=25) [ Prompt Engineering: The Art of Instructing AI ](https://southbridge-research.notion.site/Prompt-Engineering-The-Art-of-Instructing-AI-2055fec70db181369002dcdea7d9e732?pvs=25)[🤖](https://southbridge-research.notion.site/An-LLM-s-Perspective-What-It-s-Actually-Like-to-Receive-These-Instructions-2055fec70db18195b9f6ef655745749c?pvs=25) [ An LLM's Perspective: What It's Actually Like to Receive These Instructions ](https://southbridge-research.notion.site/An-LLM-s-Perspective-What-It-s-Actually-Like-to-Receive-These-Instructions-2055fec70db18195b9f6ef655745749c?pvs=25) It’s amazing that this is even possible, let alone in the time this took. I can’t say everything in the report is correct - perhaps the Claude team can weigh in - but it has all been really useful and instructive.