Unofficial Community DocumentationThese docs are written by the community based on reverse-engineered analysis of Claude Code’s publicly available npm package. This is not affiliated with, endorsed by, or approved by Anthropic.All original source code, system prompts, and intellectual property belong to Anthropic. This documentation exists purely for educational and research purposes.The source code was legally obtained from the public npm registry via npm pack @anthropic-ai/claude-code — no systems were breached, no credentials were stolen, and no unauthorized access occurred.Accuracy is not guaranteed — implementation details may change across versions. Always refer to Anthropic’s official docs for production usage.Version analyzed: Based on leaked source from March 31, 2026

What is Claude Code?

Claude Code is Anthropic’s official command-line interface (CLI) tool that brings Claude’s capabilities directly into your terminal. Unlike chat-based interfaces, Claude Code is purpose-built for software engineering workflows — it can read and edit files, execute shell commands, search codebases, manage git operations, and orchestrate complex multi-step tasks. Think of it as an agentic coding assistant that lives in your terminal, with direct access to your filesystem, shell, and development tools.

Key Characteristics

  • Terminal-native: Built with React + Ink for rich CLI UIs
  • Agentic: Autonomous tool execution with permission controls
  • Extensible: Plugin system, MCP integration, custom skills
  • Multi-model: Supports Claude Opus, Sonnet, and Haiku variants
  • IDE-integrated: Bridge system connects VS Code and JetBrains IDEs

How the Source Became Available

On March 31, 2026, security researcher Chaofan Shou (@Fried_rice) discovered that Anthropic had accidentally shipped source maps alongside the minified bundle in their public npm package @anthropic-ai/claude-code.

The Discovery

The npm package contained a .map file that referenced the full, unobfuscated TypeScript source code. This source was hosted in a publicly accessible R2 storage bucket and could be downloaded by anyone who ran:
npm pack @anthropic-ai/claude-code
This was not a hack, not a breach, and not illegal. The files were sitting on the public npm registry, accessible to anyone. Anthropic inadvertently published their internal source code as part of their standard npm release process.

What Was Exposed

The leak revealed:
  • Complete TypeScript source code (~1,900 files, 512,000+ lines)
  • System prompts and agent instructions
  • Tool implementations and schemas
  • Internal architecture and design patterns
  • Feature flags and experimental features
  • Configuration schemas and validation logic

Community Response

The security community and developers began analyzing the source to understand:
  • How Claude Code actually works under the hood
  • What tools and capabilities are available
  • How the agentic loop operates
  • Security implications and permission models
  • Integration points for extensions
This documentation is the result of that community analysis.

Tech Stack

Based on the source code analysis:
ComponentTechnology
LanguageTypeScript
RuntimeBun (JavaScript runtime)
CLI FrameworkCommander.js
Terminal UIReact + Ink
API ClientAnthropic SDK (@anthropic-ai/sdk)
Schema ValidationZod
State ManagementReact-based AppState store
PersistenceJSONL (JSON Lines) format
ProtocolModel Context Protocol (MCP)

Models Used

Claude Code uses different Claude models for different purposes:

Main Loop Models

  • Claude Opus 4.6 - Most capable, used for complex reasoning
  • Claude Sonnet 4.6 - Balanced performance and cost
  • Claude Haiku 4.5 - Fast, lightweight tasks

Specialized Models

  • Extended Thinking - Activated for complex problems requiring deep reasoning
  • Bedrock/Vertex AI - Enterprise deployments with custom routing
The model selection is configurable and can be overridden per-session or via environment variables.

How to Read These Docs

This documentation is organized into phases:
  1. Getting Started - High-level overview and architecture
  2. Core Concepts - Control flow, project structure, agent loop
  3. Tools & Commands - What Claude Code can do
  4. Models & State - How inference and memory work
  5. Configuration - Settings, permissions, environment variables
  6. Advanced Features - REPL mode, coordinator mode, plugins, skills
  7. Security - Permission system, vulnerabilities, safe usage
Each page includes:
  • Technical explanations based on source code
  • Code snippets illustrating patterns (max 15 lines)
  • Mermaid diagrams for complex flows
  • Related links to other relevant pages
When we say “implementation details unclear,” it means the source code didn’t provide enough context to make a definitive claim. We prioritize accuracy over completeness.
All source code, system prompts, and intellectual property belong to Anthropic PBC. This documentation:
  • Explains what the code does and how it works
  • Does not reproduce large verbatim code blocks
  • Uses short snippets (under 15 lines) to illustrate patterns
  • Paraphrases and explains rather than transcribes

Fair Use

This documentation is created under fair use principles for:
  • Educational purposes
  • Research and analysis
  • Commentary and criticism
  • Transformative use (explanation, not reproduction)

No Warranty

This documentation is provided “as is” without warranty of any kind. The authors make no guarantees about:
  • Accuracy of technical details
  • Completeness of coverage
  • Applicability to current versions
  • Security implications

Not Affiliated

This is an independent community project. It is not:
  • Created by Anthropic
  • Endorsed by Anthropic
  • Approved by Anthropic
  • Supported by Anthropic
For official documentation, always refer to docs.anthropic.com.

Architecture Overview

High-level system architecture and component relationships

Control Flow

Complete flow from user input to agent output

Project Structure

Directory structure and file organization

Official Docs

Anthropic’s official Claude documentation