{
  "markdown": "<div align=\"center\">\n\n# Claude Code — Leaked Source\n\n**The full source code of Anthropic's Claude Code CLI, leaked on March 31, 2026**\n\n[![TypeScript](https://img.shields.io/badge/TypeScript-512K%2B_lines-3178C6?logo=typescript&logoColor=white)](#tech-stack)\n[![Bun](https://img.shields.io/badge/Runtime-Bun-f472b6?logo=bun&logoColor=white)](#tech-stack)\n[![React + Ink](https://img.shields.io/badge/UI-React_%2B_Ink-61DAFB?logo=react&logoColor=black)](#tech-stack)\n[![Files](https://img.shields.io/badge/~1,900_files-source_only-grey)](#directory-structure)\n[![MCP Server](https://img.shields.io/badge/MCP-Explorer_Server-blueviolet)](#-explore-with-mcp-server)\n[![npm](https://img.shields.io/npm/v/warrioraashuu-codemaster?label=npm&color=cb3837&logo=npm)](https://www.npmjs.com/package/warrioraashuu-codemaster)\n[![Twitter Follow](https://img.shields.io/twitter/follow/warrioraashuu?style=social)](https://twitter.com/intent/follow?screen_name=warrioraashuu)\n\n> The original unmodified leaked source is preserved in the [`backup` branch](https://github.com/codeaashu/claude-code/tree/backup).\n\n</div>\n\n---\n\n <div align=\"center\">\n<table>\n<tr>\n  \n`The X-Ray Intelligence Engine for Your Codebase.`\n  \n<td width=\"120\" align=\"center\">\n<img src=\"https://repoxray.2clabs.tech/logo.png\" width=\"80\" height=\"80\" alt=\"RepoXray Logo\"/>\n</td>\n<td>\n<h2 align=\"center\">Understand Any Codebase<br>X-Ray Any Repo, in Seconds.<br>\n<a href=\"https://repoxray.2clabs.tech/\"><strong>repoxray.2clabs.tech</strong></a></h2>\n</td>\n</tr>\n</table>\n\n`Spend less time reading code, more time building.`\n\n</div>\n\n---\n\n## Table of Contents\n\n- [How It Leaked](#how-it-leaked)\n- [What Is Claude Code?](#what-is-claude-code)\n- [Documentation](#-documentation)\n- [Explore with MCP Server](#-explore-with-mcp-server)\n- [Directory Structure](#directory-structure)\n- [Architecture](#architecture)\n  - [Tool System](#1-tool-system)\n  - [Command System](#2-command-system)\n  - [Service Layer](#3-service-layer)\n  - [Bridge System](#4-bridge-system)\n  - [Permission System](#5-permission-system)\n  - [Feature Flags](#6-feature-flags)\n- [Key Files](#key-files)\n- [Tech Stack](#tech-stack)\n- [Design Patterns](#design-patterns)\n- [GitPretty Setup](#gitpretty-setup)\n- [Contributing](#contributing)\n- [Disclaimer](#disclaimer)\n\n---\n\n## How It Leaked\n\n[Chaofan Shou (@Fried_rice)](https://x.com/Fried_rice) discovered that the 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.\n\n> **\"Claude code source code has been leaked via a map file in their npm registry!\"**\n>\n> — [@Fried_rice, March 31, 2026](https://x.com/Fried_rice/status/2038894956459290963)\n\n---\n\n## What Is Claude Code?\n\nClaude Code is Anthropic's official CLI tool for interacting with Claude directly from the terminal — editing files, running commands, searching codebases, managing git workflows, and more. This repository contains the leaked `src/` directory.\n\n| | |\n|---|---|\n| **Leaked** | 2026-03-31 |\n| **Language** | TypeScript (strict) |\n| **Runtime** | [Bun](https://bun.sh) |\n| **Terminal UI** | [React](https://react.dev) + [Ink](https://github.com/vadimdemedes/ink) |\n| **Scale** | ~1,900 files · 512,000+ lines of code |\n\n---\n\n## � Documentation\n\nFor in-depth guides, see the [`docs/`](docs/) directory:\n\n| Guide | Description |\n|-------|-------------|\n| **[Architecture](docs/architecture.md)** | Core pipeline, startup sequence, state management, rendering, data flow |\n| **[Tools Reference](docs/tools.md)** | Complete catalog of all ~40 agent tools with categories and permission model |\n| **[Commands Reference](docs/commands.md)** | All ~85 slash commands organized by category |\n| **[Subsystems Guide](docs/subsystems.md)** | Deep dives into Bridge, MCP, Permissions, Plugins, Skills, Tasks, Memory, Voice |\n| **[Exploration Guide](docs/exploration-guide.md)** | How to navigate the codebase — study paths, grep patterns, key files |\n\nAlso see: [CONTRIBUTING.md](CONTRIBUTING.md) · [MCP Server README](mcp-server/README.md)\n\n---\n\n## �🔍 Explore with MCP Server\n\nThis repo ships an [MCP server](https://modelcontextprotocol.io/) that lets any MCP-compatible client (Claude Code, Claude Desktop, VS Code Copilot, Cursor) explore the full source interactively.\n\n### Install from npm\n\nThe MCP server is published as [`warrioraashuu-codemaster`](https://www.npmjs.com/package/warrioraashuu-codemaster) on npm — no need to clone the repo:\n\n```bash\n# Claude Code\nclaude mcp add warrioraashuu-codemaster -- npx -y warrioraashuu-codemaster\n```\n\n### One-liner setup (from source)\n\n```bash\ngit clone https://github.com/codeaashu/claude-code.git ~/claude-code \\\n  && cd ~/claude-code/mcp-server \\\n  && npm install && npm run build \\\n  && claude mcp add claude-code-explorer -- node ~/claude-code/mcp-server/dist/index.js\n```\n\n<details>\n<summary><strong>Step-by-step setup</strong></summary>\n\n```bash\n# 1. Clone the repo\ngit clone https://github.com/codeaashu/claude-code.git\ncd claude-code/mcp-server\n\n# 2. Install & build\nnpm install && npm run build\n\n# 3. Register with Claude Code\nclaude mcp add claude-code-explorer -- node /absolute/path/to/claude-code/mcp-server/dist/index.js\n```\n\nReplace `/absolute/path/to/claude-code` with your actual clone path.\n\n</details>\n\n<details>\n<summary><strong>VS Code / Cursor / Claude Desktop config</strong></summary>\n\n**VS Code** — add to `.vscode/mcp.json`:\n```json\n{\n  \"servers\": {\n    \"claude-code-explorer\": {\n      \"type\": \"stdio\",\n      \"command\": \"node\",\n      \"args\": [\"${workspaceFolder}/mcp-server/dist/index.js\"],\n      \"env\": { \"CLAUDE_CODE_SRC_ROOT\": \"${workspaceFolder}/src\" }\n    }\n  }\n}\n```\n\n**Claude Desktop** — add to your config file:\n```json\n{\n  \"mcpServers\": {\n    \"claude-code-explorer\": {\n      \"command\": \"node\",\n      \"args\": [\"/absolute/path/to/claude-code/mcp-server/dist/index.js\"],\n      \"env\": { \"CLAUDE_CODE_SRC_ROOT\": \"/absolute/path/to/claude-code/src\" }\n    }\n  }\n}\n```\n\n**Cursor** — add to `~/.cursor/mcp.json` (same format as Claude Desktop).\n\n</details>\n\n### Available tools & prompts\n\n| Tool | Description |\n|------|-------------|\n| `list_tools` | List all ~40 agent tools with source files |\n| `list_commands` | List all ~50 slash commands with source files |\n| `get_tool_source` | Read full source of any tool (e.g. BashTool, FileEditTool) |\n| `get_command_source` | Read source of any slash command (e.g. review, mcp) |\n| `read_source_file` | Read any file from `src/` by path |\n| `search_source` | Grep across the entire source tree |\n| `list_directory` | Browse `src/` directories |\n| `get_architecture` | High-level architecture overview |\n\n| Prompt | Description |\n|--------|-------------|\n| `explain_tool` | Deep-dive into how a specific tool works |\n| `explain_command` | Understand a slash command's implementation |\n| `architecture_overview` | Guided tour of the full architecture |\n| `how_does_it_work` | Explain any subsystem (permissions, MCP, bridge, etc.) |\n| `compare_tools` | Side-by-side comparison of two tools |\n\n**Try asking:** *\"How does the BashTool work?\"* · *\"Search for where permissions are checked\"* · *\"Show me the /review command source\"*\n\n### Custom source path / Remove\n\n```bash\n# Custom source location\nclaude mcp add claude-code-explorer -e CLAUDE_CODE_SRC_ROOT=/path/to/src -- node /path/to/mcp-server/dist/index.js\n\n# Remove\nclaude mcp remove claude-code-explorer\n```\n\n---\n\n## Directory Structure\n\n```\nsrc/\n├── main.tsx                 # Entrypoint — Commander.js CLI parser + React/Ink renderer\n├── QueryEngine.ts           # Core LLM API caller (~46K lines)\n├── Tool.ts                  # Tool type definitions (~29K lines)\n├── commands.ts              # Command registry (~25K lines)\n├── tools.ts                 # Tool registry\n├── context.ts               # System/user context collection\n├── cost-tracker.ts          # Token cost tracking\n│\n├── tools/                   # Agent tool implementations (~40)\n├── commands/                # Slash command implementations (~50)\n├── components/              # Ink UI components (~140)\n├── services/                # External service integrations\n├── hooks/                   # React hooks (incl. permission checks)\n├── types/                   # TypeScript type definitions\n├── utils/                   # Utility functions\n├── screens/                 # Full-screen UIs (Doctor, REPL, Resume)\n│\n├── bridge/                  # IDE integration (VS Code, JetBrains)\n├── coordinator/             # Multi-agent orchestration\n├── plugins/                 # Plugin system\n├── skills/                  # Skill system\n├── server/                  # Server mode\n├── remote/                  # Remote sessions\n├── memdir/                  # Persistent memory directory\n├── tasks/                   # Task management\n├── state/                   # State management\n│\n├── voice/                   # Voice input\n├── vim/                     # Vim mode\n├── keybindings/             # Keybinding configuration\n├── schemas/                 # Config schemas (Zod)\n├── migrations/              # Config migrations\n├── entrypoints/             # Initialization logic\n├── query/                   # Query pipeline\n├── ink/                     # Ink renderer wrapper\n├── buddy/                   # Companion sprite (Easter egg 🐣)\n├── native-ts/               # Native TypeScript utils\n├── outputStyles/            # Output styling\n└── upstreamproxy/           # Proxy configuration\n```\n\n---\n\n## Architecture\n\n### 1. Tool System\n\n> `src/tools/` — Every tool Claude can invoke is a self-contained module with its own input schema, permission model, and execution logic.\n\n| Tool | Description |\n|---|---|\n| **File I/O** | |\n| `FileReadTool` | Read files (images, PDFs, notebooks) |\n| `FileWriteTool` | Create / overwrite files |\n| `FileEditTool` | Partial modification (string replacement) |\n| `NotebookEditTool` | Jupyter notebook editing |\n| **Search** | |\n| `GlobTool` | File pattern matching |\n| `GrepTool` | ripgrep-based content search |\n| `WebSearchTool` | Web search |\n| `WebFetchTool` | Fetch URL content |\n| **Execution** | |\n| `BashTool` | Shell command execution |\n| `SkillTool` | Skill execution |\n| `MCPTool` | MCP server tool invocation |\n| `LSPTool` | Language Server Protocol integration |\n| **Agents & Teams** | |\n| `AgentTool` | Sub-agent spawning |\n| `SendMessageTool` | Inter-agent messaging |\n| `TeamCreateTool` / `TeamDeleteTool` | Team management |\n| `TaskCreateTool` / `TaskUpdateTool` | Task management |\n| **Mode & State** | |\n| `EnterPlanModeTool` / `ExitPlanModeTool` | Plan mode toggle |\n| `EnterWorktreeTool` / `ExitWorktreeTool` | Git worktree isolation |\n| `ToolSearchTool` | Deferred tool discovery |\n| `SleepTool` | Proactive mode wait |\n| `CronCreateTool` | Scheduled triggers |\n| `RemoteTriggerTool` | Remote trigger |\n| `SyntheticOutputTool` | Structured output generation |\n\n### 2. Command System\n\n> `src/commands/` — User-facing slash commands invoked with `/` in the REPL.\n\n| Command | Description | | Command | Description |\n|---|---|---|---|---|\n| `/commit` | Git commit | | `/memory` | Persistent memory |\n| `/review` | Code review | | `/skills` | Skill management |\n| `/compact` | Context compression | | `/tasks` | Task management |\n| `/mcp` | MCP server management | | `/vim` | Vim mode toggle |\n| `/config` | Settings | | `/diff` | View changes |\n| `/doctor` | Environment diagnostics | | `/cost` | Check usage cost |\n| `/login` / `/logout` | Auth | | `/theme` | Change theme |\n| `/context` | Context visualization | | `/share` | Share session |\n| `/pr_comments` | PR comments | | `/resume` | Restore session |\n| `/desktop` | Desktop handoff | | `/mobile` | Mobile handoff |\n\n### 3. Service Layer\n\n> `src/services/` — External integrations and core infrastructure.\n\n| Service | Description |\n|---|---|\n| `api/` | Anthropic API client, file API, bootstrap |\n| `mcp/` | Model Context Protocol connection & management |\n| `oauth/` | OAuth 2.0 authentication |\n| `lsp/` | Language Server Protocol manager |\n| `analytics/` | GrowthBook feature flags & analytics |\n| `plugins/` | Plugin loader |\n| `compact/` | Conversation context compression |\n| `extractMemories/` | Automatic memory extraction |\n| `teamMemorySync/` | Team memory synchronization |\n| `tokenEstimation.ts` | Token count estimation |\n| `policyLimits/` | Organization policy limits |\n| `remoteManagedSettings/` | Remote managed settings |\n\n### 4. Bridge System\n\n> `src/bridge/` — Bidirectional communication layer connecting IDE extensions (VS Code, JetBrains) with the CLI.\n\nKey files: `bridgeMain.ts` (main loop) · `bridgeMessaging.ts` (protocol) · `bridgePermissionCallbacks.ts` (permission callbacks) · `replBridge.ts` (REPL session) · `jwtUtils.ts` (JWT auth) · `sessionRunner.ts` (session execution)\n\n### 5. Permission System\n\n> `src/hooks/toolPermission/` — Checks permissions on every tool invocation.\n\nPrompts the user for approval/denial or auto-resolves based on the configured permission mode: `default`, `plan`, `bypassPermissions`, `auto`, etc.\n\n### 6. Feature Flags\n\nDead code elimination at build time via Bun's `bun:bundle`:\n\n```typescript\nimport { feature } from 'bun:bundle'\n\nconst voiceCommand = feature('VOICE_MODE')\n  ? require('./commands/voice/index.js').default\n  : null\n```\n\nNotable flags: `PROACTIVE` · `KAIROS` · `BRIDGE_MODE` · `DAEMON` · `VOICE_MODE` · `AGENT_TRIGGERS` · `MONITOR_TOOL`\n\n---\n\n## Key Files\n\n| File | Lines | Purpose |\n|------|------:|---------|\n| `QueryEngine.ts` | ~46K | Core LLM API engine — streaming, tool loops, thinking mode, retries, token counting |\n| `Tool.ts` | ~29K | Base types/interfaces for all tools — input schemas, permissions, progress state |\n| `commands.ts` | ~25K | Command registration & execution with conditional per-environment imports |\n| `main.tsx` | — | CLI parser + React/Ink renderer; parallelizes MDM, keychain, and GrowthBook on startup |\n\n---\n\n## Tech Stack\n\n| Category | Technology |\n|---|---|\n| Runtime | [Bun](https://bun.sh) |\n| Language | TypeScript (strict) |\n| Terminal UI | [React](https://react.dev) + [Ink](https://github.com/vadimdemedes/ink) |\n| CLI Parsing | [Commander.js](https://github.com/tj/commander.js) (extra-typings) |\n| Schema Validation | [Zod v4](https://zod.dev) |\n| Code Search | [ripgrep](https://github.com/BurntSushi/ripgrep) (via GrepTool) |\n| Protocols | [MCP SDK](https://modelcontextprotocol.io) · LSP |\n| API | [Anthropic SDK](https://docs.anthropic.com) |\n| Telemetry | OpenTelemetry + gRPC |\n| Feature Flags | GrowthBook |\n| Auth | OAuth 2.0 · JWT · macOS Keychain |\n\n---\n\n## Design Patterns\n\n<details>\n<summary><strong>Parallel Prefetch</strong> — Startup optimization</summary>\n\nMDM settings, keychain reads, and API preconnect fire in parallel as side-effects before heavy module evaluation:\n\n```typescript\n// main.tsx\nstartMdmRawRead()\nstartKeychainPrefetch()\n```\n\n</details>\n\n<details>\n<summary><strong>Lazy Loading</strong> — Deferred heavy modules</summary>\n\nOpenTelemetry (~400KB) and gRPC (~700KB) are loaded via dynamic `import()` only when needed.\n\n</details>\n\n<details>\n<summary><strong>Agent Swarms</strong> — Multi-agent orchestration</summary>\n\nSub-agents spawn via `AgentTool`, with `coordinator/` handling orchestration. `TeamCreateTool` enables team-level parallel work.\n\n</details>\n\n<details>\n<summary><strong>Skill System</strong> — Reusable workflows</summary>\n\nDefined in `skills/` and executed through `SkillTool`. Users can add custom skills.\n\n</details>\n\n<details>\n<summary><strong>Plugin Architecture</strong> — Extensibility</summary>\n\nBuilt-in and third-party plugins loaded through the `plugins/` subsystem.\n\n</details>\n\n---\n\n## GitPretty Setup\n\n<details>\n<summary>Show per-file emoji commit messages in GitHub's file UI</summary>\n\n```bash\n# Apply emoji commits\nbash ./gitpretty-apply.sh .\n\n# Optional: install hooks for future commits\nbash ./gitpretty-apply.sh . --hooks\n\n# Push as usual\ngit push origin main\n```\n\n</details>\n\n---\n\n## Contributing\n\nContributions to documentation, the MCP server, and exploration tooling are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n> **Note:** The `src/` directory is the original leaked source and should not be modified.\n\n---\n\n## Disclaimer\n\nThis repository archives source code leaked from Anthropic's npm registry on **2026-03-31**. All original source code is the property of [Anthropic](https://www.anthropic.com). This is not an official release and is not licensed for redistribution. Contact [aashuu ✦](https://x.com/warrioraashuu) for any comments.\n\n---\n\n<a href=\"https://www.star-history.com/?repos=codeaashu%2Fclaude-code&type=date&legend=bottom-right\">\n <picture>\n   <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/image?repos=codeaashu/claude-code&type=date&theme=dark&legend=bottom-right\" />\n   <source media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/image?repos=codeaashu/claude-code&type=date&legend=bottom-right\" />\n   <img alt=\"Star History Chart\" src=\"https://api.star-history.com/image?repos=codeaashu/claude-code&type=date&legend=bottom-right\" />\n </picture>\n</a>\n\n\n---\n\nCooked by aashuu ✦ (Ashutosh Kumar)<br>\nFounder of [2C Labs](https://www.2clabs.tech)\n\nI build tech businesses through SaaS products across every layer of the internet ( Web2 ▪︎ Web3 ▪︎ AI-native ▪︎ Infrastructure )\n\nConnect here:<br>\nWebsite [www.aashuu.me](https://www.aashuu.me) ✦  𝕏 [@warrioraashuu](https://x.com/warrioraashuu) ✦  LinkedIn [@warrioraashuu](https://www.linkedin.com/in/warrioraashuu/)\n\n",
  "bytes": 17571,
  "sha": "9d0eb7e0a0b1c29c2bb9e7f7e83fc2abb2ceef681925d16793cae3b8c4fc2b4a",
  "repo_slug": "codeaashu/claude-code",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_divu2025_codemaster_10c71067/readme"
}