Skip to content

lofi-coding/claude-code-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-code-source

Source code of @anthropic-ai/claude-code@2.1.88, extracted from sourcemap.

Claude Code is Anthropic's official CLI tool for Claude — an AI-powered coding assistant with a custom terminal UI, multi-cloud provider support, MCP protocol implementation, and an extensive suite of built-in tools.

Prerequisites

  • Bun >= 1.0
  • Node.js >= 18.0.0

Getting Started

# Install dependencies
bun install

# Run tests
bun test

# Type check
bun x tsc --noEmit

Project Structure

claude-code-source/
├── src/
│   ├── main.tsx                 # Main CLI entry point
│   ├── QueryEngine.ts           # Core conversation loop and API interaction
│   ├── Tool.ts                  # Base tool type definitions
│   ├── tools.ts                 # Tool discovery and registration
│   ├── commands.ts              # Command registry and dispatch
│   ├── entrypoints/             # Application entry points (CLI, MCP, SDK)
│   ├── commands/                # Slash command implementations
│   ├── components/              # Ink-based React terminal UI components
│   ├── hooks/                   # React hooks for terminal UI state
│   ├── tools/                   # 43 tool implementations
│   ├── services/                # 38 service modules (API, MCP, auth, analytics)
│   ├── utils/                   # 331 utility modules
│   ├── types/                   # TypeScript type definitions
│   ├── constants/               # Application constants
│   ├── schemas/                 # Validation schemas (Zod)
│   ├── context/                 # Context management
│   ├── state/                   # Application state management
│   ├── plugins/                 # Plugin system
│   ├── skills/                  # Skill definitions
│   ├── ink/                     # Custom Ink renderer and utilities
│   ├── vim/                     # Vim emulation for terminal input
│   ├── voice/                   # Voice interaction
│   └── ...
├── vendor/                      # Native module source (audio, image, NAPI)
├── package.json
├── tsconfig.json
├── bunfig.toml
└── bun.lock

Architecture

Terminal UI

Built on a custom Ink-style React renderer with React 19. The src/components/ directory contains 146 terminal UI components, and src/hooks/ provides 87 React hooks for managing interactive terminal sessions.

Multi-Cloud Support

Supports multiple AI provider backends:

  • Anthropic API — direct access via @anthropic-ai/sdk
  • AWS Bedrock — via @anthropic-ai/bedrock-sdk and @aws-sdk/*
  • Google Vertex AI — via @anthropic-ai/vertex-sdk
  • Azure — via @azure/identity

Model Context Protocol (MCP)

Full MCP client implementation in src/services/mcp/ for connecting to external tool servers, with server discovery, approval flows, and resource management.

Tool System

43 built-in tools in src/tools/ including file operations (FileReadTool, FileWriteTool, FileEditTool), code search (GlobTool, GrepTool), shell execution (BashTool), web access (WebFetchTool, WebSearchTool), task management, and agent orchestration. Each tool follows the interface defined in src/Tool.ts.

Command System

Extensible slash-command architecture in src/commands/ with support for plugins, skills, and custom user commands. Includes commands for code review, commits, security analysis, and more.

Testing

Tests use Bun's built-in test runner. Test files are co-located with source files using the *.test.ts convention.

# Run all tests
bun test

# Watch mode
bun test --watch

# Run a specific test file
bun test src/utils/array.test.ts

Configuration

File Purpose
bunfig.toml Bun runtime and test runner configuration
tsconfig.json TypeScript compiler options (ESNext, bundler resolution)
package.json Dependencies, scripts, and project metadata

License

This source was extracted from @anthropic-ai/claude-code@2.1.88 for educational and research purposes. All rights belong to Anthropic.

About

Source code of @anthropic-ai/claude-code@2.1.88, extracted from sourcemap

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors