Claude Code Architecture Analysis from Leaked Source Maps

Technical Stack and Architecture
The Claude Code package published to npm on March 31, 2026, included .map files that revealed the complete TypeScript source code. The codebase consists of approximately 1,900 files with 512,000+ lines of TypeScript.
Core Technologies
- Runtime: Bun
- Language: TypeScript (strict mode)
- Terminal UI: React + Ink (React for CLI)
- CLI Parsing: Commander.js with extra typings
- Schema Validation: Zod v4
- Code Search: ripgrep via GrepTool
- Protocols: MCP SDK, LSP (vscode-jsonrpc)
- API: Anthropic SDK
- Telemetry: OpenTelemetry + gRPC (lazy-loaded, ~400KB + 700KB)
- Feature Flags: GrowthBook
- Auth: OAuth 2.0, JWT, macOS Keychain
- State Management: Zustand (React-based store)
Directory Structure Highlights
The src/ directory contains:
main.tsx- Entry point with Commander.js CLI + React/Ink renderingcommands.ts- Command registry with 100+ commandstools.ts- Tool registry with 38+ toolsTool.ts- Tool type definitionsQueryEngine.ts- LLM query engine (~46K lines)query.ts- Main query loop (~1,729 lines)context.ts- System/user context collectioncost-tracker.ts- Token cost trackingcommands/- Slash command implementations (100+)tools/- Tool implementations (38+)components/- Ink UI components (~140)hooks/- React Hooks + permission hooksservices/- External service integrations including API, MCP, LSP, context compression, memory extraction, and analyticsconstants/- System prompts + constantsbridge/- IDE integration bridgecoordinator/- Multi-agent coordinatorplugins/- Plugin systemskills/- Skill systemmemdir/- Persistent memory systemtasks/- Task management systemstate/- State managementremote/- Remote sessionsserver/- Server modevim/- Vim mode with complete state machinevoice/- Voice inputkeybindings/- Keybinding systemscreens/- Fullscreen UI (Doctor, REPL, Resume)schemas/- Zod config schemasmigrations/- Config migrationsquery/- Query pipeline submodulesoutputStyles/- Output stylesbuddy/- Companion sprite (easter egg)
Core Data Flow
The system follows this data flow pattern:
- User input (terminal / IDE / remote)
main.tsx→ Commander.js parsingREPL.tsx(main interaction loop)QueryEngine.submitMessage()← session lifecycle- Message preparation stage includes:
applyToolResultBudget()- result size capsnipCompact()- snippet compactionmicroCompact()- micro compactioncontextCollapse()- context collapseautoCompact()- automatic compaction
This analysis is based on the leaked source code that provides insight into how a production AI coding agent manages context, tools, and multi-agent coordination.
📖 Read the full source: r/ClaudeAI
👀 See Also

Wolfram Tech Now Available as Foundation Tool for LLM Systems
Stephen Wolfram announces Wolfram Language is now available as a foundation tool for LLM systems, providing deep computation and precise knowledge to supplement LLM capabilities. The announcement follows three years of development since the initial Wolfram plugin for ChatGPT was released in March 2023.

Hands-On with Tencent's Model: Strong for Agentic Workflows, Weak for Complex Coding
Tencent's model scores 8/10 for agentic tasks with low hallucination rates, but fails on complex coding like Notion API schemas. Avoid for backend logic.

JavaClaw Beta: Java-Based AI Assistant Built on Spring AI and JobRunr
JobRunr team released JavaClaw beta, a Java version of OpenClaw that runs locally with multi-channel support, LLM choice, and background job processing via JobRunr. Built with Spring Boot 4, Spring AI, and Spring Modulith.

Pneuma: An AI-Generated Desktop Environment Where Software Materializes from Descriptions
Pneuma is a desktop computing environment where you describe what you want—a CPU monitor, game, notes app, or data visualizer—and a working program materializes in seconds. The system generates self-contained Rust modules, compiles them to WebAssembly, and executes them in sandboxed Wasmtime instances with GPU rendering via wgpu.