ARCH.md
Overview
TinyClaw orchestrates 1-4B parameter models for real project work. The driver handles everything the tiny model can't: file extraction, state management, verification, git. The model just edits code.
Flow
- Big model (or human) writes atomic tasks to QUEUE.md
- Driver reads next task from queue
- Extractor pulls target function from source file (Python AST)
- Prompt builder assembles: system prompt (~200 tokens) + function code + task instruction
- Model client sends to tiny model, gets edited function back
- Verifier checks syntax, imports, optional tests
- On pass: splice back into file, git commit, mark task done
- On fail: revert, retry (max 3), then skip with error log
- Repeat until queue empty
Modules
| Module |
Owns |
Exposes |
Depends On |
| driver |
core loop, queue state |
run(), status() |
extractor, client, verifier |
| extractor |
AST parsing, function splice |
extract_function(), splice_function() |
(none) |
| client |
model API calls |
generate(prompt, model) |
(none, uses requests) |
| verifier |
syntax/import/test checks |
verify(filepath) |
(none) |
| webui |
Flask app, queue editor |
serve() |
driver |
File Index
| File |
Purpose |
| tinyclaw/driver.py |
Core loop, queue processing |
| tinyclaw/extractor.py |
AST function extraction and splicing |
| tinyclaw/client.py |
Model API client (OpenRouter, Ollama) |
| tinyclaw/verifier.py |
Syntax, import, test verification |
| tinyclaw/prompt.py |
Prompt assembly |
| tinyclaw/cli.py |
CLI entry point |
| tinyclaw/webui.py |
Web UI (milestone 3) |
| tinyclaw/__init__.py |
Package init, version |
Queue Format (QUEUE.md)
Env / Deps
- Python 3.10+
- requests (model API calls)
- flask (web UI, milestone 3)
- No other heavy deps
Decisions Log
| Date |
Decision |
Reason |
| 2026-04-02 |
Model never uses tools |
1-4B can't reliably format tool calls |
| 2026-04-02 |
AST extraction, not line-range |
Accurate function boundaries, handles decorators |
| 2026-04-02 |
Python projects first |
Clean AST, expand later with tree-sitter |
| 2026-04-02 |
OpenRouter as primary API |
Fits OpenClaw ecosystem, access to small models |
| 2026-04-02 |
Max 500 token prompts |
Leaves room for output in 2-4k context |
Forge