From while True to production gateway in 10 Python files
A progressive tutorial that builds a real AI agent gateway one runnable section at a time, instead of stopping at the first API call.

What it does
claw0 is a teaching repo that constructs a minimal AI agent gateway from scratch across 10 self-contained Python files. Each section adds exactly one concept—agent loop, tool dispatch, session persistence, Telegram/Feishu channels, gateway routing, prompt assembly, heartbeat cron, reliable delivery, resilience retries, and named-lane concurrency—while keeping all prior code intact. The README claims ~7,000 lines total, with sections ranging from ~175 to ~1,130 lines.
The interesting bit
The pedagogical discipline is the hook: no frameworks, no magic imports, just a single file per concept that you can actually run. It mirrors how you’d evolve a prototype into production—s03’s JSONL session replay becomes s09’s overflow compaction, s06’s file-based personality system feeds s07’s proactive heartbeat. The companion repo learn-claude-code handles the internal agent design; claw0 owns the gateway and routing surface.
Key highlights
- 10 runnable sections in 3 languages (EN/ZH/JA), code and docs co-located
- Production concerns treated as first-class lessons: auth rotation, write-ahead queues, lane-based serialization
- Clean dependency graph: foundation → connectivity → brain → autonomy → production
- Workspace files (SOUL.md, MEMORY.md, CRON.json) make prompt engineering tangible and versionable
- MIT licensed, Anthropic API key the only hard requirement
Caveats
- Stars at 2,810 suggest traction but not battle-tested scale; no benchmarks or deployment stories in the README
- “Production-grade” is the README’s claim—verify yourself before trusting your pager to it
- Requires Python 3.11+ and an Anthropic key; other providers are “compatible” but unspecified
Verdict
Worth a weekend if you’re building agent infrastructure and tired of tutorials that end at requests.post. Skip it if you want a drop-in framework or already operate a message gateway in anger.