A minimal, single-file AI coding assistant built with TypeScript and Bun. Uses Claude AI with tool-calling capabilities for intelligent code manipulation.
๐ Self-writing code from day one! Start with just ~100 lines of basic tool framework, and nanocode writes the rest of itself. A true AI pair programmer that bootstraps its own development.
- ๐ ๏ธ 10 Built-in Tools: File operations, code search, shell execution, and more
- ๐ง Context-Aware: Knows your OS, timezone, and working directory
- โก Zero Dependencies: Single TypeScript file (~345 lines)
- ๐ Live Output: Real-time streaming for long-running commands
- ๐จ Beautiful CLI: Colored output with markdown rendering
- ๐ Token Tracking: Displays API token usage after each interaction
- ๐ง Cross-Platform: Works on Windows, macOS, and Linux
# Install Bun (if not already installed) curl -fsSL https://bun.sh/install | bash # Set your API key export ANTHROPIC_API_KEY=your_key_here # Or on Windows: # set ANTHROPIC_API_KEY=your_key_here # Run nanocode bun run index.ts # Or make it executable: chmod +x index.ts && ./index.ts
| Command | Description |
|---|---|
/q or exit |
Quit the assistant |
/c |
Clear conversation history |
- read - Read files with line numbers (supports offset/limit)
- write - Write content to files
- edit - Find and replace in files (supports single or all occurrences)
- glob - Find files by pattern (sorted by modification time)
- grep - Search files with regex (limited to 50 results)
- exec - Execute commands with live output and custom timeout (1ms - 300s)
- list - List directory contents (supports recursive listing)
- delete - Delete files/directories (supports recursive deletion)
- move - Move or rename files
- copy - Copy files/directories (supports recursive copy)
|> What files are in this directory?
โบ glob({"pattern":"*"})
|> README.md ... +5 files
|> Read the first 10 lines of index.ts
โบ read({"path":"index.ts","limit":10})
|> 1| #!/usr/bin/env bun ... +9 lines
|> Find all TODO comments
โบ grep({"pattern":"TODO"})
|> index.ts:42:// TODO: Add error handling ... +2 lines
|> Run tests with live output
โบ exec({"command":"npm test","timeout":60000})
[stdout] Running tests...
[stdout] โ Test 1 passed
[stderr] Warning: deprecated API
[exit: 0]
๐ Tokens: 1250 in, 340 out, 1590 total
Environment variables:
API_URL=http://127.0.0.1:8045/v1/messages # API endpoint MODEL=claude-opus-4-5 # Claude model GREP_LIMIT=50 # Max grep results MAX_FILE_SIZE=10485760 # Max file size (10MB) ANTHROPIC_API_KEY=sk-ant-... # Your API key
- Code Generation: "Create a React component with TypeScript"
- Refactoring: "Refactor this function to use async/await"
- Bug Fixing: "Fix the type errors in this file"
- Code Review: "Review this code and suggest improvements"
- Documentation: "Add JSDoc comments to all functions"
- Testing: "Generate unit tests for this module"
The AI knows your system environment:
System Prompt includes:
- OS: win32 x64 (or darwin arm64, linux x64, etc.)
- Current time: 2026-01-11T11:26:56.779Z
- Working directory: /path/to/project
Use exec for commands with real-time output:
|> Run build with live output
โบ exec({"command":"npm run build","timeout":120000})
[stdout] Building...
[stdout] โ Compiled successfully
[exit: 0]
Automatically ignores common directories:
.git,node_modules,dist,build.next,coverage,.cache
- CLAUDE.md - Architecture and design notes for AI
This is a minimal, educational project. Key principles:
- Single file - Keep everything in
index.ts - Zero dependencies - Only use Bun APIs
- Simple & clear - Readable code over clever abstractions
MIT License - Feel free to use, modify, and distribute.
Built with:
- Bun - Fast JavaScript runtime
- Claude AI - Anthropic's AI assistant
- TypeScript - Type-safe JavaScript
Version: Enhanced - January 2026
Lines of Code: ~345
Dependencies: 0
Awesomeness: โ