claw0: Build an AI Agent Gateway from Scratch

Learn to build a production-grade AI agent gateway from zero to one through 10 progressive sections, covering tool use, multi-channel routing, autonomy, and concurrency.

Stars
★ 3.4k
Last updated
3mo ago
Primary language
Python

At a glance

How it runs
CLI
Works with
Platform-specificClaude API
Cost
Free software; you pay for model usage
Setup effort
Low · running in minutes
You'll need
Python 3.11+ANTHROPIC_API_KEYShell / CLINetwork accessLocal filesystem
Typical use
AI developers wanting to understand the core mechanisms of AI agents through hands-on coding
Not a fit if
  • Teams wanting a production-ready gateway out of the box; this is teaching code
  • Teams using OpenAI or local models only; Anthropic API is required
  • Teams needing Docker or cloud deployment configs, which are not provided

What does this agent do, and when should you use it?

claw0 is an educational repository that guides developers in building an AI agent gateway from scratch, similar to OpenClaw. It comprises 10 progressive sections, each a runnable Python file introducing one core concept, from the basic agent loop to concurrency control. The code supports Telegram and Feishu channels, implements session persistence, heartbeat cron jobs, message delivery queues, and resilience mechanisms like retries and auth rotation. By the end, learners can read OpenClaw's production codebase with confidence. The repository provides English, Chinese, and Japanese versions of code and docs.

Each section is a standalone Python script demonstrating a specific aspect of the agent gateway. For instance, s01 implements the basic agent loop (while True + stop_reason), s02 adds tool use via a dispatch table, s03 implements JSONL session persistence, s04 integrates Telegram and Feishu channels, s05 implements gateway routing with 5-tier binding, s06 introduces agent personality via files like SOUL.md, s07 adds heartbeat and scheduled tasks, s08 implements a message queue, s09 implements retry and auth rotation, and s10 implements named-lane concurrency. Users run these scripts with an Anthropic API key to experience building a gateway step-by-step.

  1. AI developers wanting to understand the core mechanisms of AI agents through hands-on coding
  2. Teams building automation bots for Telegram or Feishu, leveraging the channel implementations
  3. Developers needing message persistence and reliable delivery, learning from s03 and s08 queue designs
  4. Users interested in proactive agent behavior and scheduled tasks, referencing s07
  5. Developers ensuring concurrency safety in multi-user or multi-channel environments, studying s10
  6. Those wanting to give agents a personality and memory, exploring s06

How do you install or deploy this agent?

  1. Clone the repo: git clone https://github.com/shareAI-lab/claw0.git && cd claw0. 2. Install dependencies: pip install -r requirements.txt. 3. Copy .env.example to .env and edit to set ANTHROPIC_API_KEY and MODEL_ID. 4. Ensure Python 3.11+.

How do you use this agent?

Run any section (e.g., English): python sessions/en/s01_agent_loop.py. Study sections in order, as each builds on previous ones; for example, s03 depends on s02, s04 on s03, and so on. It's recommended to run from s01 to s10 sequentially and read the accompanying .md docs.

What are this agent's strengths and limitations?

Pros
  • Progressive pedagogy, each section adds one concept while retaining prior code
  • Three language versions (English, Chinese, Japanese) with co-located code and docs
  • Covers production-grade features: auth rotation, retry onion, concurrency control
  • Provides clear dependency graphs and architecture diagrams
  • Runnable and beginner-friendly
Limitations
  • Only supports Anthropic API, requiring its API key
  • No Docker or cloud deployment config, requires manual deployment
  • Teaching code may simplify real-world production complexities
  • No explicit test coverage or production readiness assurances

How does this agent compare with similar options?

The repository mentions a companion project, learn-claude-code, which focuses on the internal design of an agent (planning, context compression, team coordination), while claw0 focuses on gateway routing, channels, and proactive behavior.

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
claw0: Build an AI Agent Gateway from Scratch This agent 28 · Major gaps CLIFree + model costs ★ 3.4k 3mo ago Python Claude API
Claude Code From Scratch 60 · Some gaps CLIFree + model costs ★ 2.8k 3mo ago Python OpenAI API · Claude API
Learn Claude Code: Harness Engineering for Real Agents 48 · Major gaps CLIFree + model costs ★ 79k 20d ago Python Claude API
Donggua's AI Learning Notes: In-depth Pi-Agent SDK Tutorial 23 · Major gaps Web appFree ★ 3.4k 1mo ago MDX —

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Major gaps
28/ 100 5-point scale 1.4 / 5
Trust 0/29
Reliability 5/14
Adaptability 6/18
Convention 8/18
Effectiveness 7/13
Verifiability 2/8
Why each dimension lost points
Trust0 / 29 · 0.0/5

Evidence shows the repository is a tutorial, with no actual execution code, so there is no substantive content on least privilege, user confirmation, data flow transparency, sensitive data handling, dependency security, external effects, rollback, or source attribution. All trust criteria score 0 because there is no evidence these aspects are addressed.

Reliability5 / 14 · 1.8/5

Self-consistency scores 2: the 10 sections and dependencies described in the README are structurally consistent, but no code verification is provided. Dependency availability scores 1: dependencies are listed, but no version pinning or availability guarantees. Failure messages score 0: no documentation on error handling or user-visible failure messages.

Adaptability6 / 18 · 1.7/5

Audience and scenarios score 2: clearly aimed at developers learning AI agents, with multi-language support. Capability boundaries score 1: scope of each section is described, but limitations are not explicit. Trigger precision scores 0: no trigger conditions defined. Environment fit scores 1: mentions Python version and API key, but no detailed environment configuration guide.

Convention8 / 18 · 2.2/5

Information architecture scores 2: clear directory structure and section descriptions. Install notes score 2: provides quick start steps. Naming stability scores 1: section naming is consistent, but no API stability mentioned. Examples and FAQ score 2: provides runnable examples, but no FAQ. Known limitations score 0: not mentioned. License scores 2: MIT license. Versioning/changelog score 0: none. Maintenance responsibility scores 1: not explicit, but repository has organizational ownership.

Effectiveness7 / 13 · 2.7/5

Output usability scores 2: code and documentation are co-located, facilitating learning. Marginal value scores 2: provides a progressive learning path from basics to advanced. Cost-benefit scores 1: requires API key and dependencies, but reasonable for an educational project.

Verifiability2 / 8 · 1.3/5

Claim traceability scores 1: claims in README partially correspond to file structure, but no code verification. Cross-source corroboration scores 0: no external validation. Fact-inference separation scores 1: some distinction between description and inference, but not explicit.

Risks and how to mitigate them
  • Not found in source: least-privilege scopingGrant only what the task needs: a dedicated account or read-only token, scoped to specific directories and repos.
  • Not found in source: confirmation before actingTurn on (or add) a confirmation step before it acts, and try it in a sandbox or test environment before real data.
  • Not found in source: data-flow disclosureWatch which external services it contacts (proxy or firewall logs) and keep sensitive data out until you know where it goes.
  • Not found in source: sensitive-data handlingUse dedicated, low-privilege, revocable API keys — never production credentials — and keep secrets out of logs.
  • Not found in source: dependency securityPin versions and run a dependency audit (npm audit, pip-audit) before installing; prefer running it in a container.
  • Not found in source: disclosed external effectsEstablish which external systems it writes to, sends to or changes, and verify with test accounts or repos before production.
  • Not found in source: rollback or recovery pathBack up first, or work on a git branch or snapshot, so its changes can be undone.
  • Not found in source: verifiable attributionInstall from the official repo or registry and check the publisher and URL to avoid look-alike packages.
  • The repository is a tutorial, not a runnable agent product, so trust-related criteria cannot be assessed.
  • Dependencies are not pinned, posing potential supply chain risks.
  • No tests or verification provided; all claims are based on README only.
Evidence confidence: Low Reviewed Aug 09, 2026 Reviewed revision 0fbf0eb1bd65
See the full review method →

FAQ

What credentials do I need?
You need an Anthropic API key (ANTHROPIC_API_KEY) and set the model ID (MODEL_ID).
Which chat platforms are supported?
Telegram and Feishu are explicitly supported, implemented in s04.
Can I use this code in production?
The code is educational but includes production-grade concepts like retries and queues; use as a base and harden for production.
What prerequisites are required?
Python programming basics and understanding of API usage.
View on GitHub ↗ Install ↓

Related agents