Skip to main content
ClaudeWave
Skill2.9k repo starsupdated 1mo ago

claude-code-skill

Claude Code is Anthropic's open-source CLI tool built in TypeScript that enables terminal-based interaction with Claude AI, featuring file editing, shell command execution, git workflows, code review, multi-agent coordination, and IDE integrations through React/Ink UI components. Use this skill to understand the development conventions, architecture, tech stack, and directory structure of the ~1,900-file codebase when building features, reviewing code, or contributing to the Claude Code repository.

Install in Claude Code
Copy
git clone https://github.com/codeaashu/claude-code ~/.claude/skills/claude-code-skill
Then start a new Claude Code session; the skill loads automatically.

Skill.md

# Claude Code — Repository Skill

## Project Overview

Claude Code is Anthropic's CLI tool for interacting with Claude from the terminal. It supports file editing, shell commands, git workflows, code review, multi-agent coordination, IDE integration (VS Code, JetBrains), and Model Context Protocol (MCP).

**Codebase:** ~1,900 files, 512,000+ lines of TypeScript under `src/`.

## Tech Stack

| Component        | Technology                                      |
|------------------|------------------------------------------------|
| Language         | TypeScript (strict mode, ES modules)           |
| Runtime          | Bun (JSX support, `bun:bundle` feature flags)  |
| Terminal UI      | React + Ink (React for CLI)                    |
| CLI Parser       | Commander.js (`@commander-js/extra-typings`)   |
| API Client       | `@anthropic-ai/sdk`                            |
| Validation       | Zod v4                                         |
| Linter/Formatter | Biome                                          |
| Analytics        | GrowthBook (feature flags & A/B testing)       |
| Protocol         | Model Context Protocol (MCP)                   |

## Architecture

### Directory Map (`src/`)

| Directory        | Purpose                                                         |
|------------------|-----------------------------------------------------------------|
| `commands/`      | ~50 slash commands (`/commit`, `/review`, `/config`, etc.)      |
| `tools/`         | ~40 agent tools (Bash, FileRead, FileWrite, Glob, Grep, etc.)  |
| `components/`    | ~140 Ink/React UI components for terminal rendering             |
| `services/`      | External integrations (API, OAuth, MCP, LSP, analytics, plugins)|
| `bridge/`        | Bidirectional IDE communication layer                           |
| `state/`         | React context + custom store (AppState)                         |
| `hooks/`         | React hooks (permissions, keybindings, commands, settings)      |
| `types/`         | TypeScript type definitions                                     |
| `utils/`         | Utilities (shell, file ops, permissions, config, git)           |
| `screens/`       | Full-screen UIs (Doctor, REPL, Resume, Compact)                 |
| `skills/`        | Bundled skills + skill loader system                            |
| `plugins/`       | Plugin system (marketplace + bundled plugins)                   |
| `coordinator/`   | Multi-agent coordination & supervisor logic                     |
| `tasks/`         | Task management (shell tasks, agent tasks, teammates)           |
| `context/`       | React context providers (notifications, stats, FPS)             |
| `memdir/`        | Persistent memory system (CLAUDE.md, user/project memory)       |
| `entrypoints/`   | Initialization logic, Agent SDK, MCP entry                      |
| `voice/`         | Voice input/output (STT, keyterms)                              |
| `vim/`           | Vim mode keybinding support                                     |
| `schemas/`       | Zod configuration schemas                                       |
| `keybindings/`   | Keybinding configuration & resolver                             |
| `migrations/`    | Config migrations between versions                              |
| `outputStyles/`  | Output formatting & theming                                     |
| `query/`         | Query pipeline & processing                                     |
| `server/`        | Server/daemon mode                                              |
| `remote/`        | Remote session handling                                         |

### Key Files

| File                | Role                                                |
|---------------------|-----------------------------------------------------|
| `src/main.tsx`      | CLI entry point (Commander parser, startup profiling)|
| `src/QueryEngine.ts`| Core LLM API caller (streaming, tool-call loops)    |
| `src/Tool.ts`       | Tool type definitions & `buildTool` factory          |
| `src/tools.ts`      | Tool registry & presets                              |
| `src/commands.ts`   | Command registry                                     |
| `src/context.ts`    | System/user context collection (git status, memory)  |
| `src/cost-tracker.ts`| Token cost tracking                                 |

### Entry Points & Initialization Sequence

1. `src/main.tsx` — Commander CLI parser, startup profiling
2. `src/entrypoints/init.ts` — Config, telemetry, OAuth, MDM
3. `src/entrypoints/cli.tsx` — CLI session orchestration
4. `src/entrypoints/mcp.ts` — MCP server mode
5. `src/entrypoints/sdk/` — Agent SDK (programmatic API)
6. `src/replLauncher.tsx` — REPL session launcher

Startup performs parallel initialization: MDM policy reads, Keychain prefetch, feature flag checks, then core init.

## Patterns & Conventions

### Tool Definition

Each tool lives in `src/tools/{ToolName}/` and uses `buildTool`:

```typescript
export const MyTool = buildTool({
  name: 'MyTool',
  aliases: ['my_tool'],
  description: 'What this tool does',
  inputSchema: z.object({
    param: z.string(),
  }),
  async call(args, context, canUseTool, parentMessage, onProgress) {
    // Execute and return { data: result, newMessages?: [...] }
  },
  async checkPermissions(input, context) { /* Permission checks */ },
  isConcurrencySafe(input) { /* Can run in parallel? */ },
  isReadOnly(input) { /* Non-destructive? */ },
  prompt(options) { /* System prompt injection */ },
  renderToolUseMessage(input, options) { /* UI for invocation */ },
  renderToolResultMessage(content, progressMessages, options) { /* UI for result */ },
})
```

**Directory structure per tool:** `{ToolName}.ts` or `.tsx` (main), `UI.tsx` (rendering), `prompt.ts` (system prompt), plus utility files.

### Command Definition

Commands live in `src/commands/` and follow three types:

- **PromptCommand** — Sends a formatted prompt with injected tools (most commands)
-