Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Appendix A: Key File Index

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/.

Entry Points and Core Loop

FileResponsibilityRelated Chapters
main.tsxCLI entry point, parallel prefetch, lazy import, Feature Flag gatingChapter 1
query.tsAgent Loop main loop, queryLoop state machineChapter 3
query/transitions.tsLoop transition types: Continue, TerminalChapter 3

Tool System

FileResponsibilityRelated Chapters
Tool.tsTool interface contract, TOOL_DEFAULTS fail-closed defaultsChapters 2, 25
tools.tsTool registration, Feature Flag conditional loadingChapter 2
services/tools/toolOrchestration.tsTool execution orchestration, partitionToolCalls concurrency partitioningChapter 4
services/tools/toolExecution.tsSingle-tool execution lifecycleChapter 4
services/tools/StreamingToolExecutor.tsStreaming tool executorChapter 4
tools/BashTool/Bash tool implementation, including Git safety protocolChapters 8, 27
tools/FileEditTool/File edit tool, "read before edit" enforcementChapters 8, 27
tools/FileReadTool/File read tool, default 2000 linesChapter 8
tools/GrepTool/ripgrep-based search toolChapter 8
tools/AgentTool/Sub-Agent spawning toolChapters 8, 20
tools/SkillTool/Skill invocation toolChapters 8, 22
tools/SkillTool/prompt.tsSkill list budget: 1% of context windowChapters 12, 26

System Prompts

FileResponsibilityRelated Chapters
constants/prompts.tsSystem prompt construction, SYSTEM_PROMPT_DYNAMIC_BOUNDARYChapters 5, 6, 25
constants/systemPromptSections.tsSection registry with cache control scopeChapter 5
constants/toolLimits.tsTool result budget constantsChapters 12, 26

API and Caching

FileResponsibilityRelated Chapters
services/api/claude.tsAPI call construction, cache breakpoint placementChapter 13
services/api/promptCacheBreakDetection.tsCache break detection, PreviousState trackingChapters 14, 25
utils/api.tssplitSysPromptPrefix() three-way cache splittingChapters 5, 13

Context Compaction

FileResponsibilityRelated Chapters
services/compact/compact.tsCompaction orchestration, POST_COMPACT_MAX_FILES_TO_RESTOREChapters 9, 10
services/compact/autoCompact.tsAuto-compaction threshold and circuit breakerChapters 9, 25, 26
services/compact/prompt.tsCompaction prompt templateChapters 9, 28
services/compact/microCompact.tsTime-based micro-compactionChapter 11
services/compact/apiMicrocompact.tsAPI-native cached micro-compactionChapter 11

Permissions and Security

FileResponsibilityRelated Chapters
utils/permissions/yoloClassifier.tsYOLO auto-mode classifierChapter 17
utils/permissions/denialTracking.tsDenial tracking, DENIAL_LIMITSChapters 17, 27
tools/BashTool/bashPermissions.tsBash command permission checksChapter 16

CLAUDE.md and Skills

FileResponsibilityRelated Chapters
utils/claudemd.tsCLAUDE.md loading and injection, 4-layer priorityChapter 19
skills/bundled/Built-in skills directoryChapter 22
skills/loadSkillsDir.tsUser-defined skill discoveryChapter 22
skills/mcpSkillBuilders.tsMCP-to-skill bridgeChapter 22

Multi-Agent Orchestration

FileResponsibilityRelated Chapters
coordinator/coordinatorMode.tsCoordinator mode implementationChapter 20
utils/teammate.tsTeammate Agent toolsChapter 20
utils/swarm/teammatePromptAddendum.tsTeammate prompt addendum contentChapter 20

Tool Results and Storage

FileResponsibilityRelated Chapters
utils/toolResultStorage.tsLarge result persistence, truncation previewsChapters 12, 28
utils/toolSchemaCache.tsTool Schema cachingChapter 15

Cross-Session Memory

FileResponsibilityRelated Chapters
memdir/memdir.tsMEMORY.md index and topic file loading, system prompt injectionChapter 24
memdir/paths.tsMemory directory path resolution, three-level priority chainChapter 24
services/extractMemories/extractMemories.tsFork agent automatic memory extractionChapter 24
services/SessionMemory/sessionMemory.tsRolling session summary for compactionChapter 24
utils/sessionStorage.tsJSONL session record storage and recoveryChapter 24
tools/AgentTool/agentMemory.tsSub-Agent persistence and VCS snapshotsChapter 24
services/autoDream/autoDream.tsOvernight memory consolidation and pruningChapter 24

Telemetry and Observability

FileResponsibilityRelated Chapters
services/analytics/index.tsEvent entry point, queue-attach pattern, PII tag typesChapter 29
services/analytics/sink.tsDual-path dispatch (Datadog + 1P), samplingChapter 29
services/analytics/firstPartyEventLogger.tsOTel BatchLogRecordProcessor integrationChapter 29
services/analytics/firstPartyEventLoggingExporter.tsCustom Exporter, disk-persistent retryChapter 29
services/analytics/metadata.tsEvent metadata, tool name sanitization, PII gradingChapter 29
services/analytics/datadog.tsDatadog allow-list, batch flushingChapter 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 detectionChapter 29
utils/debug.tsDebug logging, --debug flagChapter 29
utils/diagLogs.tsPII-free container diagnosticsChapter 29
utils/errorLogSink.tsError file loggingChapter 29
utils/telemetry/sessionTracing.tsOTel spans, three-level tracingChapter 29
utils/telemetry/perfettoTracing.tsPerfetto visualization tracingChapter 29
utils/gracefulShutdown.tsCascading timeout graceful shutdownChapter 29
cost-tracker.tsCost tracking, cross-session persistenceChapter 29

Configuration and State

FileResponsibilityRelated Chapters
utils/effort.tsEffort level parsingChapter 21
utils/fastMode.tsFast Mode managementChapter 21
utils/managedEnvConstants.tsManaged environment variable allowlistAppendix B
screens/REPL.tsxMain interactive interface (5000+ line React component)Chapter 1