Home › Entities ›
Claude Code
Claude Code
- Entity ID:
ent-20260409-381bd95a1693
- Type:
product
- Scope:
shared
- Status:
active
- Aliases: CC, claude-code CLI
Description
Claude Code is Anthropic's agentic CLI coding tool -- a terminal-based AI assistant that can read, write, and execute code autonomously. Built as a 512,000+ line TypeScript application spanning 4,600+ files, it runs on the Bun runtime and renders its interface through a React+Ink terminal UI. The leaked codebase (via an exposed source map) revealed an architecture far more complex than the ~279 files in the official open-source repository, exposing internal subsystems for security, telemetry, payments, and multi-agent orchestration.
Architecture Overview
Claude Code is organized around the five-layer-architecture, with the queryengine-ts monolith (~46K lines) serving as the gravitational center. The core agent loop is orchestrated by the tt-function (3,167 lines, 486 cyclomatic complexity), which drives streaming API communication, tool execution, and session management.
Core Engine
| Component |
Description |
| queryengine-ts |
46K-line monolith handling LLM streaming, tool dispatch, transcript recording, and session state |
| tt-function |
3,167-line "god function" orchestrating the agent run loop with 486 cyclomatic complexity |
| streaming-tool-executor |
Executes tool calls as streaming tokens arrive, enabling parallel tool execution |
| message-normalization |
11 transformations (smooshing, Capybara surgery, etc.) applied before every API call |
| system-prompt-assembly |
Dynamic construction of the system prompt from modular components |
| system-reminders |
Mid-conversation context injections that keep the model aligned with current state |
Security and Permissions
Context and Memory
| Component |
Description |
| memory-hierarchy |
Multi-level memory (session, project, user, enterprise) with LLM-based retrieval |
| compaction-pipeline |
Context window management when approaching token limits |
| cache-economics |
Prompt cache optimization for cost reduction |
| session-persistence |
Checkpoint-based session save/resume across CLI restarts |
| auto-memory |
Automatic extraction and storage of project context |
| auto-dream |
Background context synthesis during idle periods |
Agent and Multi-Agent Patterns
| Component |
Description |
| forked-agent-pattern |
Parallel subagent spawning with 92% prompt cache reuse |
| teammate-tool |
Multi-agent collaboration with team-lead coordination |
| ultraplan |
Complex task decomposition and planning system |
| speculation-engine |
Predictive file prefetching to reduce latency |
| kairos |
Session-level timing and scheduling intelligence |
| Component |
Description |
| terminal-renderer |
Custom React reconciler with Yoga WASM flexbox and 16ms frame budget |
| bridge-system |
IDE integration layer for VS Code and JetBrains |
| hooks-system |
21 lifecycle events for user-defined feedback loops |
| plugin-system |
Marketplace runtime with dependency resolution and cycle detection |
| skill-system |
Reusable markdown-defined workflows invoked via slash commands |
| toolsearch-system |
Lazy tool loading (77K to 8.7K tokens) with BM25 matching |
| vim-mode |
Full Vim state machine for terminal input editing |
| cc-protocol |
Deep link remote session control from phone/browser |
Telemetry and Feature Management
Search and Retrieval
| Component |
Description |
| grep-over-rag |
Agentic grep chosen over RAG after testing both approaches |
Design Principles
Eight architectural design principles govern Claude Code's development:
- Agentic grep over RAG -- Use the model's reasoning to search codebases rather than vector databases
- Fail-open safety -- When safety systems error, fall back to human prompts rather than blocking
- Cache-first economics -- Optimize aggressively for prompt cache hits to reduce API costs
- Streaming-native -- Process tokens as they arrive rather than waiting for complete responses
- Permission at the boundary -- Enforce safety at tool execution boundaries, not in the model
- Memory without vectors -- Use LLM reasoning over filenames for memory retrieval
- Fork for parallelism -- Spawn subagents for concurrent work rather than sequential processing
- Extensibility via markdown -- Define skills, hooks, and configuration in human-readable formats
Ecosystem
The Claude Code ecosystem extends beyond Anthropic's official product:
- claw-code -- Clean-room Python/Rust rewrite by Sigrid Jin with 49K+ GitHub stars
- piebald -- Community tool tracking system prompts across 141 versions
- ccunpacked-dev -- Visual architecture reference mapping 108 feature flags
- claude-mythos-preview -- Unreleased frontier model with 93.9% SWE-bench score
- x42-protocol -- Unshipped autonomous USDC payment system
- operon-desktop-mode -- Unreleased science research workspaces
Key claims
clm-20260409-285074076579: Claude Code abandoned RAG for agentic grep after testing both
clm-20260409-4740377e3ccd: 150K compaction threshold bug
clm-20260409-47638929f7c2: Claude Code commits leak secrets at 3.2% rate (2x baseline)
clm-20260409-526d16839a31: Safety mechanism and attack surface are the same thing
clm-20260409-55bcc37ee526: CVE: 50-subcommand cap causes deny-to-ask downgrade
clm-20260409-66e733cfe69f: 29-30% false-claims rate acknowledged in internal comments
clm-20260409-705de7e82bf7: Compaction laundering attack vector
clm-20260409-70c4b9b1b41c: Eight architectural design principles govern Claude Code
clm-20260409-77a12ba7f99b: Forked agents achieve 92% prompt cache reuse
clm-20260409-86ce9df0fb73: Memory retrieval uses LLM reasoning over filenames, not vector search
- ... and 4 more
Relations
rel-20260409-00c821e10770: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-680ad4a76a20
rel-20260409-25a350a4934d: ent-20260409-381bd95a1693 --[implements]--> ent-20260409-cdc9261a044e
rel-20260409-4350ef75122c: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-48c7dd87870f
rel-20260409-47450817314a: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-13c5791ba3aa
rel-20260409-557147002bda: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-f9c3441c13e8
rel-20260409-68e6fed3da38: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-8aeee7e5553e
rel-20260409-8b65e60dd2f0: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-560fd7fc9833
rel-20260409-96bacc53ba19: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-d04d8d64ce66
rel-20260409-9bcea1664252: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-cdc5e105d192
rel-20260409-b352d33f91da: ent-20260409-381bd95a1693 --[contains]--> ent-20260409-c9a0bfcecb27
- ... and 4 more
Sources
src-20260409-6913a0b93c8b