Comprehensive documentation of the Claude Code CLI (v2.1.88) source code, reconstructed from npm package source maps.
This analysis covers ~1884 TypeScript files across ~200 directories, documenting the architecture, tools, commands, services, utilities, UI components, and advanced features of the Claude Code CLI.
- Architecture Overview - High-level system architecture
- Main Entrypoint - CLI entry, initialization, command parsing
- Tool System - Tool abstraction & registry
- Query Engine - Query processing, LLM interaction
- Command System - Command dispatch
- State Management - AppState & state flow
- AgentTool - Sub-agent orchestration
- AskUserQuestionTool - User prompting
- BashTool - Shell command execution
- BriefTool - Context summarization
- ConfigTool - Configuration management
- EnterPlanModeTool - Plan mode activation
- EnterWorktreeTool - Git worktree creation
- ExitPlanModeTool - Plan mode deactivation
- ExitWorktreeTool - Worktree cleanup
- FileEditTool - Search-and-replace editing
- FileReadTool - File reading
- FileWriteTool - File writing
- GlobTool - Glob pattern matching
- GrepTool - Regex search
- LSPTool - Language Server Protocol
- ListMcpResourcesTool - MCP resource listing
- MCPTool - MCP tool invocation
- McpAuthTool - MCP authentication
- NotebookEditTool - Jupyter notebook editing
- PowerShellTool - PowerShell execution
- ReadMcpResourceTool - MCP resource reading
- REPLTool - Interactive REPL (Ant-only)
- RemoteTriggerTool - Remote trigger handling
- SendMessageTool - Inter-agent messaging
- SkillTool - Skill invocation
- ScheduleCronTool - Cron job management
- SyntheticOutputTool - Synthetic output generation
- TaskCreateTool - Task creation
- TaskGetTool - Task retrieval
- TaskListTool - Task listing
- TaskOutputTool - Task output retrieval
- TaskStopTool - Task cancellation
- TaskUpdateTool - Task status updates
- TeamCreateTool - Team creation
- TeamDeleteTool - Team deletion
- TodoWriteTool - Todo list management
- ToolSearchTool - Tool discovery
- TungstenTool - Tungsten integration
- WebFetchTool - URL fetching
- WebSearchTool - Web search
- KAIROS/Ant-only Tools - Feature-gated tools
- Session Commands - Session lifecycle
- Clear/Exit Commands - Session cleanup
- Config Commands - Configuration
- Settings Commands - Runtime settings
- Auth Commands - Authentication
- Review Commands - Code review
- Branch/Issue Commands - Git & issues
- MCP Commands - MCP management
- Feature Commands - Feature-specific
- Interaction Commands - Interactive session
- UI Commands - Information display
- Debug Commands - Debugging
- Remote Commands - Remote sessions
- Integration Commands - External integrations
- Misc Commands - Miscellaneous
- API Service - API client
- Analytics Service - Telemetry
- OAuth Service - Authentication
- MCP Service - MCP integration
- LSP Service - Language Server Protocol
- Compact Service - Context compaction
- Plugins Service - Plugin system
- Settings Sync Service - Cloud sync
- Team Memory Sync Service - Team memory
- Policy Limits Service - Rate limiting
- Remote Managed Settings - MDM
- Auto Dream Service - Proactive suggestions
- Extract Memories Service - Memory extraction
- Tips Service - User guidance
- Tool Use Summary Service - Usage tracking
- Auth | Config | Git
- Permissions | Settings
- Shell | Bash
- Model | Memory
- MCP | Skills
- Swarm | Telemetry
- Task | Todo
- Secure Storage | Sandbox
- GitHub | File Persistence
- Hooks | Effort/Fast Mode
- Teleport | Ultraplan
- Computer Use | Deep Link
- Worktree Mode | Advisor/Attribution
- Ink Framework - Terminal UI framework
- Components Overview - React components
- Design System - Design tokens
- Messages Components - Message rendering
- Permissions Components - Permission dialogs
- Keybindings System - Keyboard shortcuts
- Vim Mode - Vim emulation
- Spinner Components - Loading indicators
- Coordinator Mode - Multi-agent coordination
- Assistant Mode - KAIROS assistant
- Buddy System - AI companion
- Plugins System - Plugin architecture
- Skills System - Skills framework
- Voice Mode - Voice interaction
- Bootstrap - Application startup
- Migrations - Database migrations
- Hooks System - React hooks
- Context Providers - React context
- Native TS Modules - Native modules
- Schemas - Zod schemas
- Types System - TypeScript types
- Vendor Modules - Vendor code
- Message Flow - User input to LLM response
- Permission Flow - Permission request lifecycle
- Tool Execution Flow - Tool execution lifecycle
- Session Lifecycle - Session management
- Original Package: @anthropic-ai/claude-code
- Version: 2.1.88
- Source Files: ~1884 TypeScript files
- Restoration Method: Extracted from
cli.js.mapsourcesContent field