CC
Claude Code
v2.1.88
Claude CodeFile Map

File Map

1800+ files

Complete reference of key files in the Claude Code source tree. Use this as a starting point for exploring specific areas of the codebase.

Critical Files (Start Here)

src/QueryEngine.ts
~1295

Query lifecycle, message buffering, system prompt assembly

src/query.ts
~1729

Main agentic loop state machine, API streaming, recovery

src/Tool.ts
~500+

Tool interface, ToolUseContext, buildTool() factory

src/main.tsx
~1600+

CLI initialization, state setup, parallel prefetching

src/context.ts
~300+

User/system context builders, CLAUDE.md loading

Tools Directory

tools/BashTool/BashTool.tsx
~160KB

Command execution with security

tools/BashTool/bashPermissions.ts
98KB

Permission rules + ML classifier

tools/BashTool/bashSecurity.ts
102KB

Dangerous pattern detection (AST)

tools/BashTool/readOnlyValidation.ts
68KB

Privilege escalation prevention

tools/BashTool/sedValidation.ts
21KB

Sed command validation

tools/FileEditTool/FileEditTool.ts

String find/replace with diff

tools/FileWriteTool/FileWriteTool.ts

Full content replacement

tools/FileReadTool/FileReadTool.ts

Read with PDF/notebook/image

tools/AgentTool/AgentTool.tsx
500+

Subagent spawning

tools/AgentTool/runAgent.ts
400+

Agent query loop + cache sharing

tools/AgentTool/loadAgentsDir.ts

YAML/MD agent definition loading

tools/SkillTool/SkillTool.ts

Skill invocation via sub-agent

tools/MCPTool/MCPTool.ts

MCP tool proxy wrapper

tools/GrepTool/

Ripgrep-based content search

tools/GlobTool/

File pattern matching

tools/shared/gitOperationTracking.ts

Git mutation detection

tools/shared/spawnMultiAgent.ts

Multi-agent/teammate spawning

Services Directory

services/api/claude.ts
3500+

Claude API client + streaming parser

services/compact/compact.ts

Full conversation compaction

services/compact/autoCompact.ts

Auto-compaction triggers + thresholds

services/compact/microCompact.ts

Single-turn compression

services/mcp/client.ts
119KB

MCP protocol client orchestrator

services/mcp/config.ts
51KB

MCP settings, env vars, validation

services/mcp/auth.ts
88KB

OAuth flow, token management

services/lsp/manager.ts

LSP server lifecycle management

services/extractMemories/extractMemories.ts

Auto-memory background agent

services/analytics/index.ts

Event pipeline API

services/tools/toolOrchestration.ts
189

Tool batching & concurrency

services/tools/StreamingToolExecutor.ts
226

Streaming execution queue

Other Key Directories

state/AppStateStore.ts

Central state definition (DeepImmutable)

coordinator/coordinatorMode.ts

Multi-worker orchestration (~370 lines)

memdir/memdir.ts

Memory directory system (21KB)

memdir/paths.ts

Memory path resolution (10KB)

memdir/memoryTypes.ts

Memory type taxonomy (22KB)

skills/loadSkillsDir.ts

Skill discovery & loading (34KB)

skills/bundledSkills.ts

Built-in skill registry

commands/

90+ slash commands (/compact, /model, etc.)

components/

Ink UI components (React for terminal)

ink/

Custom terminal rendering engine

hooks/toolPermission/

Permission context & logging

utils/permissions/

Permission modes, rules, filesystem checks

utils/forkedAgent.ts

Subagent context creation + cache params

utils/queryContext.ts

System prompt assembly pipeline

constants/prompts.ts

Tool definitions + system prompt (800+ lines)

bridge/

Remote work polling, spawning, reconnect, capacity management

remote/

Remote session manager and websocket/session adapters

services/PromptSuggestion/

Prompt suggestion, speculation overlays, next-step prediction

Slash Commands (90+)

Each command lives in its own directory under src/commands/. 101 total — grouped by category:

Core
/compact/model/clear/help/config/exit/status
Files & Context
/memory/files/context/resume/session/export/branch/diff
Security
/permissions/hooks/env/login/logout
AI Features
/fast/effort/voice/plan/review/skills/mcp
Monitoring
/cost/usage/stats/doctor/feedback/ide/desktop
Customization
/theme/stickers/color/vim/keybindings/share/tag/rename/copy/tasks/upgrade

Hidden gems worth finding: /btw, /think-back, /stickers, /bughunter, /teleport, /good-claude.

Start Here — Looking for X?

Understand how Claude answers
src/query.ts + src/QueryEngine.ts
See how tools work
tools/BashTool/BashTool.tsx
Trace permission checks
utils/permissions/ + bashPermissions.ts
Find how memory works
memdir/ + services/extractMemories/
Explore slash commands
commands/<name>/
See MCP integration
services/mcp/client.ts + config.ts