中文说明 | Architecture (EN) | 架构说明(中文)
This repository is a source-level snapshot of Claude Code, Anthropic's official CLI for Claude.
It appears to contain the core src/ tree only, without the usual top-level project metadata such as package.json, lockfiles, build scripts, or a published release layout. In other words, this repository is best treated as a code-reading and architecture-reference snapshot rather than a complete, ready-to-build distribution.
Claude Code is a tool-driven coding assistant centered around:
- an interactive CLI experience
- a large built-in command surface
- a runtime that exposes file, shell, web, task, and agent tools
- support for local and remote execution flows
- an MCP server entrypoint for tool interoperability
From the source, the default command is claude, and the main interactive flow starts in src/main.tsx.
The repository currently contains:
src/main.tsx: the main CLI bootstrap and command registration entrypointsrc/commands.ts: the aggregated built-in command registrysrc/tools.ts: the aggregated tool registry used by the assistant runtimesrc/tasks.ts: task-type registration for local, remote, and agent-backed worksrc/entrypoints/mcp.ts: the MCP server entrypoint that exposes Claude Code tools over stdio- a large collection of UI, service, bridge, tool, and workflow modules under
src/
The codebase shows that Claude Code is not just a thin command wrapper. It includes a full application runtime with:
- CLI and terminal UI layers
- command dispatch and slash-command style features
- tool permission and execution plumbing
- agent and task orchestration
- remote session and bridge support
- MCP integration
- settings, telemetry, auth, and policy controls
The CLI bootstraps through src/main.tsx and related entrypoints under src/entrypoints/.
Key responsibilities include:
- parsing CLI arguments
- fast-path handling for selected commands and flags
- initializing auth, config, telemetry, and policy state
- launching the interactive session
- wiring subcommands such as MCP, remote, daemon, and session flows
Built-in commands are aggregated in src/commands.ts.
The command set is broad and includes areas such as:
- session management
- review and diff workflows
- login and auth flows
- onboarding and help
- MCP management
- configuration and permissions
- remote environment and teleport features
- reporting, stats, and insights
This makes the command layer a useful place to start if you want to understand user-facing capabilities.
Tools are aggregated in src/tools.ts and represent the operational abilities available to the assistant runtime.
Examples visible in this snapshot include:
- shell execution
- file read, write, and edit operations
- notebook editing
- web fetch and web search
- task lifecycle control
- agent and skill tools
- todo and planning support
- MCP-related integrations
The tool system is a central abstraction in the architecture. It defines what the assistant can do in response to a request and how those operations are validated, permission-checked, and executed.
Task registration lives in src/tasks.ts, with implementations under src/tasks/.
The snapshot includes task types for:
- local shell work
- local agent execution
- remote agent execution
- other feature-gated workflow types
This suggests that Claude Code supports both direct tool use and longer-running delegated task execution patterns.
A substantial part of the repository is dedicated to remote-session and bridge-related infrastructure, especially under src/bridge/.
These modules indicate support for:
- remote session URLs and session compatibility handling
- bridge communication and transport
- remote execution and session management
- trusted-device and connectivity workflows
The file src/entrypoints/mcp.ts exposes Claude Code capabilities through the Model Context Protocol (MCP), allowing external clients to discover and invoke tools over a stdio transport.
This is an important integration point if you are studying Claude Code as both:
- a standalone coding CLI
- a tool provider in a broader MCP ecosystem
The source tree is large, but these directories are good starting points:
src/commands/: user-facing commandssrc/tools/: tool implementationssrc/tasks/: task implementationssrc/components/: terminal UI componentssrc/bridge/: remote bridge and session plumbingsrc/services/: API, MCP, policy, and supporting servicessrc/utils/: shared helpers and infrastructuresrc/entrypoints/: startup entrypoints for CLI and MCP modessrc/constants/: product, prompt, and feature constants
If you are exploring the code for understanding or secondary development, a practical reading order is:
src/main.tsxsrc/commands.tssrc/tools.tssrc/tasks.tssrc/entrypoints/mcp.ts- feature-specific directories such as
src/bridge/,src/services/, andsrc/components/
This path gives a fast overview of how the CLI starts, what commands exist, what tools can be called, how work is modeled, and how the system is exposed externally.
This snapshot does not currently include:
package.json- dependency lockfiles
- top-level build scripts
- test commands
- a visible license file
Because of that, it should not be assumed that the repository can be installed or run as-is in its current form.
If you later add the missing project metadata, this README can be expanded with:
- installation instructions
- development commands
- test commands
- packaging or release steps
This README is meant to help English-speaking readers quickly understand what this repository contains and where to begin.
For deeper technical reading, see:
ARCHITECTURE.mdfor the English architecture guideARCHITECTURE.zh-CN.mdfor the Chinese architecture guide
If you want, the next useful step would be to add one of these:
- a contributor guide for navigating the source tree
- file-by-file notes for the most important subsystems
- a subsystem guide for bridge, tools, or plugins