Skip to main content
The Claurst workspace is a Cargo workspace with 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

Package: cc-core
Path: crates/core
Type: Library
Central shared crate. Defines all types consumed by every other crate. Contains 9 inline submodules.

Key types

Selected constants (cc-core::constants)

Key dependencies

thiserror, serde, serde_json, tokio, chrono, once_cell, glob, walkdir, uuid
Package: cc-api
Path: crates/api
Type: Library
Complete 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-core
Package: cc-tools
Path: crates/tools
Type: Library
Implements 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-mcp
Package: cc-query
Path: crates/query
Type: Library
The 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-mcp
Package: cc-tui
Path: crates/tui
Type: Library
Terminal UI built on ratatui + crossterm. Replaces the TypeScript ink/React rendering layer with immediate-mode rendering.

Key types

Key functions

Rendering colors

Key dependencies

ratatui, crossterm, syntect, unicode-width, cc-core, cc-query
Package: cc-commands
Path: crates/commands
Type: Library
Slash command implementations for the interactive REPL. Corresponds to the TypeScript src/commands/ directory.

Core types

Registry functions

Implemented commands

Key dependencies

async-trait, tokio, cc-core, cc-query
Package: cc-mcp
Path: crates/mcp
Type: Library
Full MCP (Model Context Protocol) client over JSON-RPC 2.0 + stdio subprocess transport. Implements protocol version 2024-11-05.

Key types

McpManager operations

Key dependencies

tokio, serde, serde_json, cc-core
Package: cc-bridge
Path: crates/bridge
Type: Library
Implements 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-core
Package: cc-buddy
Path: crates/buddy
Type: Library
cc-buddy is compiled only when the BUDDY feature flag is enabled. It is absent from standard external builds.
Tamagotchi-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 your userId 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)
Package: cc-plugins
Path: crates/plugins
Type: Library
Plugin 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-tools
Package: claude-code
Path: crates/cli
Type: 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

  1. Parse CLI args with clap
  2. Initialize tracing_subscriber (verbose → DEBUG, default → WARN)
  3. Load Settings from ~/.claude/settings.json
  4. Build Config by layering settings → CLI overrides
  5. Create Arc<CostTracker>
  6. Build system context (embedded system_prompt.txt + ContextBuilder)
  7. Create AnthropicClient and ToolContext
  8. Connect MCP servers if --mcp-config provided
  9. Build tool list: cc_tools::all_tools() + AgentTool + McpToolWrapper for each MCP tool
  10. Start cron scheduler via start_cron_scheduler()
  11. Dispatch to run_headless() (prompt provided) or run_interactive() (TUI REPL)

Key dependencies

clap, tokio, tracing-subscriber, cc-core, cc-api, cc-tools, cc-query, cc-tui, cc-commands, cc-mcp, cc-bridge

Workspace dependencies

Key shared dependencies declared in [workspace.dependencies]: