Claude Code Codebase - Deep Technical Understanding Guide
- Source ID:
src-20260419-f46b0a2fccd9 - Kind:
analysis - Scope:
private - Origin:
community-analysis - Raw path:
sources/raw/claude-code-codebase-deep-technical-understanding-guide__src-20260419-f46b0a2fccd9.md - Status:
active
Summary
Community analysis document covering Claude Code architecture, internals, and leak analysis. See extracted entities and claims below.
Tags
architecture internals
Extracted entities
ent-20260419-026ec2d354e8bashSecurity.ts Numbered Checks (concept): 23 sequentially numbered security validators inside bashSecurity.ts (~2,000 lineent-20260419-0416c1181febextractMemories.ts (file): ~600-line file implementing a fire-and-forget hidden Opus call per turn used toent-20260419-0847d810164dquery.ts 10-Step Loop (concept): Fully dissected per-iteration structure of the query.ts state-machine while-loopent-20260419-1a2d3f40f0cfStreaming Tool Execution Parallelism (concept): Design where tool invocations are executed as their definitions stream in from tent-20260419-1b335993887114 Cache-Breaking Vectors (concept): Enumerated list of 14 events that invalidate the prompt cache: CLAUDE.md mid-sesent-20260419-250777fe7786Harrison Security Deep Dive (Query Loop) (document): Harrison Security blog analysis dissecting the query.ts 1,421-line while-loop wient-20260419-267b85260b02Denial Tracking System (concept): 46-line subsystem that, when a user repeatedly denies actions, shifts the agentent-20260419-284b005a6bd9Session JSONL Log Format (dataset): Structured per-session log file containing tool-call durations, per-operation toent-20260419-3545bbd2eff9250,000 Wasted API Calls Bug (issue): Defect documented in an internal code comment describing ~250,000 wasted API calent-20260419-3c940f253835compaction/ Directory (file): ~4,000-line directory implementing the 5-layer context compression pipeline.ent-20260419-46db6f59a6d8Module Size Map (concept): Reference distribution of Claude Code module sizes used to navigate the codebaseent-20260419-522c1fccbf67main.tsx Entry Point (file): CLI entry point of Claude Code, ~20,000 lines / 785KB bundle; hosts the 3,167-lient-20260419-53d061ec7c78Memory as Hint, Not Truth (concept): Architectural stance that the agent's stored beliefs are hints to be verified agent-20260419-5baa864a2734Velocity-Pressure Code Pattern (concept): Anti-pattern diagnosis: features added to the safest-feeling existing location rent-20260419-5e6a96d8cc9bDeferred Tool Loading Convergence (concept): Pattern of loading tool definitions in batches as context requires them rather tent-20260419-69c4acf29c0815 Reverse-Engineered Design Intents (concept): Ji_ai's catalog of 15 encoded design decisions extracted from the leaked TypeScrent-20260419-6bd0f130227cReactive Compact Circuit Breaker (concept): Safety mechanism in the query-loop state that gives up after 3 attempts to recovent-20260419-73e6e77a5f70Code Authorship Anomaly (concept): Finding from static code authorship analysis that the leaked Claude Code codebasent-20260419-77cbb6b979b13,167-Line God Function Metrics (concept): Quantified signature of the single largest function in Claude Code: 3,167 lines,ent-20260419-7e876aebce6fStrict Write Discipline (concept): Invariant that the agent only updates its memory index after a confirmed successent-20260419-8fbb653f4f83kairos/ Directory (file): ~8,000-line directory containing the KAIROS daemon implementation with its 4-phaent-20260419-935506c2d7acConditional-Statement Fingerprint (concept): Stylistically unique pattern of if/else/ternary structures produced by Claude Coent-20260419-95541d9e4103commands.ts (Slash Command Implementations) (file): File (~25,000 lines) holding 100+ slash-command implementations.ent-20260419-9bca6bf795bfFingerprinting AI Coding Agents (MSR '26 Paper) (document): Peer-reviewed paper (MSR '26, January 2026) that analyzed 33,580 PRs across fiveent-20260419-a18dd883ee7c/insights Command (concept): Pre-leak slash command that reads all session JSONL logs and generates a frictioent-20260419-a42fd6fb7d05TechTrenches God-Function Analysis (document): TechTrenches article that named the single 3,167-line / 486-branch-point functioent-20260419-a76eebe71f47Async Generator Query Architecture (concept): QueryEngine.submitMessage() returns an AsyncGeneratorrather than a ent-20260419-a8b4b5213c3bCached vs Non-Cached Billing Multiple (concept): At 200K-context Opus rates, the difference between cached and non-cached billingent-20260419-b64d78e2cd15Codified Behavior Over Model Self-Discipline (concept): Design principle that behaviors such as 'don't refactor, rename, or reorganize bent-20260419-bcbc0edfd509Ji_ai 15 Design Intents Analysis (document): Ji_ai dev.to article reverse-engineering 15 design intents from ~80K lines of th- ... and 14 more
Extracted claims
clm-20260419-037504d29835[observation]: Design intents are most effectively discovered via /insightsclm-20260419-081f996bdfd2[decision]: query.ts is a 10-step state machine, not recursionclm-20260419-0851f529de85[pattern]: Deferred tool loading is converging across agent frameworksclm-20260419-2ef4f0e7dc2b[fact]: 14 vectors break the prompt cacheclm-20260419-2f4ce3d699bc[anti-pattern]: 250,000 wasted API calls were documented but shipped anywayclm-20260419-30688600d859[fact]: /insights reads JSONL logs to produce workflow friction reportsclm-20260419-3509efd69456[decision]: submitMessage returns AsyncGenerator, not Promiseclm-20260419-41c46dbfedc4[fact]: Leaked Claude Code occupies its own authorship tierclm-20260419-51aa6c05d850[observation]: bashSecurity.ts numbering suggests incident-driven check accretionclm-20260419-5f03621d0ace[anti-pattern]: Velocity-pressure pattern is diagnostic, not unusualclm-20260419-60161a02c2c5[constraint]: Memory index only updates after a confirmed successful writeclm-20260419-60e215fb40dd[decision]: Cache-break latch is intentionally sticky for the sessionclm-20260419-6190c3aa137d[observation]: query.ts is the recommended practical entry pointclm-20260419-63f5d68049a3[metric]: Streaming tool execution cuts wall time by about 40%clm-20260419-7818a10df16f[pattern]: Denial tracking is a 46-line graceful-degradation subsystemclm-20260419-7840c2e5a971[metric]: Claude Code module-size distribution concentrates complexity in QueryEngineclm-20260419-a93940c70218[fact]: Session JSONL logs carry structured per-operation metricsclm-20260419-aaa7342d9931[metric]: prompts.ts contains 141 system-prompt assembly modulesclm-20260419-ae9a9732224b[decision]: Minimal-impact behavior is codified in the system promptclm-20260419-aeb5e3f2f7b8[metric]: A single 3,167-line function has 486 branch points and 12 nesting levelsclm-20260419-b9b061b980d2[decision]: Agent treats its own memory as hint, not truthclm-20260419-baa89a05ec07[metric]: KAIROS daemon occupies ~8,000 lines with 4-phase dream loopclm-20260419-baae6fb64527[fact]: extractMemories.ts makes a fire-and-forget Opus call per turnclm-20260419-c0331cdbc911[metric]: Fingerprinting paper reaches 97.2% F1 on agent identificationclm-20260419-c2d9b9a0940f[metric]: Cached vs non-cached billing differs by ~5x at 200K Opusclm-20260419-d27e828089e9[hypothesis]: Leaked CC style is consistent with execution-feedback trainingclm-20260419-dbace1b4bdc4[observation]: Undercover Mode does not defeat the structural fingerprintclm-20260419-dc35f9649f6a[pattern]: /insights enables a compounding workflow-improvement loopclm-20260419-dd70f0d9885d[constraint]: Reactive compact tries up to 3 times before giving upclm-20260419-e3f55c90074d[metric]: commands.ts holds 100+ slash commands in 25,000 lines- ... and 4 more
Extracted relations
rel-20260419-00000000a001: Conditional-Statement Fingerprint --[contradicts]--> Undercover Moderel-20260419-00000000a002: query.ts 10-Step Loop --[implements]--> query.tsrel-20260419-00000000a003: Nine Continue Points --[contains]--> query.ts 10-Step Looprel-20260419-00000000a004: Reactive Compact Circuit Breaker --[implements]--> query.ts 10-Step Looprel-20260419-00000000a005: Streaming Tool Execution Parallelism --[implements]--> StreamingToolExecutorrel-20260419-00000000a006: Async Generator Query Architecture --[implements]--> QueryEngine.tsrel-20260419-00000000a007: 3,167-Line God Function Metrics --[related_to]--> tt() Functionrel-20260419-00000000a008: God Function Responsibilities --[contains]--> tt() Functionrel-20260419-00000000a009: 250,000 Wasted API Calls Bug --[caused]--> Velocity-Pressure Code Patternrel-20260419-00000000a010: 14 Cache-Breaking Vectors --[contains]--> Prompt Cache Section Registryrel-20260419-00000000a011: Prompt Cache Section Registry --[supports]--> Cache Economicsrel-20260419-00000000a012: Cache Sticky Latch --[depends_on]--> Prompt Cache Section Registryrel-20260419-00000000a013: Compounding /insights Loop --[depends_on]--> /insights Commandrel-20260419-00000000a014: /insights Command --[uses]--> Session JSONL Log Formatrel-20260419-00000000a015: Module Size Map --[contains]--> QueryEngine.tsrel-20260419-00000000a016: Module Size Map --[contains]--> Tool.ts (Built-in Tool Registry)rel-20260419-00000000a017: main.tsx Entry Point --[contains]--> tt() Functionrel-20260419-00000000a018: bashSecurity.ts Numbered Checks --[implements]--> Bash Security Pipelinerel-20260419-00000000a019: Denial Tracking System --[depends_on]--> Permission Pipelinerel-20260419-00000000a020: Deferred Tool Loading Convergence --[related_to]--> ToolSearch Systemrel-20260419-00000000a021: prompts.ts (141-Module Assembly) --[implements]--> System Prompt Assemblyrel-20260419-00000000a022: extractMemories.ts --[implements]--> Auto-Memoryrel-20260419-00000000a023: kairos/ Directory --[implements]--> KAIROSrel-20260419-00000000a024: compaction/ Directory --[implements]--> Compaction Pipelinerel-20260419-00000000a025: buddy/ Directory --[implements]--> Buddy Sprite- ... and 9 more