A distilled coding agent in ~5,800 lines of Python
Less code. Similar performance on 50 samples in SWE-Bench
Nano-Claw-Code is a lightweight Python coding agent distilled from the full Claude Code framework.
We systematically analyzed which tools the agent actually uses during real coding tasks (SWE-bench), removed everything non-essential, then rewrote the core in pure Python. The result is a 70x reduction in code size with zero performance loss.
This demonstrates that large-scale agentic frameworks contain substantial redundancy for specific task distributions, and that principled distillation can yield dramatically simpler systems without sacrificing capability.
# The entire agent in 15 Python modules
cli.py 1,639 lines # Interactive REPL & CLI
tools_impl.py 1,066 lines # 12 core tools
agent.py 659 lines # Agent loop & caching
openai_compat.py 599 lines # Multi-provider support
agents.py 302 lines # Sub-agent system
skills.py 294 lines # Skill discovery
config.py 279 lines # Configuration
session.py 233 lines # Session persistence
prompts.py 189 lines # System prompts
... +5 more modules
─────────────────────────────
Total ~5,800 lines
Evaluated on SWE-bench Lite (first 40 instances) using claude-sonnet-4-20250514
| Variant | Language | Tools | Core Lines | Submitted | Resolved | Resolve Rate |
|---|---|---|---|---|---|---|
| start-claude-code full | TypeScript | 42 | ~405,500 | 38 | 22 | 57.9% |
| nano-claw-code python | Python | 12 | ~5,800 | 38 | 22 | 57.9% |
Two-stage distillation: prune unused tools, then rewrite in Python
What was kept, what was cut, and why
.claude/skills/cd nano-claw-code
pip install -e .
# Anthropic API
export ANTHROPIC_API_KEY="sk-ant-xxx"
# Or via OpenRouter
export OPENROUTER_API_KEY="sk-or-xxx"
export OPENROUTER_MODEL="moonshotai/kimi-k2"
# Interactive mode
./start.sh
# SWE-bench evaluation
cd swebench_harness
python run_swebench_claude_code.py \
--claude-code-dir ../nano-claw-code \
--max-instances 2