Skip to content

Latest commit

 

History

History
330 lines (244 loc) · 11.7 KB

File metadata and controls

330 lines (244 loc) · 11.7 KB

CLAUDE CODE SOURCE :)

⚡ The Complete Anthropic Claude Code CLI Source Code ⚡


Claude Code



Follow AnukarOP

TypeScript Bun React
Leaked Lines of Code Files


🚨 FULL SOURCE CODE OF ANTHROPIC'S CLAUDE CODE CLI 🚨

The AI coding assistant that powers millions of developers worldwide

Leaked via npm source map exposure on March 31, 2026


📂 Browse Source🔧 Architecture🛠️ Tools⚡ Commands📊 Tech Stack


🔥 What Is This?

This repository contains the COMPLETE leaked source code of Anthropic's Claude Code — the revolutionary AI-powered CLI that lets developers interact with Claude AI directly from their terminal.

On March 31, 2026, A security researcher discovered that Claude Code's full TypeScript source was accidentally exposed via a .map file in the npm package:

🐦 "Claude code source code has been leaked via a map file in their npm registry!"

The source map pointed to unobfuscated TypeScript files hosted on Anthropic's R2 storage — making the entire codebase publicly downloadable.


⭐ Why This Matters

Feature Details
🤖 AI Agent Architecture See exactly how Claude Code's agentic system works
🔧 40+ AI Tools File editing, web search, code execution, and more
💬 50+ Commands Full slash command implementation
🔌 MCP Protocol Model Context Protocol integration
🌐 IDE Bridge VS Code & JetBrains integration code
🧠 Multi-Agent System Agent swarm orchestration
🎤 Voice Mode Voice input implementation
📊 512,000+ Lines Production-grade TypeScript

📂 Directory Structure

📦 source code/
├── 🚀 main.tsx                 # CLI entrypoint
├── 📋 commands.ts              # Command registry
├── 🔧 tools.ts                 # Tool registry  
├── 🤖 QueryEngine.ts           # LLM query engine (46K lines!)
├── 📊 cost-tracker.ts          # Token cost tracking
│
├── 📁 commands/                # 50+ slash commands
├── 📁 tools/                   # 40+ AI agent tools
├── 📁 components/              # 140+ React/Ink UI components
├── 📁 services/                # API, MCP, OAuth, LSP integrations
├── 📁 bridge/                  # IDE communication layer
├── 📁 coordinator/             # Multi-agent orchestration
├── 📁 plugins/                 # Plugin system
├── 📁 skills/                  # Skill system
├── 📁 voice/                   # Voice input
├── 📁 vim/                     # Vim mode
└── 📁 ... and 20+ more directories

🏗️ Architecture Overview

🛠️ Tool System

Every capability Claude Code has is implemented as a modular tool

Tool Description Category
🖥️ BashTool Shell command execution System
📖 FileReadTool Read files, images, PDFs, notebooks Files
✏️ FileWriteTool Create and overwrite files Files
🔧 FileEditTool Partial file modification Files
🔍 GlobTool File pattern matching Search
🔎 GrepTool Content search (ripgrep) Search
🌐 WebFetchTool Fetch URL content Web
🔍 WebSearchTool Web search Web
🤖 AgentTool Spawn sub-agents Agents
SkillTool Execute skills Skills
🔌 MCPTool MCP server integration Protocol
📡 LSPTool Language Server Protocol Protocol
📓 NotebookEditTool Jupyter notebook editing Files
📋 TaskCreateTool Task management Tasks
👥 TeamCreateTool Team agent management Agents
🗺️ EnterPlanModeTool Planning mode Modes
🌳 EnterWorktreeTool Git worktree isolation Git
CronCreateTool Scheduled triggers Automation
🎯 SyntheticOutputTool Structured output Output

⚡ Command System

50+ slash commands for power users

Command Description
/commit 📝 Create git commits with AI-generated messages
/review 🔍 AI-powered code review
/compact 📦 Compress conversation context
/mcp 🔌 MCP server management
/config ⚙️ Settings management
/doctor 🏥 Environment diagnostics
/login / /logout 🔐 Authentication
/memory 🧠 Persistent memory management
/skills ⚡ Skill management
/tasks 📋 Task management
/vim ⌨️ Vim mode toggle
/diff 📊 View changes
/cost 💰 Check usage cost
/theme 🎨 Change theme
/pr_comments 💬 View PR comments
/resume ⏮️ Restore previous session
/share 🔗 Share session
/desktop 🖥️ Desktop app handoff

🔌 Service Layer

External integrations and core services

Service Description
🔗 api/ Anthropic API client & bootstrap
🔌 mcp/ Model Context Protocol integration
🔐 oauth/ OAuth 2.0 authentication
📡 lsp/ Language Server Protocol
📊 analytics/ Feature flags (GrowthBook)
🔌 plugins/ Plugin loader
📦 compact/ Context compression
🧠 extractMemories/ Auto memory extraction
👥 teamMemorySync/ Team memory sync

🌉 Bridge System

IDE integration layer for VS Code & JetBrains

┌─────────────────┐     ┌─────────────────┐
│   VS Code /     │◄───►│  Claude Code    │
│   JetBrains     │     │     CLI         │
└─────────────────┘     └─────────────────┘
         │                      │
         └──────────┬───────────┘
                    │
         ┌──────────▼──────────┐
         │   Bridge Protocol   │
         │  - JWT Auth         │
         │  - Message Protocol │
         │  - Permission CB    │
         └─────────────────────┘

🔒 Permission System

Security-first design with granular permissions

Checks permissions on every tool invocation:

  • default - Ask for approval
  • 📋 plan - Plan mode restrictions
  • auto - Automatic approval
  • 🔓 bypassPermissions - Skip checks

🚀 Feature Flags

Dead code elimination via Bun's bun:bundle:

import { feature } from 'bun:bundle'

// Inactive code is completely stripped at build time
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 Lines Description
🧠 QueryEngine.ts ~46,000 Core LLM engine - streaming, tool loops, retry logic
🔧 Tool.ts ~29,000 Tool interfaces & permission models
📋 commands.ts ~25,000 Command registry & execution
🚀 main.tsx - CLI entrypoint with parallel prefetch

💻 Tech Stack


Bun

TypeScript

React

Zod
Category Technology
Runtime Bun - Ultra-fast JavaScript runtime
📝 Language TypeScript (strict mode)
🖥️ Terminal UI React + Ink
🔧 CLI Parsing Commander.js
Validation Zod v4
🔍 Code Search ripgrep
🔌 Protocols MCP SDK, LSP
🤖 API Anthropic SDK
📊 Telemetry OpenTelemetry + gRPC
🚩 Feature Flags GrowthBook
🔐 Auth OAuth 2.0, JWT, macOS Keychain

🎯 Notable Design Patterns

⚡ Parallel Prefetch

// main.tsx — blazing fast startup
startMdmRawRead()      // MDM settings
startKeychainPrefetch() // Keychain reads
// All run in parallel before heavy imports!

📦 Lazy Loading

Heavy modules loaded only when needed:

  • OpenTelemetry
  • gRPC
  • Analytics
  • Feature-gated subsystems

🤖 Agent Swarms

Multi-agent orchestration via coordinator/ — spawn sub-agents with AgentTool, create teams with TeamCreateTool

⚡ Skill System

Reusable workflows in skills/ executed via SkillTool — extensible with custom skills

🔌 Plugin Architecture

Full plugin system in plugins/ for built-in and third-party extensions


🔗 Quick Links

Resource Link
📂 Source Code source code/
🔧 Tools source code/tools/
⚡ Commands source code/commands/
🎨 Components source code/components/
🌉 Bridge source code/bridge/

⚠️ Disclaimer

This repository is for educational and security research purposes only.

The original Claude Code source is the property of Anthropic. This repository is NOT affiliated with, endorsed by, or maintained by Anthropic.


⭐ Star This Repo!

If you found this useful, please give it a star!

GitHub stars


🔍 Keywords / Tags

claude anthropic claude-code ai artificial-intelligence llm large-language-model cli command-line typescript bun react ink terminal ai-coding ai-assistant code-assistant developer-tools source-code security-research mcp model-context-protocol agent ai-agent multi-agent