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)

FileLinesPurpose
src/QueryEngine.ts~1295Query lifecycle, message buffering, system prompt assembly
src/query.ts~1729Main 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

PathSizePurpose
tools/BashTool/BashTool.tsx~160KBCommand execution with security
tools/BashTool/bashPermissions.ts98KBPermission rules + ML classifier
tools/BashTool/bashSecurity.ts102KBDangerous pattern detection (AST)
tools/BashTool/readOnlyValidation.ts68KBPrivilege escalation prevention
tools/BashTool/sedValidation.ts21KBSed command validation
tools/FileEditTool/FileEditTool.tsString find/replace with diff
tools/FileWriteTool/FileWriteTool.tsFull content replacement
tools/FileReadTool/FileReadTool.tsRead with PDF/notebook/image
tools/AgentTool/AgentTool.tsx500+Subagent spawning
tools/AgentTool/runAgent.ts400+Agent query loop + cache sharing
tools/AgentTool/loadAgentsDir.tsYAML/MD agent definition loading
tools/SkillTool/SkillTool.tsSkill invocation via sub-agent
tools/MCPTool/MCPTool.tsMCP tool proxy wrapper
tools/GrepTool/Ripgrep-based content search
tools/GlobTool/File pattern matching
tools/shared/gitOperationTracking.tsGit mutation detection
tools/shared/spawnMultiAgent.tsMulti-agent/teammate spawning

Services Directory

PathSizePurpose
services/api/claude.ts3500+Claude API client + streaming parser
services/compact/compact.tsFull conversation compaction
services/compact/autoCompact.tsAuto-compaction triggers + thresholds
services/compact/microCompact.tsSingle-turn compression
services/mcp/client.ts119KBMCP protocol client orchestrator
services/mcp/config.ts51KBMCP settings, env vars, validation
services/mcp/auth.ts88KBOAuth flow, token management
services/lsp/manager.tsLSP server lifecycle management
services/lsp/LSPServerManager.tsMulti-server coordination
services/extractMemories/extractMemories.tsAuto-memory background agent
services/SessionMemory/sessionMemory.tsPeriodic conversation notes
services/analytics/index.tsEvent pipeline API
services/analytics/growthbook.tsFeature gates & A/B testing
services/tools/toolOrchestration.ts189Tool batching & concurrency
services/tools/StreamingToolExecutor.ts226Streaming execution queue

Other Key Directories

PathPurpose
state/AppStateStore.tsCentral state definition (DeepImmutable)
coordinator/coordinatorMode.tsMulti-worker orchestration (~370 lines)
memdir/memdir.tsMemory directory system (21KB)
memdir/paths.tsMemory path resolution (10KB)
memdir/memoryTypes.tsMemory type taxonomy (22KB)
skills/loadSkillsDir.tsSkill discovery & loading (34KB)
skills/bundledSkills.tsBuilt-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.tsSubagent context creation + cache params
utils/queryContext.tsSystem prompt assembly pipeline
utils/bash/Bash parsing utilities
utils/git/Git integration helpers
utils/memory/Memory system utilities
constants/prompts.tsTool definitions + system prompt (800+ lines)
entrypoints/cli.tsxCLI bootstrap + fast-path handling
entrypoints/sdk/SDK mode for headless use

Slash Commands (90+)

Each command lives in its own directory under src/commands/. Here are some notable ones:

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