
I Reverse-Engineered Claude Code's 80K Lines of Source. Here's What I Found.
Most Claude Code tips are surface-level. "Write better prompts." "Be specific." "Give it context." Fine advice, but it misses the point. The real leverage comes from understanding why Claude Code was built the way it was. So I read the source — all 80,000 lines of it, with four parallel subagents doing the exploration — and extracted the 15 design decisions the authors encoded into the TypeScript. Here's what I found. The Core Insight That Changes Everything One turn in Claude Code is not a function call. It's an AsyncGenerator . // QueryEngine.ts · line 209 export class QueryEngine { async * submitMessage ( prompt : string | ContentBlockParam [], options ?: { uuid ?: string ; isMeta ?: boolean }, ): AsyncGenerator < SDKMessage , void , unknown > } That single design decision explains dozens of behaviors. Every LLM response token, every tool execution update, every file change notification — all of it flows through one stream. The queryLoop runs five levels deep with yield* chains at e
Continue reading on Dev.to
Opens in a new tab
