Quick Start
Clone the repo and start exploring the source in minutes
MCP Explorer Server
Use the
claude-code-explorer-mcp package to navigate the source interactivelyArchitecture Overview
Understand the core pipeline: CLI → Query Engine → Tools → UI
Tools Reference
Complete catalog of all 40+ agent tools with permissions and usage
How it leaked
On March 31, 2026, Chaofan Shou (@Fried_rice) discovered that Anthropic’s published npm package for Claude Code included a.map file referencing the full, unobfuscated TypeScript source — downloadable as a zip from Anthropic’s R2 storage bucket.
“Claude code source code has been leaked via a map file in their npm registry!” — @Fried_rice, March 31, 2026The original unmodified source is preserved in the
backup branch.
What is Claude Code?
Claude Code is a terminal-native AI coding assistant built as a single-binary CLI. At ~1,900 files and 512,000+ lines of TypeScript, it is a large, production-quality codebase with a sophisticated architecture.| Leaked | 2026-03-31 |
| Language | TypeScript (strict) |
| Runtime | Bun |
| Terminal UI | React + Ink |
| Scale | ~1,900 files · 512,000+ lines |
Key capabilities
40+ agent tools
File I/O, shell execution, web search, LSP, MCP, and more
85+ slash commands
Git, code review, session management, configuration
MCP support
Acts as both MCP client and server
Plugin system
Extend with custom plugins and reusable skills
Multi-agent
Spawn teams of parallel sub-agents for complex tasks
IDE bridge
Bidirectional integration with VS Code and JetBrains
Tech stack
| Category | Technology |
|---|---|
| Runtime | Bun ≥ 1.1.0 |
| Language | TypeScript (strict) |
| Terminal UI | React 19 + Ink |
| CLI parsing | Commander.js (extra-typings) |
| Schema validation | Zod v4 |
| Code search | ripgrep (via GrepTool) |
| Protocols | MCP SDK · LSP |
| API | Anthropic SDK |
| Telemetry | OpenTelemetry + gRPC |
| Feature flags | GrowthBook |
| Auth | OAuth 2.0 · JWT · macOS Keychain |
Architecture at a glance
Claude Code is organized around six primary systems: Tool system (src/tools/) — Every action Claude can take is a self-contained module with its own input schema, permission model, and execution logic. Tools include BashTool, FileEditTool, GlobTool, GrepTool, AgentTool, and ~35 more.
Command system (src/commands/) — User-facing slash commands invoked with / in the REPL. Over 85 commands cover git, code review, session management, configuration, MCP, and more.
Query Engine (src/QueryEngine.ts, ~46K lines) — The core LLM API engine. Handles streaming responses, tool-call loops, thinking mode, retries, and token counting.
Service layer (src/services/) — External integrations including the Anthropic API client, MCP connection management, OAuth, LSP, analytics, and plugin loading.
Bridge system (src/bridge/) — Bidirectional communication layer connecting IDE extensions (VS Code, JetBrains) with the CLI process.
Permission system (src/hooks/toolPermission/) — Checks permissions on every tool invocation and prompts the user for approval based on configured permission mode.
Explore the source
MCP Explorer Server
Install
claude-code-explorer-mcp to browse source interactively from any MCP clientExploration guide
Study paths, grep patterns, and key files for understanding the codebase
Architecture overview
Core pipeline, startup sequence, state management, rendering, and data flow
Contributing
Contribute documentation, MCP server improvements, or analysis tooling