How does an AI agent harness really work? 14 chapters deep-dive into the architecture of Claude Code — from the bootstrap phase to token routing.
Three-Layer Model
Claw Code follows a clear three-layer model. This book explains each layer line by line — with code examples, ASCII diagrams, and data flow analysis.
207 commands and 184 tools as JSON snapshots. LRU-cached, immutable, typed.
Token-based prompt routing, session bootstrapping, multi-turn loops with budget control.
7-phase bootstrap, trust gating, prefetch operations, JSON session persistence.
Deny-list-based access control with name and prefix matching.
From utils (564 modules) to voice (1 module) — each documented with JSON metadata.
Clean-room reimplementation, copyleft debate, the questions that matter.
class PortRuntime: def route_prompt(self, prompt: str, limit: int = 5): # Tokenization tokens = {t.lower() for t in prompt.replace('/', ' ') .replace('-', ' ').split() if t} # Scoring: 207 commands + 184 tools by_kind = { 'command': self._collect_matches( tokens, PORTED_COMMANDS, 'command'), 'tool': self._collect_matches( tokens, PORTED_TOOLS, 'tool'), } return self._select(by_kind, limit)
Table of Contents
Each chapter goes deep into a module — with source code, sequence diagrams, and architectural analysis.
Practical Guide
Step by step through the architecture. From setup to building your own AI system.
Free Download
14 chapters. 6,400+ lines. Every module explained. Completely free.
EPUB 3 — Kindle · Apple Books · Google Play · Tolino · Kobo