This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Reconstructed TypeScript source tree of the Claude Code CLI, recovered from source maps of the public npm release. Some native modules are replaced with compatible shims in shims/. This is not the upstream Anthropic development repo.
bun install # Install dependencies (includes local shim packages)
bun run dev # Start CLI interactively (alias: bun run start)
bun run version # Verify the CLI boots and prints versionRequirements: Bun >= 1.3.5, Node.js >= 24
There is no lint, test, or build script. Validation is manual: boot the CLI and exercise the changed path.
src/dev-entry.ts is the entry point. It scans for missing relative imports across src/ and vendor/. If any are missing, it prints a diagnostic and exits. When all imports resolve, it forwards to src/entrypoints/cli.tsx → src/main.tsx which runs full initialization (auth, GrowthBook, MCP, settings, Commander.js) and launches the React/Ink REPL.
src/main.tsx— Full CLI initialization: side-effect imports for startup profiling, MDM reads, and keychain prefetch must stay at the top and in order.src/query.ts/src/QueryEngine.ts— Streaming API call loop, tool execution, auto-compaction, session lifecycle, and persistence.src/commands.ts— Slash command registration (/commit,/review,/config,/compact,/memory,/plan, etc.).src/tools/— 53 tool implementations, each in its own directory (e.g.,BashTool/,FileEditTool/,AgentTool/).src/commands/— 87 slash command implementations, each in its own directory with anindex.tsentry.src/services/— Backend services: API client (api/), MCP protocol (mcp/), session compaction (compact/), analytics/feature flags (analytics/).src/components/— Terminal UI components built with React + Ink (messages, inputs, diffs, permission dialogs, status bar).src/hooks/— Custom React hooks for tools, voice, IDE integration, vim mode, sessions, tasks.src/ink/— Custom Ink fork handling layout, focus, ANSI rendering, virtual scrolling, and click detection.src/vim/— Full vim keybinding engine (motions, operators, text objects).src/coordinator/— Multi-agent coordination, conditionally loaded viabun:bundlefeature flagCOORDINATOR_MODE.src/assistant/— KAIROS assistant mode, conditionally loaded via feature flagKAIROS.src/bridge/— Remote bridge control for web/IDE connections.shims/— Compatibility replacements for private native modules (color-diff-napi,modifiers-napi,url-handler-napi, and Anthropic-internal MCP packages).vendor/— Native binding source code (audio-capture-src,image-processor-src,modifiers-napi-src,url-handler-src).
- TypeScript with ESM imports and
react-jsx.strictmode is off in tsconfig. - Most files omit semicolons and use single quotes — match surrounding file style exactly.
camelCasefor variables/functions,PascalCasefor React components and classes,kebab-casefor command directories.- Import order: when comments warn against reordering, keep imports stable.
main.tsxside-effect imports at the top are order-sensitive. - Path alias:
src/*maps to./src/*via tsconfig paths. - Prefer small, focused modules over broad utility dumps.
There is no automated test suite. For any change:
- Boot the CLI with
bun run dev. - Smoke-test version output with
bun run version. - Exercise the specific command, service, or UI path you changed.
When adding tests, place them close to the feature they cover and name them after the module or behavior under test.
Use short, imperative commit subjects (e.g., Fix MCP config normalization). In PRs, explain user-visible impact and list validation steps.
dev-entry.tsgates startup on zero missing imports. Any new module must be resolvable or the CLI won't boot.- Conditional imports via
bun:bundlefeature flags (COORDINATOR_MODE,KAIROS) userequire()to avoid circular dependencies — preserve this pattern. - Changes to shims should maintain API compatibility with the original native modules they replace.
- This is a reconstructed source tree — prefer minimal, auditable changes. Document any workaround added because a module was restored with fallbacks or shim behavior.