This is a recovered source tree of Anthropic's Claude Code CLI (reconstructed from npm source-map leak, 2026-03-31). The codebase is read-only architectural reference — there is no package.json and building requires the original toolchain (Bun, internal bun:bundle features, private dependencies).
Important: The underlying software is Anthropic's proprietary product. Use beyond fair use / your local law is your responsibility.
- Runtime: Bun (uses
bun:bundlefor dead code elimination and feature flags) - No local build: This is a recovered source tree without build toolchain
- Entry Point:
src/main.tsx(~800KB bundled, Commander-based CLI)
- Linter: ESLint + Biome (dual setup)
- Custom rules:
custom-rules/namespace for project-specific lint rules - Common lint disables:
// eslint-disable-next-line @typescript-eslint/no-require-imports // biome-ignore lint/suspicious/noConsole: intentional console output // eslint-disable-next-line custom-rules/no-process-env-top-level
- No test runner available in this recovered source tree
- Test files follow pattern:
*.test.ts,*.test.tsx - Example test location:
test/utils/transcriptSearch.renderFidelity.test.tsx - Single test execution: Not available without original toolchain
- Live site: https://python012.github.io/learn-agent-from-claude-code/
- Local preview:
pip install mkdocs mkdocs-material && mkdocs serve
- Extension required: Always use
.jsfor local imports,.mjsfor ESM packages (Bun bundler requirement) - Import organization: Type imports first, then regular imports; use
/* eslint-disable @typescript-eslint/no-require-imports */for lazyrequire() - biome-ignore-all for import order when markers must not be reordered
- Semicolons: Required
- Quotes: Single quotes for strings
- Trailing commas: Use in multi-line objects/arrays
- Line length: ~120 characters (soft limit)
- Arrow functions: Use
=>with space before and after - Object literals: Use shorthand when possible
- TypeScript: Strict mode with
zod/v4for runtime validation - Type imports: Always use
import type {}for type-only imports - Generic types: Use descriptive names (
Input,Output,P extends ToolProgressData) - Zod schemas: Use
z.object()withzod/v4for input validation - DeepImmutable: Use for contexts that must not be mutated
- Files: PascalCase for components/tools (
BashTool.tsx,AppState.ts), camelCase for utilities (errors.ts,format.ts) - Classes/Types: PascalCase (
Tool,ToolUseContext,ShellError) - Functions/variables: camelCase (
buildTool,isSearchOrReadBashCommand) - Constants: UPPER_SNAKE_CASE (
TOOL_DEFAULTS,BASH_SEARCH_COMMANDS) - React components: PascalCase with descriptive names (
renderToolUseMessage,ToolUseProgressMessage) - Feature flags: UPPER_SNAKE_CASE (
COORDINATOR_MODE,KAIROS,PROACTIVE)
- Custom error classes: Extend
Errorwith descriptive names (e.g.,ShellError,AbortError,TelemetrySafeError) - Error detection: Use type guards (e.g.,
isAbortError()) - Telemetry safety: Use
TelemetrySafeError_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHSfor telemetry-logged errors
- Framework: React + Ink for terminal UI components
- Hooks: Standard React hooks (
useState,useEffect,useMemo) - Cleanup: Use
registerCleanup()for global cleanup handlers - Rendering: Return JSX from
renderToolUseMessage(),renderToolResultMessage()methods
- JSDoc: Use for public APIs and complex functions
- Inline comments: Explain "why" not "what"
- TODO markers: Use
TODO:prefix with context - File headers: Add context for side-effect files (e.g.,
src/main.tsxlines 1-8)
- Bun feature flags: Use
feature()frombun:bundlefor dead code elimination - Environment flags: Use
process.env.USER_TYPE === 'ant'for ant-only features
- Permission modes: Use
PermissionModetype ('default','auto','bypass', etc.) - Tool validation: Implement
validateInput()andcheckPermissions()in tools - Permission context: Use
ToolPermissionContextfor permission checks - Telemetry: Never log file paths, code snippets, or sensitive data
- Promise handling: Use
async/awaitconsistently - AbortController: Pass
AbortSignalto long-running operations - Foreground tasks: Use
registerForeground()/unregisterForeground()for shell tasks - No floating promises: Use
biome-ignore lint/nursery/noFloatingPromiseswith justification
- FS abstraction: Use
getFsImplementation()for cross-platform FS ops - Path handling: Use
expandPath(),safeResolvePath()for path operations - Windows compatibility: Use
src/utils/windowsPaths.tsfor path conversion - Sync FS: Only in exit handlers; disable lint with
/* eslint-disable custom-rules/no-sync-fs */
- Test files:
*.test.ts/*.test.tsx - Test structure: Arrange-Act-Assert pattern
- Fidelity tests: Use
renderFidelity.test.tsxpattern for UI component testing
- Tool definition: Use
buildTool()helper withToolDeftype - State management: Use
AppStatewithsetAppState()pattern - Session storage: Use
sessionStorage.tsfor JSONL persistence - MCP integration: Use
src/services/mcp/for Model Context Protocol - Lazy require: Use
lazy require()for circular dependency breaks (e.g.,const getTeammateUtils = () => require('./utils/teammate.js'))
| Directory | Purpose |
|---|---|
src/Tool.ts |
Core Tool interface definition |
src/tools.ts |
Tool pool assembly |
src/tools/ |
Tool implementations (Bash, Read, Write, etc.) |
src/services/ |
API, MCP, LSP, plugins, analytics |
src/state/ |
AppState store and state management |
src/utils/ |
Utilities (permissions, settings, model, session) |
src/components/ |
React + Ink UI components |
src/types/ |
TypeScript type definitions |
docs-site/agent-learning-guide/ |
Agent development tutorials (9 parts) |
- Tutorial series:
docs-site/agent-learning-guide/(9 comprehensive guides) - Start here:
docs-site/agent-learning-guide/00-learning-roadmap.md(learning path overview) - Code index: See
docs-site/agent-learning-guide/README.mdfor core code locations
This source tree is reconstructed from a published npm package's source map. The underlying software is Anthropic's proprietary product. This repository is for architectural reference and educational purposes only. Use beyond fair use / your local law is your responsibility.