This appendix lists the key files in the Claude Code v2.1.88 source code and their responsibilities, grouped by subsystem. File paths are relative to restored-src/src/.
File Responsibility Related Chapters
main.tsxCLI entry point, parallel prefetch, lazy import, Feature Flag gating Chapter 1
query.tsAgent Loop main loop, queryLoop state machine Chapter 3
query/transitions.tsLoop transition types: Continue, Terminal Chapter 3
File Responsibility Related Chapters
Tool.tsTool interface contract, TOOL_DEFAULTS fail-closed defaults Chapters 2, 25
tools.tsTool registration, Feature Flag conditional loading Chapter 2
services/tools/toolOrchestration.tsTool execution orchestration, partitionToolCalls concurrency partitioning Chapter 4
services/tools/toolExecution.tsSingle-tool execution lifecycle Chapter 4
services/tools/StreamingToolExecutor.tsStreaming tool executor Chapter 4
tools/BashTool/Bash tool implementation, including Git safety protocol Chapters 8, 27
tools/FileEditTool/File edit tool, "read before edit" enforcement Chapters 8, 27
tools/FileReadTool/File read tool, default 2000 lines Chapter 8
tools/GrepTool/ripgrep-based search tool Chapter 8
tools/AgentTool/Sub-Agent spawning tool Chapters 8, 20
tools/SkillTool/Skill invocation tool Chapters 8, 22
tools/SkillTool/prompt.tsSkill list budget: 1% of context window Chapters 12, 26
File Responsibility Related Chapters
constants/prompts.tsSystem prompt construction, SYSTEM_PROMPT_DYNAMIC_BOUNDARY Chapters 5, 6, 25
constants/systemPromptSections.tsSection registry with cache control scope Chapter 5
constants/toolLimits.tsTool result budget constants Chapters 12, 26
File Responsibility Related Chapters
services/api/claude.tsAPI call construction, cache breakpoint placement Chapter 13
services/api/promptCacheBreakDetection.tsCache break detection, PreviousState tracking Chapters 14, 25
utils/api.tssplitSysPromptPrefix() three-way cache splittingChapters 5, 13
File Responsibility Related Chapters
services/compact/compact.tsCompaction orchestration, POST_COMPACT_MAX_FILES_TO_RESTORE Chapters 9, 10
services/compact/autoCompact.tsAuto-compaction threshold and circuit breaker Chapters 9, 25, 26
services/compact/prompt.tsCompaction prompt template Chapters 9, 28
services/compact/microCompact.tsTime-based micro-compaction Chapter 11
services/compact/apiMicrocompact.tsAPI-native cached micro-compaction Chapter 11
File Responsibility Related Chapters
utils/permissions/yoloClassifier.tsYOLO auto-mode classifier Chapter 17
utils/permissions/denialTracking.tsDenial tracking, DENIAL_LIMITS Chapters 17, 27
tools/BashTool/bashPermissions.tsBash command permission checks Chapter 16
File Responsibility Related Chapters
utils/claudemd.tsCLAUDE.md loading and injection, 4-layer priority Chapter 19
skills/bundled/Built-in skills directory Chapter 22
skills/loadSkillsDir.tsUser-defined skill discovery Chapter 22
skills/mcpSkillBuilders.tsMCP-to-skill bridge Chapter 22
File Responsibility Related Chapters
coordinator/coordinatorMode.tsCoordinator mode implementation Chapter 20
utils/teammate.tsTeammate Agent tools Chapter 20
utils/swarm/teammatePromptAddendum.tsTeammate prompt addendum content Chapter 20
File Responsibility Related Chapters
utils/toolResultStorage.tsLarge result persistence, truncation previews Chapters 12, 28
utils/toolSchemaCache.tsTool Schema caching Chapter 15
File Responsibility Related Chapters
memdir/memdir.tsMEMORY.md index and topic file loading, system prompt injection Chapter 24
memdir/paths.tsMemory directory path resolution, three-level priority chain Chapter 24
services/extractMemories/extractMemories.tsFork agent automatic memory extraction Chapter 24
services/SessionMemory/sessionMemory.tsRolling session summary for compaction Chapter 24
utils/sessionStorage.tsJSONL session record storage and recovery Chapter 24
tools/AgentTool/agentMemory.tsSub-Agent persistence and VCS snapshots Chapter 24
services/autoDream/autoDream.tsOvernight memory consolidation and pruning Chapter 24
File Responsibility Related Chapters
services/analytics/index.tsEvent entry point, queue-attach pattern, PII tag types Chapter 29
services/analytics/sink.tsDual-path dispatch (Datadog + 1P), sampling Chapter 29
services/analytics/firstPartyEventLogger.tsOTel BatchLogRecordProcessor integration Chapter 29
services/analytics/firstPartyEventLoggingExporter.tsCustom Exporter, disk-persistent retry Chapter 29
services/analytics/metadata.tsEvent metadata, tool name sanitization, PII grading Chapter 29
services/analytics/datadog.tsDatadog allow-list, batch flushing Chapter 29
services/analytics/sinkKillswitch.tsRemote circuit breaker (tengu_frond_boric) Chapter 29
services/api/logging.tsAPI three-event model (query/success/error) Chapter 29
services/api/withRetry.tsRetry telemetry, gateway fingerprint detection Chapter 29
utils/debug.tsDebug logging, --debug flag Chapter 29
utils/diagLogs.tsPII-free container diagnostics Chapter 29
utils/errorLogSink.tsError file logging Chapter 29
utils/telemetry/sessionTracing.tsOTel spans, three-level tracing Chapter 29
utils/telemetry/perfettoTracing.tsPerfetto visualization tracing Chapter 29
utils/gracefulShutdown.tsCascading timeout graceful shutdown Chapter 29
cost-tracker.tsCost tracking, cross-session persistence Chapter 29
File Responsibility Related Chapters
utils/effort.tsEffort level parsing Chapter 21
utils/fastMode.tsFast Mode management Chapter 21
utils/managedEnvConstants.tsManaged environment variable allowlist Appendix B
screens/REPL.tsxMain interactive interface (5000+ line React component) Chapter 1