CC

Claude Code Analysis

Deep dive into the internals of @anthropic-ai/claude-code v2.1.88

Source extracted from cli.js.map of the npm package. TypeScript, Ink-based terminal UI, codename Tengu.

Lines of Code
512K
3x Linux 1.0 kernel
Source Files
1,884
.ts and .tsx files
Slash Commands
101
From /compact to /stickers
Built-in Tools
43
Bash, Edit, Agent, MCP...

Core Execution Loop

User InputPrompt + attachments
API StreamText + tool_use blocks
Tool ExecutionRead=parallel, Write=serial
Permission Check5-layer security gate
Loop until no more tool calls or exit condition

Explore

Streaming Tool Execution

Tools start executing while the model is still generating. StreamingToolExecutor queues tool_use blocks as they arrive.

Zero-Cost Cache Sharing

CacheSafeParams frozen at fork time. Identical system prompt bytes = automatic prompt cache hit for subagents.

Multi-Level Compaction

4 strategies (micro, auto, snip, collapse) keep conversations within token limits. Unlimited session length.