惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
D
Docker
J
Java Code Geeks
腾讯CDC
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
M
MIT News - Artificial intelligence
L
LangChain Blog
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
博客园 - Franky
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
N
Netflix TechBlog - Medium
B
Blog RSS Feed
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News

Hacker News - Newest: "AI"

AI can't read an investor deck AI as an attorney? Student uses ChatGPT, Gemini to sue UW over alleged racial discrimination Hacking MCP Servers in AI Systems – The Rug Pull: Tool Changes After Approval GitHub - MeepCastana/KubeezCut: Free Web based video editor GitHub - GenAI-Gurus/awesome-eu-ai-act: Curated tools, official sources, OSS, templates, and guides for EU AI Act compliance. Can AI judge journalism? A Thiel-backed startup says yes, even if it risks chilling whistleblowers Coming soon: 10 Things That Matter in AI Right Now DARPA built an AI to fact-check enemy weapons claims What explains heterogeneity in AI adoption? When AI Meets Muscle: Context-Aware Electrical Stimulation Promises a New Way to Guide Human Movements - Department of Computer Science AI Changed How We Build. It Did Not Change What Matters. Linux rules on using AI-generated code - Copilot is OK, but humans must take 'full responsibility for the… Meta spins up AI version of Mark Zuckerberg to engage with employees Code Mode: Let Your AI Write Programs, Not Just Call Tools | TanStack Blog GitHub - Delavalom/graft: Go framework for building AI agents. Type-safe tools, multi-provider (OpenAI, Anthropic, Gemini, Bedrock), zero vendor SDKs. India's TCS tops estimates, says new AI models did not dent services demand Gen Z's fading AI hype Strong feeling: we are in a folded AI reality GitHub - machinarii/total-recall-catalog: A reference catalog of latest knowledge retrieval, memory & RAG systems GitHub - mensfeld/code-on-incus: Give each AI agent its own isolated machine with root, Docker, and systemd. Active defense detects and stops threats automatically.. Quantization, LoRA, and the 8% Problem: Benchmarking Local LLMs for Production AI Iran war: We spoke to the man making Lego-style AI videos that experts say are powerful propaganda Powell, Bessent discussed Anthropic's Mythos AI cyber threat with major U.S. banks GitHub - immartian/bellamem: Persistent belief-graph memory for AI agents. Retrieves decisive context by importance — not recency, not RAG, not /compact. recursive-mode: The Repo-Native Operating System for AI Engineering After the attack on Sam Altman's home, will AI CEO's go on the offensive? The biggest advance in AI since the LLM Opus 4.6 vs GPT 5.4 One Prompt Unity World Generation Test “AI polls” are fake polls Client Challenge
GitHub - alejandrobalderas/claude-code-from-source: Archi...
2026-04-11 · via Hacker News - Newest: "AI"

Architecture, Patterns & Internals of Anthropic's AI Coding Agent


This repository is purely educational. It contains no source code from Claude Code — not a single line. Every code block is original pseudocode written to illustrate architectural patterns. The goal is to help engineers understand how production AI agents are built, not to reproduce or redistribute proprietary software.


When Anthropic shipped Claude Code on npm, the .js.map source maps contained a sourcesContent field with the full original TypeScript. This book is the result of studying that architecture and distilling the patterns, trade-offs, and design decisions into a technical narrative that any engineer can learn from.

18 chapters across 7 parts. ~400 pages in print equivalent.

Every chapter has layered depth: a narrative flow for technical leaders, deep-dive sections for implementers, and an "Apply This" closing that extracts transferable patterns you can steal for your own systems. Diagrams use Mermaid and render natively on GitHub.


Who This Is For

  • Senior engineers building agentic systems — steal the patterns, understand the trade-offs, implement in your own stack
  • Technical leaders evaluating architectures — follow the narrative without reading every code block
  • Anyone curious about how production AI tools actually work under the hood

Table of Contents

Part I: Foundations

Before the agent can think, the process must exist.

# Chapter What You'll Learn
1 The Architecture of an AI Agent The 6 key abstractions, data flow, permission system, build system
2 Starting Fast — The Bootstrap Pipeline 5-phase init, module-level I/O parallelism, trust boundary
3 State — The Two-Tier Architecture Bootstrap singleton, AppState store, sticky latches, cost tracking
4 Talking to Claude — The API Layer Multi-provider client, prompt cache, streaming, error recovery

Part II: The Core Loop

The heartbeat of the agent: stream, act, observe, repeat.

# Chapter What You'll Learn
5 The Agent Loop query.ts deep dive, 4-layer compression, error recovery, token budgets
6 Tools — From Definition to Execution Tool interface, 14-step pipeline, permission system
7 Concurrent Tool Execution Partition algorithm, streaming executor, speculative execution

Part III: Multi-Agent Orchestration

One agent is powerful. Many agents working together are transformative.

# Chapter What You'll Learn
8 Spawning Sub-Agents AgentTool, 15-step runAgent lifecycle, built-in agent types
9 Fork Agents and the Prompt Cache Byte-identical prefix trick, cache sharing, cost optimization
10 Tasks, Coordination, and Swarms Task state machine, coordinator mode, swarm messaging

Part IV: Persistence and Intelligence

An agent without memory makes the same mistakes forever.

# Chapter What You'll Learn
11 Memory — Learning Across Conversations File-based memory, 4-type taxonomy, LLM recall, staleness
12 Extensibility — Skills and Hooks Two-phase skill loading, lifecycle hooks, snapshot security

Part V: The Interface

Everything the user sees passes through this layer.

# Chapter What You'll Learn
13 The Terminal UI Custom Ink fork, rendering pipeline, double-buffer, pools
14 Input and Interaction Key parsing, keybindings, chord support, vim mode

Part VI: Connectivity

The agent reaches beyond localhost.

# Chapter What You'll Learn
15 MCP — The Universal Tool Protocol 8 transports, OAuth for MCP, tool wrapping
16 Remote Control and Cloud Execution Bridge v1/v2, CCR, upstream proxy

Part VII: Performance Engineering

Making it all fast enough that humans don't notice the machinery.

# Chapter What You'll Learn
17 Performance — Every Millisecond and Token Counts Startup, context window, prompt cache, rendering, search
18 Epilogue — What We Learned The 5 architectural bets, what transfers, where agents are heading

The 10 Patterns That Make It Work

If you read nothing else:

  1. AsyncGenerator as agent loop — yields Messages, typed Terminal return, natural backpressure and cancellation
  2. Speculative tool execution — start read-only tools during model streaming, before the response completes
  3. Concurrent-safe batching — partition tools by safety, run reads in parallel, serialize writes
  4. Fork agents for cache sharing — parallel children share byte-identical prompt prefixes, saving ~95% input tokens
  5. 4-layer context compression — snip, microcompact, collapse, autocompact — each lighter than the next
  6. File-based memory with LLM recall — Sonnet side-query selects relevant memories, not keyword matching
  7. Two-phase skill loading — frontmatter only at startup, full content on invocation
  8. Sticky latches for cache stability — once a beta header is sent, never unset mid-session
  9. Slot reservation — 8K default output cap, escalate to 64K on hit (saves context in 99% of requests)
  10. Hook config snapshot — freeze at startup to prevent runtime injection attacks

How This Book Was Made

The source was extracted from npm source maps. 36 AI agents analyzed nearly two thousand TypeScript files in four phases:

  1. Exploration: 6 parallel agents read every file in the source tree
  2. Analysis: 12 agents wrote 494KB of raw technical documentation
  3. Writing: 15 agents rewrote everything from scratch as narrative chapters
  4. Review & Revision: 3 editorial reviewers produced 900 lines of feedback; 3 revision agents applied all fixes

The entire process — from source extraction to final revised book — took approximately 6 hours.


Disclaimer

This repository does not contain any source code from Claude Code. All code blocks are original pseudocode using different variable names, written to illustrate architectural patterns. No proprietary prompt text, internal constants, or exact function implementations are included. This project exists purely for educational purposes — to help engineers understand the design patterns behind production AI coding agents.

The "NO'REILLY" cover is a parody/meme for illustrative purposes only. This project has no affiliation with O'Reilly Media. The crab is just a crab.

This is an independent analysis. Claude Code is a product of Anthropic. This book is not affiliated with, endorsed by, or sponsored by Anthropic.