OpenLAIR Research

Nano-Claw-Code

A distilled coding agent in ~5,800 lines of Python
Less code. Similar performance on 50 samples in SWE-Bench

70x
Smaller Codebase
405K → 5.8K lines
57.9%
SWE-bench Resolve Rate
Similar performance on 50 samples
12
Core Tools
Down from 42

What Is This?

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.

nano_claw_code/
# 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

Key Results

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%
TypeScript line counts reflect core agent framework only (excluding ~107,400 lines of shared UI). Full benchmark runs (300 instances) are in progress.
start-claude-code
405,500 lines
nano-claw-code
5,800 lines

Distillation Pipeline

Two-stage distillation: prune unused tools, then rewrite in Python

start-claude-code

TypeScript
~405,500 lines 42 tools
Stage 1: Prune
-29 tools, -4 services
-27,400 lines (6.8%)

nano-claude-code

TypeScript
~378,100 lines 13 tools
Stage 2: Rewrite
TypeScript → Python
65x compression

nano-claw-code

Python
~5,800 lines 12 tools

Architecture

What was kept, what was cut, and why

12 Tools Retained

Read Write Edit Bash Glob Grep WebFetch WebSearch NotebookEdit TodoWrite Agent Skill

29 Tools Removed

PowerShell LSP SendMessage PlanMode Config Brief ToolSearch Worktree Cron Team Tasks MCP Resources AskUser McpAuth +15 more

Key Capabilities Preserved

Sub-agent System
3 built-in profiles + custom agents
Skill System
Discover skills from .claude/skills/
Memory Hierarchy
Layered CLAUDE.md with @include
Context Compaction
Auto-summarize at 75% token budget
Prompt Caching
Anthropic cache_control breakpoints
Permission System
3 modes with safe-command classification
Session Persistence
Save/load/resume conversations
OpenAI Compatibility
Kimi, MiniMax, and more via OpenRouter

Quick Start

1

Install

cd nano-claw-code
pip install -e .
2

Configure API

# 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"
3

Run

# 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

Roadmap

Distill Claude Code into nano-claude-code (42 → 13 tools, TypeScript)
Python re-implementation — nano-claw-code (~5,800 lines, 12 tools)
SWE-bench evaluation harness with full trace logging
Comparative evaluation on SWE-bench Lite (40/300 instances)
Full SWE-bench Lite run (300 instances) — all three variants
SWE-bench Verified run (500 instances)
Third-party model evaluation via OpenRouter (Kimi, MiniMax)
Distillation dataset from agent traces