Skip to main content
Claude Code is Anthropic’s official CLI for interacting with Claude directly from the terminal. It edits files, runs shell commands, searches codebases, manages git workflows, and orchestrates multi-agent tasks — all through natural language. This documentation is based on the full source code leaked from Anthropic’s npm registry on March 31, 2026.

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 interactively

Architecture 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, 2026
The original unmodified source is preserved in the backup branch.
This repository archives source code that was unintentionally exposed from Anthropic’s npm registry. All original source code is the property of Anthropic. This is not an official release and is not licensed for redistribution.

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.
Leaked2026-03-31
LanguageTypeScript (strict)
RuntimeBun
Terminal UIReact + 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

CategoryTechnology
RuntimeBun ≥ 1.1.0
LanguageTypeScript (strict)
Terminal UIReact 19 + Ink
CLI parsingCommander.js (extra-typings)
Schema validationZod v4
Code searchripgrep (via GrepTool)
ProtocolsMCP SDK · LSP
APIAnthropic SDK
TelemetryOpenTelemetry + gRPC
Feature flagsGrowthBook
AuthOAuth 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.
The fastest way to explore the architecture is with the MCP Explorer server. Install it with a single command and ask your AI assistant questions like “How does the BashTool work?” or “Show me the permission system.”

Explore the source

MCP Explorer Server

Install claude-code-explorer-mcp to browse source interactively from any MCP client

Exploration 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

Build docs developers (and LLMs) love