resolver = "2", edition 2021, and version 1.0.0 across all member crates. Every crate lives under src-rust/crates/.
Dependency flow
cc-core is the shared foundation consumed by every other crate. claude-code (the binary) sits at the top and wires everything together.
Crates
cc-api — Claude API client and SSE streaming
cc-api — Claude API client and SSE streaming
Package:
Path:
Type: LibraryComplete async Messages API client with SSE streaming support. Corresponds to the TypeScript
cc-apiPath:
crates/apiType: LibraryComplete async Messages API client with SSE streaming support. Corresponds to the TypeScript
src/services/api/ layer.Key types
Retry and backoff
send_with_retry retries on HTTP 429 and 529 with exponential backoff: initial delay 1 s, 2× multiplier, capped at 60 s, max 5 attempts. Honors the Retry-After response header.Prompt caching
CacheControl::ephemeral() is automatically applied to system prompt blocks (when using SystemPrompt::Blocks) and to the last tool definition in the tools list.Key dependencies
reqwest, reqwest-eventsource, tokio, serde, serde_json, base64, cc-corecc-tools — all 33 tool implementations
cc-tools — all 33 tool implementations
Package:
Path:
Type: LibraryImplements all 33 built-in tools. Each tool is a zero-sized struct implementing the
cc-toolsPath:
crates/toolsType: LibraryImplements all 33 built-in tools. Each tool is a zero-sized struct implementing the
Tool trait. JSON schemas are generated with schemars.Core trait and registry
Implemented tools
Global singletons
Key dependencies
schemars, tokio, regex, walkdir, glob, reqwest, serde_json, dashmap, cc-core, cc-mcpcc-query — agentic query loop
cc-query — agentic query loop
Package:
Path:
Type: LibraryThe core agentic query loop. Drives the multi-turn conversation with the API, executes tools, manages context compaction, and runs the background cron scheduler.
The sub-agent tool (
cc-queryPath:
crates/queryType: LibraryThe core agentic query loop. Drives the multi-turn conversation with the API, executes tools, manages context compaction, and runs the background cron scheduler.
Key types
Key functions
AgentTool (agent_tool.rs)
The sub-agent tool (Task) lives in this crate rather than cc-tools because it must call run_query_loop recursively. It always excludes itself from the child tool list to prevent infinite recursion.Auto-compact constants
Key dependencies
tokio, tokio-util, cc-core, cc-api, cc-tools, cc-mcpcc-tui — terminal UI
cc-tui — terminal UI
cc-commands — slash command implementations
cc-commands — slash command implementations
cc-mcp — MCP client
cc-mcp — MCP client
cc-bridge — bridge to claude.ai
cc-bridge — bridge to claude.ai
Package:
Path:
Type: LibraryImplements the bridge protocol connecting the local CLI to the claude.ai web UI. Enables remote control from a browser session via long polling.
cc-bridgePath:
crates/bridgeType: LibraryImplements the bridge protocol connecting the local CLI to the claude.ai web UI. Enables remote control from a browser session via long polling.
Key types
Transport
The polling loop long-polls{server_url}/sessions/{id}/poll for incoming messages and flushes outgoing BridgeEvent items to {server_url}/sessions/{id}/events. Exponential backoff on network errors; disconnects on 401/403.Work modes
Supported work modes (from README):single-session, worktree, same-dir.Key dependencies
reqwest, tokio, serde, serde_json, base64, sha2, hex, cc-corecc-buddy — companion pet system
cc-buddy — companion pet system
Package:
Path:
Type: LibraryTamagotchi-style companion pet system. Provides species hatching, ASCII art sprites, procedurally generated stats, and a soul description generated by Claude on first hatch.
cc-buddyPath:
crates/buddyType: LibraryTamagotchi-style companion pet system. Provides species hatching, ASCII art sprites, procedurally generated stats, and a soul description generated by Claude on first hatch.
Key types
PRNG
Species and stats are determined by a Mulberry32 PRNG seeded from youruserId hash with the salt 'friend-2026-401'. The same user always gets the same buddy.Sprites
ASCII art sprites are 5 lines × 12 characters, with multiple animation frames for idle and reaction states.Key dependencies
cc-core, cc-api (for soul generation)cc-plugins — plugin system
cc-plugins — plugin system
Package:
Path:
Type: LibraryPlugin loader with a trust model and skill macros. Enables third-party extensions to register additional tools and commands.
cc-pluginsPath:
crates/pluginsType: LibraryPlugin loader with a trust model and skill macros. Enables third-party extensions to register additional tools and commands.
Key capabilities
- Plugin loader and lifecycle management
- Trust model for plugin verification
- Skill macros for defining plugin-provided skills
Key dependencies
cc-core, cc-toolsclaude-code — binary entry point
claude-code — binary entry point
Package:
Path:
Type: Binary (
claude-codePath:
crates/cliType: Binary (
[[bin]] name = "claude")Binary entry point. Produces the claude executable. Wires all crates together and starts either the interactive TUI REPL or headless (non-interactive) mode.CLI flags
Startup sequence
- Parse CLI args with
clap - Initialize
tracing_subscriber(verbose → DEBUG, default → WARN) - Load
Settingsfrom~/.claude/settings.json - Build
Configby layering settings → CLI overrides - Create
Arc<CostTracker> - Build system context (embedded
system_prompt.txt+ContextBuilder) - Create
AnthropicClientandToolContext - Connect MCP servers if
--mcp-configprovided - Build tool list:
cc_tools::all_tools()+AgentTool+McpToolWrapperfor each MCP tool - Start cron scheduler via
start_cron_scheduler() - Dispatch to
run_headless()(prompt provided) orrun_interactive()(TUI REPL)
Key dependencies
clap, tokio, tracing-subscriber, cc-core, cc-api, cc-tools, cc-query, cc-tui, cc-commands, cc-mcp, cc-bridgeWorkspace dependencies
Key shared dependencies declared in[workspace.dependencies]: