Skip to content

luzhenqian/claude-harness

Repository files navigation

English | 中文 | 日本語

Claude Harness

Deconstructing Claude Code — interactive source code analysis, guided walkthroughs, and deep architectural exploration.

Claude Harness is an open-source platform for exploring and understanding the internals of Claude Code, Anthropic's official AI coding agent. Through interactive code browsing, in-depth technical articles, and module-level analysis, it transforms 500K+ lines of TypeScript into an accessible learning experience.

Why This Project Exists

Claude Code is one of the most sophisticated AI agent harnesses ever built — a masterclass in tool design, context management, permission governance, and multi-agent coordination. But understanding its architecture from raw source alone is daunting.

Claude Harness makes that architecture legible. It provides:

  • Guided articles that walk through each subsystem with real code references
  • Interactive code browser with syntax highlighting and full-text search
  • Module visualizations that reveal the structural relationships in the codebase

Whether you're building your own AI agent, studying harness engineering patterns, or simply curious about how Claude Code works under the hood — this project is for you.

At a Glance

Metric Value
Source Files Analyzed 1,902
Lines of Code 514,587
Modules Mapped 35
Technical Articles 31+
Languages English, 中文, 日本語

Key Features

Interactive Code Browser

Browse the full Claude Code source tree with a file explorer, syntax highlighting powered by Shiki, and instant client-side search via FlexSearch.

In-Depth Technical Articles

31 guided walkthroughs covering every major subsystem:

# Article
01 The Big Picture: How a 512,000-Line AI CLI Is Built
02 The Query Engine: The Complete Lifecycle of a Conversation
03 The Tool System: How AI Safely Interacts with the Outside World
04 The Streaming Tool Executor: How to Safely Let AI Operate Multiple Tools Simultaneously
05 The Permission System: Walking the Tightrope Between Autonomy and Safety
06 Context Management: When Even a Million Tokens Aren't Enough
07 Startup Performance: How a Heavy CLI Achieves Fast Cold Starts
08 Multi-Agent Orchestration: How the Coordinator Pattern Enables AI Collaboration
09 Persistent Memory: How AI Remembers You Across Sessions
10 Bridge System: Bidirectional Communication Architecture Between CLI and IDE
11 MCP Protocol Integration: How AI Tools Connect to Everything
12 Plugins and Skills: A Three-Layer Extensibility Architecture
13 OAuth and Authentication: The Full Pipeline from Keychain to Token Refresh
14 Terminal UI Framework: Building a CLI with React
15 Keybindings and Vim Mode: Editor-Level Interaction in a CLI
16 Screen System: Designing Fullscreen Interaction Modes
17 State Management: React State Architecture Without Redux
18 Telemetry and Observability: OpenTelemetry in a CLI Application
19 Configuration System: Schema Validation, Migrations, and Multi-Source Merging
20 Feature Flags and Conditional Compilation: The Art of Compile-Time Code Elimination
21 The File Operations Trio: Design Philosophy of Read, Write, and Edit
22 BashTool: Letting AI Safely Execute Shell Commands
23 The Search System: The Glob + Grep + Full-Text Search Combination
24 Web Tools: How AI Accesses the Internet
25 LSP Integration: How Language Server Protocol Enhances AI Coding
26 The Buddy System: A Virtual Pet Game Inside Your Codebase
27 The Output Style System: Bringing Brand Identity to Terminal Output
28 Remote Execution and Scheduled Triggers: The Headless AI Agent
29 Session Management: Interruption, Resumption, and Sharing
30 API Client: Deep Integration with the Anthropic API
31 Error Handling and Self-Healing: How AI Recovers from Failures

Module Explorer

Visualize the 35 major modules with file counts, line counts, and descriptions:

utils          564 files   181K lines   Utility functions
components     389 files    82K lines   Ink UI components (~140)
services       130 files    54K lines   External service integrations
tools          184 files    51K lines   Agent tool implementations (~40)
commands       207 files    27K lines   Slash commands (~50)
hooks          104 files    19K lines   React hooks
ink             96 files    20K lines   Ink renderer wrapper
...and 28 more

Multi-Language Support

Full internationalization with English, Chinese (中文), and Japanese (日本語) — with locale-aware routing and automatic fallback.

Tech Stack

Layer Technology
Framework Next.js 16 (App Router)
UI React 19 + Tailwind CSS 4
Code Highlighting Shiki
Search FlexSearch
Articles MDX via next-mdx-remote
i18n next-intl
Animations Motion
Diagrams Mermaid
Monorepo Turbo
Deployment Vercel

Getting Started

Prerequisites

  • Node.js 22+ (see .node-version)
  • pnpm (or npm)

Installation

# Clone the repository
git clone https://github.com/anthropics/claude-harness.git
cd claude-harness

# Install dependencies
pnpm install

# Generate metadata (file tree, module stats, search index)
pnpm generate

# Start development server
pnpm dev

The app will be available at http://localhost:3000.

Build for Production

pnpm build

Project Structure

claude-harness/
├── content/
│   └── articles/
│       ├── en/                    # English articles
│       ├── zh/                    # Chinese articles (31 guides)
│       └── ja/                    # Japanese articles
│
├── packages/
│   ├── claude-code-source/        # (source no longer distributed — see its README)
│   ├── scripts/                   # Metadata generation pipeline
│   │   └── src/
│   │       ├── generate-file-tree.ts
│   │       ├── generate-module-stats.ts
│   │       ├── generate-search-index.ts
│   │       └── generate-source-summary.ts
│   │
│   └── web/                       # Next.js web application
│       └── src/
│           ├── app/[locale]/      # Locale-aware pages
│           │   ├── articles/      # Article list & detail
│           │   ├── code/          # Interactive code browser
│           │   └── modules/       # Module explorer
│           ├── components/        # Shared UI components
│           ├── lib/               # Utilities & data loading
│           └── i18n/              # Internationalization config
│
├── turbo.json                     # Turbo monorepo config
├── vercel.json                    # Vercel deployment config
└── package.json                   # Root workspace config

Data Generation Pipeline

The pnpm generate command runs four scripts that process Claude Code source (provided locally) into structured metadata:

  1. File Tree — Recursively scans the source directory into a hierarchical JSON tree (1,902 entries)
  2. Module Stats — Analyzes 35 top-level modules with file/line counts
  3. Source Summary — Aggregates totals across the entire codebase
  4. Search Index — Builds a full-text FlexSearch index for client-side search

These generated files power the web UI's code browser, module explorer, and search functionality.

Architecture

+---------------------------------------------------+
|                  Web Application                   |
|                                                    |
|  +----------+ +----------+ +--------+ +---------+  |
|  | Articles | |   Code   | | Module | | Search  |  |
|  |  (MDX)   | | Browser  | |Explorer| | (Flex)  |  |
|  +----+-----+ +----+-----+ +---+----+ +----+----+  |
|       |             |           |           |       |
|  +----v-------------v-----------v-----------v----+  |
|  |             Generated Metadata                |  |
|  |  file-tree.json module-stats.json search-idx  |  |
|  +------------------------+----------------------+  |
+---------------------------|-------------------------+
                            |
                  +---------v---------+
                  | Generation Scripts |
                  | (packages/scripts) |
                  +---------+---------+
                            |
                  +---------v---------+
                  | Claude Code Source |
                  |  (not distributed) |
                  +--------------------+

Contributing

Contributions are welcome! Here are some ways to help:

  • Add articles — Write new technical walkthroughs in content/articles/
  • Translate — Help expand English and Japanese article coverage
  • Improve UI — Enhance the code browser, module explorer, or search experience
  • Fix bugs — Check the Issues tab for open items

Writing Articles

Articles are MDX files in content/articles/{locale}/. Each file needs frontmatter:

---
title: "Your Article Title"
description: "Brief description"
order: 32
tags: ["tag1", "tag2"]
readTime: "15 min"
---

Your content here...

Related Projects

License

MIT

About

Deconstructing Claude Code — interactive source code analysis, guided wc/helpe walkthroughs, and deep architectural exploration of Anthropic's AI coding agent.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors