π¨ Claude Code β Leaked Source (2026-03-31)
β οΈ Disclaimer
This repository archives source code that was leaked from Anthropic's npm registry on March 31, 2026.
All original source code remains the property of Anthropic.
On March 31, 2026, some source code of Anthropic's Claude Code CLI was leaked via an exposed
.mapfile in their npm package.
π Source Code: https://github.com/nirholas/claude-code
𧨠How It Leaked
Chaofan Shou (@Fried_rice) publicly disclosed the issue:
"Claude code source code has been leaked via a map file in their npm registry!"
β March 31, 2026
π https://x.com/Fried_rice/status/2038894956459290963
Root Cause
| Component | Issue |
|---|---|
| npm Package | Included a .map file |
| Source Map | Contained reference to full TypeScript source |
| Storage | Linked to downloadable archive (R2 bucket) |
| Exposure | Unobfuscated source publicly accessible |
π§ Overview
Claude Code is Anthropic's official CLI tool for interacting with Claude directly from the terminal.
Capabilities
- File editing & manipulation
- Command execution
- Codebase search
- Git workflow management
- Multi-agent orchestration
π¦ This repository contains the leaked src/ directory.
π Source Code: https://github.com/nirholas/claude-code
π Leak Summary
| Attribute | Details |
|---|---|
| Leaked On | 2026-03-31 |
| Language | TypeScript |
| Runtime | Bun |
| UI Framework | React + Ink |
| Scale | ~1,900 files |
| Code Size | 512,000+ LOC |
π Directory Structure
src/
βββ main.tsx # CLI entrypoint (Commander.js + Ink)
βββ commands.ts # Command registry
βββ tools.ts # Tool registry
βββ Tool.ts # Tool definitions
βββ QueryEngine.ts # Core LLM engine
βββ context.ts # Context management
βββ cost-tracker.ts # Token tracking
β
βββ commands/ # ~50 commands
βββ tools/ # ~40 tools
βββ components/ # ~140 UI components
βββ hooks/ # React hooks
βββ services/ # External integrations
βββ screens/ # Full-screen UI
βββ types/ # TS types
βββ utils/ # Utilities
β
βββ bridge/ # IDE integration
βββ coordinator/ # Multi-agent orchestration
βββ plugins/ # Plugin system
βββ skills/ # Skill system
βββ keybindings/ # Key mappings
βββ vim/ # Vim mode
βββ voice/ # Voice input
βββ remote/ # Remote sessions
βββ server/ # Server mode
βββ memdir/ # Persistent memory
βββ tasks/ # Task system
βββ state/ # State management
βββ migrations/ # Config migrations
βββ schemas/ # Zod schemas
βββ entrypoints/ # Init logic
βββ ink/ # Ink wrapper
βββ buddy/ # Easter egg
βββ native-ts/ # TS utilities
βββ outputStyles/ # Styling
βββ query/ # Query pipeline
βββ upstreamproxy/ # Proxy config
ποΈ Core Architecture
1οΈβ£ Tool System (src/tools/)
Each tool is a self-contained module with schema, permissions, and execution logic.
| Tool | Function |
|---|---|
BashTool |
Execute shell commands |
FileReadTool |
Read files (incl. PDFs, images) |
FileWriteTool |
Create/overwrite files |
FileEditTool |
Partial edits |
GlobTool |
Pattern search |
GrepTool |
Content search (ripgrep) |
WebFetchTool |
Fetch URLs |
WebSearchTool |
Web search |
AgentTool |
Spawn sub-agents |
SkillTool |
Execute skills |
MCPTool |
MCP integration |
LSPTool |
LSP integration |
NotebookEditTool |
Edit notebooks |
Task* |
Task management |
Team* |
Agent team control |
PlanMode* |
Planning mode toggle |
Worktree* |
Git isolation |
CronCreateTool |
Scheduling |
RemoteTriggerTool |
Remote triggers |
SleepTool |
Delay execution |
SyntheticOutputTool |
Structured output |
2οΈβ£ Command System (src/commands/)
Slash commands used in CLI:
| Command | Description |
|---|---|
/commit |
Git commit |
/review |
Code review |
/compact |
Context compression |
/mcp |
MCP management |
/config |
Settings |
/doctor |
Diagnostics |
/login / /logout
|
Auth |
/memory |
Memory mgmt |
/skills |
Skills |
/tasks |
Tasks |
/vim |
Vim mode |
/diff |
View changes |
/cost |
Usage cost |
/theme |
UI theme |
/context |
Context view |
/resume |
Restore session |
/share |
Share session |
3οΈβ£ Service Layer (src/services/)
| Service | Purpose |
|---|---|
api/ |
Anthropic API client |
mcp/ |
MCP server mgmt |
oauth/ |
Auth flow |
lsp/ |
Language servers |
analytics/ |
Feature flags |
plugins/ |
Plugin loader |
compact/ |
Context compression |
policyLimits/ |
Org limits |
remoteManagedSettings/ |
Remote config |
extractMemories/ |
Memory extraction |
tokenEstimation.ts |
Token counting |
teamMemorySync/ |
Sync |
4οΈβ£ Bridge System (src/bridge/)
Connects CLI β IDE (VS Code, JetBrains).
-
bridgeMain.tsβ main loop -
bridgeMessaging.tsβ protocol -
bridgePermissionCallbacks.tsβ permissions -
replBridge.tsβ REPL bridge -
jwtUtils.tsβ authentication -
sessionRunner.tsβ execution
5οΈβ£ Permission System
Located in: src/hooks/toolPermission/
- Enforces permissions on every tool execution
-
Modes include:
defaultplanautobypassPermissions
6οΈβ£ Feature Flags
Dead code elimination via Bun:
import { feature } from 'bun:bundle'
const voiceCommand = feature('VOICE_MODE')
? require('./commands/voice/index.js').default
: null
Notable Flags:
PROACTIVE, KAIROS, BRIDGE_MODE, DAEMON, VOICE_MODE, AGENT_TRIGGERS, MONITOR_TOOL
π Key Files
| File | Description |
|---|---|
QueryEngine.ts |
Core LLM engine (~46K LOC) |
Tool.ts |
Tool system definitions |
commands.ts |
Command registry |
main.tsx |
CLI bootstrap + UI init |
βοΈ Tech Stack
| Category | Technology |
|---|---|
| Runtime | Bun |
| Language | TypeScript |
| UI | React + Ink |
| CLI | Commander.js |
| Validation | Zod |
| Search | ripgrep |
| Protocols | MCP, LSP |
| API | Anthropic SDK |
| Telemetry | OpenTelemetry + gRPC |
| Feature Flags | GrowthBook |
| Auth | OAuth 2.0, JWT |
π§© Design Patterns
β‘ Parallel Prefetch
startMdmRawRead()
startKeychainPrefetch()
Improves startup performance by parallelizing I/O.
π€ Lazy Loading
Heavy dependencies (OpenTelemetry, gRPC) are loaded only when needed.
π€ Agent Swarms
- Sub-agents via
AgentTool - Coordinated through
coordinator/ - Team-based execution supported
π§ Skill System
- Defined in
skills/ - Executed via
SkillTool - Supports custom workflows
π Plugin Architecture
- First + third-party plugins
- Loaded dynamically via
plugins/
β οΈ Final Disclaimer
This repository archives leaked source code from Anthropicβs npm registry (2026-03-31).
All rights belong to Anthropic.
Top comments (1)
imho This repository may be removed due to copyright infringement. Incidentally, this code has already been rewritten for Python and Rust