Skip to main content
Claude Code is an AI coding assistant CLI built by Anthropic. It wraps the Claude API in a production-grade agent harness that can read, edit, and execute code across your local filesystem, all from the terminal. This documentation is based on the decompiled TypeScript source extracted from the published npm package @anthropic-ai/claude-code version 2.1.88. The source is provided strictly for technical research and educational purposes.
All source code in this repository is the intellectual property of Anthropic and Claude. Commercial use is strictly prohibited. This repository exists for research, study, and educational exchange only. If any content infringes your rights, contact the repository owner for immediate removal.

What Claude Code is

Claude Code is a terminal-native AI agent. You give it a prompt — or open an interactive session — and it uses a built-in tool system to read files, run shell commands, search codebases, call external APIs, and write changes back to disk. Everything runs locally, coordinated by the agent loop in query.ts. The compiled CLI ships as a single 12 MB cli.js bundle requiring only Node.js >= 18. The src/ directory in this repository contains the unbundled TypeScript source extracted from the npm tarball.

Repository stats

ItemCount
Source files (.ts / .tsx)~1,884
Lines of code~512,664
Largest single filequery.ts (~785 KB)
Built-in tools40+
Slash commands80+
npm dependencies~192 packages
RuntimeNode.js >= 18 (compiled Bun bundle)

Major capabilities

Agent loop

A while-loop that calls the Claude API, checks stop_reason, executes tools, appends results, and repeats — wrapped with streaming, compaction, and permission checks.

40+ built-in tools

File read/write/edit, glob, grep, bash execution, web fetch, web search, MCP protocol, sub-agent spawning, todo management, and more.

80+ slash commands

In-session commands for authentication, memory, configuration, MCP servers, context compaction, plan mode, session resumption, and code review.

Multi-agent system

Spawn sub-agents as child processes or in-process teammates. Coordinate work via a shared task board and message inbox.

MCP integration

Connect to external MCP servers over stdio, SSE, HTTP, or WebSocket. Tools are registered dynamically under the mcp__<server>__<tool> naming convention.

Session persistence

Every conversation is appended to a JSONL transcript under ~/.claude/projects/. Resume any session with --continue or --resume <id>.

Permission model

Three-layer authorization: pre-tool hooks → allow/deny rules → interactive prompt. Each tool reports whether it is read-only, destructive, or concurrency-safe.

Context management

Three compression strategies — autoCompact, snipCompact, and contextCollapse — keep long sessions within the model’s context window.

Repository purpose

This repository contains the decompiled TypeScript source of @anthropic-ai/claude-code v2.1.88, published to npm as a 12 MB bundled cli.js. The src/ directory was extracted from the npm tarball for research purposes. The source is not directly compilable from this repository alone. 108 feature-gated internal modules were dead-code-eliminated by Bun at Anthropic’s build time and are not recoverable from any published artifact. See Installation for what is and isn’t possible when building from source. The repository also includes deep analysis reports covering telemetry, hidden features, undercover mode, remote control mechanisms, and the future roadmap derived from reading the source.

Build docs developers (and LLMs) love