The entire AI agent that's taking over the tech world — broken down file by file. ~700 lines of core orchestration. Built in one weekend. 10,500+ GitHub stars. Let's read it together and map every piece to the Agent Formula.
This is every file that matters. Not a simplified version — this IS the architecture. Compare this to OpenClaw's 400,000 lines across 52+ modules.
Click each tab to see the real code patterns from NanoClaw. Every highlighted line maps directly to the Agent Formula you learned today.
This single file is the heart of NanoClaw. At ~700 lines, it handles everything: connecting to WhatsApp, polling for new messages, deciding when to invoke the AI agent, spawning containers, and routing responses back. This is the REASONING LOOP of the entire system.
This is why NanoClaw exists. Instead of giving the AI access to your whole computer (like OpenClaw), each agent runs in its own isolated Linux container. It can only see what you explicitly mount. This file handles spawning those containers and streaming the AI's output back.
Remember the TOOLS part of the Agent Formula? This file defines what the agent can do. Each tool is an MCP server function that the agent calls when it needs to take action in the world. Same concept as the calculator tool from your Colab notebook — but these tools send messages, schedule tasks, and manage groups.
The MEMORY component. This is how NanoClaw remembers conversations, stores scheduled tasks, and tracks which messages have been processed. Without this, the agent would have no context — every message would be a blank slate.
This is one of NanoClaw's most elegant ideas. Each group has its own CLAUDE.md file — a Markdown document that serves as the agent's BRAIN instructions for that specific context. The agent reads this before every response, and can modify it to "remember" things.
Every piece of NanoClaw maps to the formula you learned today. Here's the exact mapping.
NanoClaw uses Claude Code running inside each container. The Agent SDK handles all the thinking. NanoClaw never processes language itself — it just routes messages to Claude and routes responses back.
Same pattern as your Colab calculator tool. Each tool has a name, description, and input schema. Claude decides when to use them. The IPC system communicates tool results back to the host.
The message loop polls → detects trigger → loads context → spawns agent → sends response. Same pattern as your run_agent() while loop. NanoClaw adds a concurrency queue so multiple groups don't step on each other.
Two memory systems: SQLite for structured data (messages, tasks, state), and Markdown files for unstructured knowledge ("Mom's birthday is March 15"). The agent can read AND write both.
NanoClaw's entire core is ~700 lines. Your Colab agent loop was ~50 lines. The difference is infrastructure (containers, WhatsApp, databases) — not intelligence. The agent pattern is the same.
The most valuable decisions in NanoClaw aren't technical. They're: "What tools should the agent have?" (business question), "What should each group's CLAUDE.md say?" (product question), and "What gets mounted in each container?" (trust question).
One developer built this in a weekend. With Claude Code. The same tools you used today. The only difference is he identified a real problem (security), had a clear 10× advantage (auditable code), and shipped fast. You can do this.