Learn · A 12-lesson source-code reading

Learn Claude Code

Not a tutorial — a teardown. From the one-line agent loop to worktree isolation. 12 lessons × 3 interactive widgets, each readable on its own.

12 lessons 36 widgets Based on shareAI-lab/learn-claude-code
S01
Agent Loop
No loop, no agent
Agent loopstop_reasonmessages historytool_result passback
→
S02
Tool Use
Same loop, more tools
Tool dispatch mapJSON schemasafe_path escapingtool extension
→
S03
Todo Write
Let the agent track its own progress
TodoManagerin_progress singleton rulenag reminder injectionstructured state
→
S04
Subagent
Delegate big problems to a fresh agent
Subagent dispatchcontext isolationCHILD_TOOLS trimmingsummary-only return
→
S05
Skill Loading
Domain knowledge loaded on demand
Two-layer skill architectureYAML frontmatterload_skill tooltoken economics
→
S06
Context Compact
Context filling up? Learn to compact.
Micro compactAuto compactmanual compact tooltranscript persistence
→
S07
Task System
State written to disk, survives compression
Task CRUDblockedBy dependency graphJSON file persistencetopological ready-set
→
S08
Background Tasks
Let work run itself, no blocking
Threaded background tasknotification queuedrain before LLM callresult passback
→
S09
Agent Teams
Multiple agents communicate via file inboxes
Persistent teammateJSONL inbox5 message typesteam config.json
→
S10
Team Protocols
Handshakes between agents
shutdown protocolplan_approval protocolrequest_id correlationFSM: pending->approved/rejected
→
S11
Autonomous Agents
Agents that find their own work
WORK / IDLE two-phase lifecycletask board pollingauto_claimidentity reinjection
→
S12
Worktree Isolation
Different agents should not share the same tree
git worktree addtask / worktree bindingkeep vs removedirectory-level isolation
→