Skip to content

Archie818/Claude-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Source Snapshot

中文说明 | 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.

Overview

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.

What Is In This Snapshot

The repository currently contains:

  • src/main.tsx: the main CLI bootstrap and command registration entrypoint
  • src/commands.ts: the aggregated built-in command registry
  • src/tools.ts: the aggregated tool registry used by the assistant runtime
  • src/tasks.ts: task-type registration for local, remote, and agent-backed work
  • src/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

High-Level Architecture

1. CLI and Application Bootstrap

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

2. Commands

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.

3. Tools

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.

4. Tasks and Agents

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.

5. Remote and Bridge Features

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

6. MCP Integration

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

Repository Layout

The source tree is large, but these directories are good starting points:

  • src/commands/: user-facing commands
  • src/tools/: tool implementations
  • src/tasks/: task implementations
  • src/components/: terminal UI components
  • src/bridge/: remote bridge and session plumbing
  • src/services/: API, MCP, policy, and supporting services
  • src/utils/: shared helpers and infrastructure
  • src/entrypoints/: startup entrypoints for CLI and MCP modes
  • src/constants/: product, prompt, and feature constants

How To Read This Codebase

If you are exploring the code for understanding or secondary development, a practical reading order is:

  1. src/main.tsx
  2. src/commands.ts
  3. src/tools.ts
  4. src/tasks.ts
  5. src/entrypoints/mcp.ts
  6. feature-specific directories such as src/bridge/, src/services/, and src/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.

Notes About Buildability

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

Intended Use Of This README

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.md for the English architecture guide
  • ARCHITECTURE.zh-CN.md for 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

About

Claude Code — Leaked Source (2026-03-31)

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors