Claude Code Source Leak: Four Projects That Decode the AI Coding Agent Architecture

After part of Claude Code's source code leaked, four open-source projects unpacked its internal architecture — through animated diagrams, deep-dive reports, a design guide, and an open-source implementation.

In the March that just ended, something big happened in the AI coding world: part of Claude Code's source code leaked by accident.

That "accident" opened a window for developers around the world — the internals of an AI coding Agent turn out to be this intricate, and those "magical" operations rest on designs this complex.

Today I'll introduce four projects that got popular because of it; each unpacks Claude Code's design essence from a different angle.

1. An animated explanation of how Claude Code works (in English)

https://ccunpacked.dev/

If the source code is an unreadable book from heaven, this site is its animated picture-book edition.

Built by developer @zackautocracy, this interactive site turns Claude Code's whole input-to-output flow into a clickable, animated visual piece:

Core modules include:

  • The Agent Loop — the full flow from user input → message handling → API call → Token accounting → tool call → loop rendering, animated step by step across 11 stages
  • Architecture Explorer — the source tree of more than 1,800 files, grouped into Tools & Commands, Core Processing, UI Layer, and so on
  • Tool System — detailed notes on 50+ built-in tools, grouped by function into file operations, execution, search, Agent tasks, MCP, planning, and more
  • Command Catalog — a complete index of 88 slash commands
  • Hidden Features — features in the code that haven't shipped, including Buddy (virtual pet), Kairos (persistence mode), UltraPlan (long-horizon planning), Coordinator Mode (multi-agent coordination), and more

Why I recommend it: the most intuitive, most complete visual walkthrough of Claude Code available right now — good for developers who want to grasp how it works fast.

2. A deep-dive research report on the Claude Code source

https://github.com/tvytlx/ai-agent-deep-dive

This repo offers two versions of a deep technical report (PDF) that systematically dissects the Claude Code source.

What the report covers:

  • Agent Loop mechanics: how the Query Loop drives the entire system
  • Tool system design: interface definitions and execution flow for 50+ tools
  • Multi-Agent collaboration: how Task, Team, and Agent relate to and communicate with each other
  • Context management: the internals of memory compaction and context governance
  • Security mechanisms: the design logic of the permission system, permission decisions, and interruption handling

Notably, the repo also includes a minimal teaching-oriented Python Agent project (src/agt/) that shows how the core structure of an AI Agent should be organized:

# Where the Agent core code lives
src/agt/agent.py    
# CLI entry point
src/agt/cli.py
A Fake LLM interface is built in for now, so learners can understand the architecture and then plug in a real model themselves.

Why I recommend it: want to understand Agent architecture at the theoretical level? These two reports are the most systematic reference material in Chinese/English today.

3. A slimmed-down open-source implementation of Claude Code

https://github.com/HKUDS/OpenHarness

This is the most hardcore project in this round-up — a from-scratch Python implementation of Claude Code's core architecture, at only 1/44 of the code.

By the numbers:

Metric Claude Code OpenHarness Gap
Lines of code 512,664 11,733 44x lighter
Files 1,884 163 -
Tools ~44 43 (98%) Almost on par
Commands ~88 54 (61%) -
Language TypeScript Python -

Core features kept:

  • 🔄 Agent Loop: streaming tool-call loop + exponential backoff retries
  • 🔧 43 tools: file I/O, shell, search, web, MCP
  • 🧠 Context and memory: CLAUDE.md injection, context compaction, MEMORY.md persistence
  • 🛡️ Permission system: multi-level permission modes, path rules, PreToolUse/PostToolUse Hooks
  • 🤝 Multi-Agent coordination: subagent spawning, team registration, background task management
  • 📚 Skills system: compatible with the anthropics/skills format

Architecture:

openharness/
  engine/          # Agent Loop — query → stream → tool-call → loop
  tools/           # 43 Tools — file I/O, shell, search, web, MCP
  skills/          # on-demand skill loading (.md files)
  permissions/     # multi-level modes, path rules, command deny
  hooks/           # PreToolUse/PostToolUse lifecycle
  commands/        # 54 Commands
  memory/          # persistent cross-session knowledge
  coordinator/     # subagent spawning, team coordination

Why I recommend it: want to experiment with Agent architecture yourself? Or build your own coding tool on Claude Code's ideas? This is the most complete, cleanest open-source reference implementation out there.


4. Two Claude Code design guides

https://github.com/wquguru/harness-books

This repo contains two books about Harness Engineering, both chasing one core engineering question:

When a model that can write code walks into your terminal, your repos, your permission system, and your team processes, what lets the system still hold its boundaries, its continuity, and its control over consequences?

Harness Engineering: A Claude Code Design Guide (book one)

Table of contents at a glance:

  • Chapter 1: Why Harness Engineering isn't just a bigger alias for Prompt Engineering
  • Chapter 2: A prompt isn't an input box; it's a control plane
  • Chapter 3: Query Loop — an Agent isn't answering questions; it's continuously taking over the workflow
  • Chapter 4: Tools, permissions, and interruption — how to let the model act without letting it run wild
  • Chapter 5: Context, memory, and compaction — how to keep a system working over the long run instead of getting muddier with every exchange
  • Chapter 6: Errors and recovery — the model making mistakes isn't an exception; it's the normal runtime state
  • Chapter 7: Multi-Agent and verification — don't let the system be its own judge
  • Chapter 8: Landing it with a team — turning individual tricks into organizational capability
  • Chapter 9: Ten principles — how to tell whether an AI coding system is an engineering system

Harness Design Philosophy in Claude Code and Codex (book two)

It sets Claude Code beside GitHub Copilot's Codex engine, analyzing the philosophy of order behind each harness design.

Read online:

Why I recommend it: if "how do I use it" isn't enough for you and you want to know "why was it designed this way", these two books offer the deepest engineering perspective available.

Final thoughts

The Claude Code source leak gave us a chance to glimpse the inner world of a top-tier AI coding tool.

These four projects enter from different angles — visual diagrams, a deep technical report, an open-source implementation, and an engineering design guide — and together they form a complete learning path:

If you want to Start with
Get a quick sense of how it works ccunpacked.dev
Learn the architecture systematically the ai-agent-deep-dive report
Build your own Agent OpenHarness
Understand the engineering design philosophy harness-books

I hope these resources help you understand the inner world of AI coding tools a little better.

All the links:

🔗 ccunpacked.dev: https://ccunpacked.dev/

🔗 ai-agent-deep-dive: https://github.com/tvytlx/ai-agent-deep-dive

🔗 OpenHarness: https://github.com/HKUDS/OpenHarness

🔗 harness-books: https://github.com/wquguru/harness-books

Which project do you find most valuable? Share your thoughts in the comments.

Related posts:

One week with opencode, and I threw Claude Code away (with an opencode install guide)

From paid closed source to an open-source replacement: OpenCode + Ollama team up to "raid" Claude Code

A guide to Claude Code alternatives in China: hooking up GLM and MiniMax with ease

Trae delisted the Claude models, and I think that's a good thing

ClaudeCode #AIAgent #OpenSourceProjects #SourceCodeAnalysis #HarnessEngineering #AIProgramming