Skip to content

Demo: mini-claude Build Guide

Build chapter by chapter — end up with an AI coding assistant matching Claude Code's architecture

Open in GitHub Codespaces

Final Goal

demo/
├── main.ts                    # CLI entry (Commander.js)
├── context.ts                 # System prompt builder
├── query.ts                   # Query loop (streaming + tool use)
├── Tool.ts                    # Tool interface & factory
├── tools.ts                   # Tool registry
├── types/                     # Type system ← Chapter 1
├── tools/                     # Tool implementations
├── services/
│   ├── api/claude.ts          # Anthropic SDK wrapper
│   └── compact/compact.ts     # Context compression
├── screens/REPL.tsx           # Terminal UI (Ink)
├── components/                # UI components
├── commands/                  # Slash commands
└── utils/                     # Utilities

Chapter-by-Chapter Progress

ChNew ModulesCapability AfterStatus
1types/ type systemType definitions compile
2Tool.ts + tools.tsTool interface & registry
3services/api/ + context.tsStreaming API calls
4query.ts + utils/messages.tsMulti-turn tool use loop
5BashTool, FileReadTool, GrepToolExecute commands, read files, search
6FileWriteTool, FileEditTool, GlobToolFull file operations
7utils/permissions.tsDangerous command blocking
8screens/REPL.tsx + components/Interactive terminal UI
9main.ts (Commander.js)Full CLI argument support
10commands/ + compact service/help, /clear, /compact
11components/PermissionRequest.tsxInteractive permission prompts
12History, retry, error handlingProduction-ready

Run the Demo

bash
cd demo
bun install
bun run main.ts

# Type check
bun run typecheck