by SafeRL-Lab
Nano Claude Code: A Fast, Easy-to-Use Python Reimplementation of Claude Code Supporting Any Model
# Add to your Claude Code skills
git clone https://github.com/SafeRL-Lab/nano-claude-codeEnglish | 中文 |한국어 | 日本語 | Deutsch | Português
task/ package): TaskCreate / TaskUpdate / TaskGet / TaskList tools with sequential IDs, dependency edges (blocks/blocked_by), metadata, persistence to .nano_claude/tasks.json, thread-safe store, /tasks REPL command, 37 new tests (~9500 lines of Python).plugin/ package): install/uninstall/enable/disable/update via /plugin CLI, recommendation engine (keyword+tag matching), multi-scope (user/project), git-based marketplace. AskUserQuestion tool: interactive mid-task user prompts with numbered options and free-text input (~8500 lines of Python).mcp/ package, stdio + SSE + HTTP transports, auto tool discovery, /mcp command, 34 new tests (~7000 lines of Python).multi_agent/), memory package (), skill package () with built-in skills, argument substitution, fork/inline execution, AI memory search, git worktree isolation, agent type definitions ( lines of Python), see .No comments yet. Be the first to share your thoughts!
memory/skill/Nano Claude Code: A Lightweight and Easy-to-Use Python Reimplementation of Claude Code Supporting Any Model, such as Claude, GPT, Gemini, Kimi, Qwen, Zhipu, DeepSeek, and local open-source models via Ollama or any OpenAI-compatible endpoint.
Claude Code is a powerful, production-grade AI coding assistant — but its source code is a compiled, 12 MB TypeScript/Node.js bundle (~1,300 files, ~283K lines). It is tightly coupled to the Anthropic API, hard to modify, and impossible to run against a local or alternative model.
Nano Claude Code reimplements the same core loop in ~10K lines of readable Python, keeping everything you need and dropping what you don't. See here for more detailed analysis (Nano Claude code v3.03), English version and Chinese version
| Dimension | Claude Code (TypeScript) | Nano Claude Code (Python) |
|-----------|--------------------------|---------------------------|
| Language | TypeScript + React/Ink | Python 3.8+ |
| Source files | ~1,332 TS/TSX files | 51 Python files |
| Lines of code | ~283K | ~10.2K |
| Built-in tools | 44+ | 21 |
| Slash commands | 88 | 17 |
| Model providers | Anthropic only | 7+ (Anthropic · OpenAI · Gemini · Kimi · Qwen · DeepSeek · Ollama · …) |
| Local models | No | Yes — Ollama, LM Studio, vLLM, any OpenAI-compatible endpoint |
| Build step required | Yes (Bun + esbuild) | No — run directly with python nano_claude.py |
| Runtime extensibility | Closed (compile-time) | Open — register_tool() at runtime, Markdown skills, git plugins |
| Task dependency graph | No | Yes — blocks / blocked_by edges in task/ package |
NotebookEdit, LSP Diagnostics, RemoteTrigger, EnterWorktree, and more.extractMemories service proactively extracts knowledge from conversations without explicit tool calls.cli.js, comprehensive test coverage, version-locked releases.--model or /model — no recompile needed.agent.py). Any Python developer can read, fork, and extend it in minutes.pip install -r requirements.txt and you're running. Changes take effect immediately.register_tool(ToolDef(...)), install skill packs from git URLs, or wire in any MCP server.TaskCreate / TaskUpdate support blocks / blocked_by edges for structured multi-step planning (not available in Claude Code).preserve_last_n_turns.Agent loop — Nano uses a Python generator that yields typed events (TextChunk, ToolStart, ToolEnd, TurnDone). The entire loop is visible in one file, making it easy to add hooks, custom renderers, or logging.
Tool registration — every tool is a ToolDef(name, schema, func, read_only, concurrent_safe) dataclass. Any module can call register_tool() at import time; MCP servers, plugins, and skills all use the same mechanism.
Context compression
| | Claude Code | Nano Claude Code |
|-|-------------|-----------------|
| Trigger | Exact token count | len / 3.5 estimate, fires at 70 % |
| Layer 1 | — | Snip: truncate old tool outputs (no API cost) |
| Layer 2 | AI summarization | AI summarization of older turns |
| Control | System-managed | preserve_last_n_turns parameter |
Memory — Claude Code's extractMemories service has the model proactively surface facts. Nano's memory/ package is tool-driven: the model calls MemorySave explicitly, which is more predictable and auditable.
| Feature | Details | |---|---| | Multi-provider | Anthropic · OpenAI · Gemini · Kimi · Qwen · Zhipu · DeepSeek · Ollama · LM Studio · Custom endpoint | | Interactive REPL | readline history, Tab-complete slash commands | | Agent loop | Streaming API + automatic tool-use loop | | 21 built-in tools | Read · Write · Edit · Bash · Glob · Grep · WebFetch · WebSearch · MemorySave · MemoryDelete · MemorySearch · MemoryList · Agent · SendMessage · CheckAgen