|
1 | | -# Codebase CLI |
| 1 | +<p align="center"> |
| 2 | + <img src="docs/assets/codebase-mark.svg" alt="codebase" width="96" /> |
| 3 | +</p> |
2 | 4 |
|
3 | | -AI coding agent in your terminal. Reads your project, writes code, runs commands, searches the web. Works with any LLM provider — or sign in with codebase.foundation and we proxy inference for you. |
| 5 | +<h1 align="center">codebase</h1> |
4 | 6 |
|
5 | | -> **v2 (TypeScript)** — codebase-cli has been rewritten on top of the |
6 | | -> [pi-mono](https://github.com/earendil-works/pi-mono) runtime. Existing |
7 | | -> v1 (Go) users: the installer below auto-detects the old binary and |
8 | | -> migrates your data. See [`docs/MIGRATION_v1_to_v2.md`](docs/MIGRATION_v1_to_v2.md). |
| 7 | +<p align="center"> |
| 8 | + <strong>An AI coding agent for builders.</strong><br/> |
| 9 | + Lives in your terminal. Reads your project, writes code, runs commands, ships work. |
| 10 | +</p> |
9 | 11 |
|
10 | | -## Install |
11 | | - |
12 | | -Requires **Node.js ≥ 20**. The one-liner installer prints a hint with Volta/fnm/nvm if Node is missing or too old. |
| 12 | +<p align="center"> |
| 13 | + <a href="https://www.npmjs.com/package/codebase-cli"><img alt="npm" src="https://img.shields.io/npm/v/codebase-cli?style=flat-square" /></a> |
| 14 | + <a href="https://github.com/codebase-foundation/codebase-cli/blob/master/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" /></a> |
| 15 | +</p> |
13 | 16 |
|
14 | | -**macOS / Linux (one-liner — recommended):** |
| 17 | +<p align="center"> |
| 18 | + <a href="https://github.com/earendil-works/pi"> |
| 19 | + <img src="https://pi.dev/logo-auto.svg" alt="Powered by pi" width="20" align="absmiddle" /> |
| 20 | + <strong>Powered by <a href="https://github.com/earendil-works/pi">pi</a></strong> |
| 21 | + </a> |
| 22 | + · |
| 23 | + <em>The agent loop, provider adapters, and session protocol come from <a href="https://github.com/earendil-works/pi">pi-mono</a>.</em> |
| 24 | +</p> |
15 | 25 |
|
16 | | -```sh |
17 | | -curl -fsSL https://codebase.design/install.sh | sh |
18 | | -``` |
| 26 | +--- |
19 | 27 |
|
20 | | -This detects an existing v1 binary, asks before removing it, then installs v2 via npm. |
21 | | - |
22 | | -**Windows (PowerShell):** |
23 | | - |
24 | | -```powershell |
25 | | -irm https://codebase.design/install.ps1 | iex |
26 | | -``` |
| 28 | +## Two ways to run it |
27 | 29 |
|
28 | | -**With npm (any platform, requires Node.js ≥ 20):** |
| 30 | +**Bring your own LLM.** Drop an API key in your shell and go — Anthropic, OpenAI, Groq, OpenRouter, Mistral, Ollama, any OpenAI-compatible endpoint. |
29 | 31 |
|
30 | 32 | ```sh |
31 | | -npm install -g codebase-cli |
| 33 | +ANTHROPIC_API_KEY=sk-ant-... codebase |
| 34 | +# or |
| 35 | +OPENAI_API_KEY=sk-... codebase |
32 | 36 | ``` |
33 | 37 |
|
34 | | -**With Homebrew:** |
35 | | - |
36 | | -```sh |
37 | | -brew install codebase-foundation/codebase/codebase |
38 | | -``` |
39 | | - |
40 | | -**From source:** |
41 | | - |
42 | | -```sh |
43 | | -git clone https://github.com/codebase-foundation/codebase-cli.git |
44 | | -cd codebase-cli |
45 | | -npm install |
46 | | -npm run build |
47 | | -npm link # symlinks `codebase` into your npm prefix |
48 | | -``` |
49 | | - |
50 | | -After install, run `codebase` from any project directory. |
51 | | - |
52 | | -## Quick Start |
53 | | - |
54 | | -**Option 1: Login with Codebase (easiest)** |
| 38 | +**Or sign in once via [codebase.design](https://codebase.design)** and try open-weight models instantly with no key setup — MiniMax, Qwen, Llama, and others routed through our inference proxy. One auth, every model. |
55 | 39 |
|
56 | 40 | ```sh |
57 | 41 | codebase auth login |
58 | | -``` |
59 | | - |
60 | | -Opens your browser, logs you into codebase.foundation, and you're ready. Uses our inference providers (Claude, MiniMax, Qwen, etc.) with your account credits. No API keys needed. |
61 | | - |
62 | | -**Option 2: Bring your own API key** |
63 | | - |
64 | | -```sh |
65 | | -export ANTHROPIC_API_KEY=sk-ant-... |
66 | 42 | codebase |
67 | 43 | ``` |
68 | 44 |
|
69 | | -Works with any provider: |
70 | | - |
71 | | -```sh |
72 | | -# OpenAI |
73 | | -export OPENAI_API_KEY=sk-... |
74 | | - |
75 | | -# Groq |
76 | | -export OPENAI_BASE_URL=https://api.groq.com/openai/v1 |
77 | | -export OPENAI_API_KEY=gsk-... |
78 | | -export OPENAI_MODEL=llama-3.3-70b-versatile |
79 | | - |
80 | | -# Ollama (local, free) |
81 | | -export OPENAI_BASE_URL=http://localhost:11434/v1 |
82 | | -export OPENAI_API_KEY=ollama |
83 | | -export OPENAI_MODEL=qwen2.5-coder:32b |
84 | | -``` |
85 | | - |
86 | | -**Option 3: First-run setup wizard** |
87 | | - |
88 | | -Just run `codebase` with no config. The setup wizard walks you through picking a provider, entering your key, and selecting a model. "Login with Codebase" is the first option. |
89 | | - |
90 | | -## What It Does |
91 | | - |
92 | | -You describe what you want. The agent reads your code, makes changes, runs commands, and explains what it did. |
93 | | - |
94 | | -``` |
95 | | -> add a /health endpoint that returns uptime and version |
96 | | -
|
97 | | - read_file server.go ✓ |
98 | | - read_file go.mod ✓ |
99 | | - edit_file server.go ✓ |
100 | | - shell go build ./... ✓ |
101 | | -
|
102 | | -Added GET /health endpoint at server.go:47 returning JSON with |
103 | | -uptime, version, and go runtime. Build passes. |
104 | | -``` |
105 | | - |
106 | | -## Tools (30) |
107 | | - |
108 | | -| Category | Tools | |
109 | | -|----------|-------| |
110 | | -| **File read** | `read_file`, `list_files`, `glob`, `grep`, `search_files` | |
111 | | -| **File write** | `write_file`, `edit_file`, `multi_edit`, `notebook_edit` | |
112 | | -| **Shell** | `shell` (input-aware parallelism — read-only commands run concurrently) | |
113 | | -| **Git** | `git_status`, `git_diff`, `git_log`, `git_commit`, `git_branch`, `enter_worktree`, `exit_worktree` | |
114 | | -| **Web** | `web_search`, `web_fetch` | |
115 | | -| **Agent** | `dispatch_agent` (explore, plan, or general-purpose subagents with optional worktree isolation) | |
116 | | -| **Tasks** | `create_task`, `update_task`, `list_tasks`, `get_task` | |
117 | | -| **Planning** | `enter_plan_mode`, `exit_plan_mode` | |
118 | | -| **Memory** | `save_memory`, `read_memory` (persist context across sessions) | |
119 | | -| **Other** | `config`, `ask_user` | |
120 | | - |
121 | | -Plus any tools from connected MCP servers. |
122 | | - |
123 | | -## Commands (22) |
124 | | - |
125 | | -| Command | What it does | |
126 | | -|---------|-------------| |
127 | | -| `/help` | List all commands | |
128 | | -| `/status` | Model, tokens, turns, cost | |
129 | | -| `/cost` | Token usage and estimated cost | |
130 | | -| `/context` | Visual context window usage bar | |
131 | | -| `/model [name]` | Show or switch model | |
132 | | -| `/commit` | Generate commit from current diff | |
133 | | -| `/review` | Code review of uncommitted changes | |
134 | | -| `/plan` | Enter planning mode | |
135 | | -| `/diff` | Open diff in VS Code/Cursor | |
136 | | -| `/compact` | Manually compact conversation | |
137 | | -| `/clear` | Clear display | |
138 | | -| `/memory` | View saved project memories | |
139 | | -| `/undo [file]` | Revert file from session history or git | |
140 | | -| `/export [file]` | Export conversation to markdown | |
141 | | -| `/tasks` | Show task checklist | |
142 | | -| `/theme` | Switch color theme | |
143 | | -| `/trust` | Set permission level | |
144 | | -| `/diagnostics` | Toggle language checkers | |
145 | | -| `/copy` | Copy last response to clipboard | |
146 | | -| `/session` | Full session info | |
147 | | -| `/setup` | Re-run setup wizard | |
148 | | -| `/quit` | Exit (or ctrl+c twice) | |
149 | | - |
150 | | -## Features |
151 | | - |
152 | | -- **30 tools** with schema validation and input-dependent parallel execution |
153 | | -- **Streaming tool execution** — tools start running before the model finishes responding |
154 | | -- **3 agent types** — explore (read-only), plan (architecture), general-purpose (full access) |
155 | | -- **Worktree isolation** — subagents can work in isolated git branches |
156 | | -- **Cross-session memory** — remembers your preferences and project context |
157 | | -- **Error recovery** — auto-retries on context overflow, output limits, rate limits |
158 | | -- **Structured compaction** — 9-section summaries when context gets long |
159 | | -- **Hooks system** — automate lint/test/format after edits |
160 | | -- **7 language checkers** — Go, TypeScript, ESLint, Python (pyright/mypy), Rust |
161 | | -- **MCP support** — connect external tool servers for extensibility |
162 | | -- **IDE detection** — discovers VS Code/Cursor/JetBrains via lockfiles |
163 | | -- **File history** — undo any edit within the session, even without git |
164 | | -- **Glue models** — route cheap tasks to a fast model, save money |
165 | | -- **Permission explainer** — risk-rated permission prompts (LOW/MEDIUM/HIGH) |
166 | | -- **Multi-provider** — OpenAI, Anthropic, MiniMax, Groq, Ollama, any compatible endpoint |
167 | | -- **OAuth-aware platform** — sign-in unlocks proxied inference and account-curated skills/templates/prompts |
| 45 | +## Install |
168 | 46 |
|
169 | | -## Authentication |
| 47 | +Requires **Node.js ≥ 20**. |
170 | 48 |
|
171 | 49 | ```sh |
172 | | -codebase auth login # browser OAuth — log in with Google, GitHub, or wallet |
173 | | -codebase auth <cbk_xxx> # save an API key from the dashboard (SSH / headless) |
174 | | -codebase auth status # show current sign-in |
175 | | -codebase auth refresh # force-refresh the access token |
176 | | -codebase auth logout # revoke session |
177 | | -``` |
178 | | - |
179 | | -Credentials are stored at `~/.codebase/credentials.json` (mode 0600). |
180 | | - |
181 | | -When logged in, the CLI routes through `codebase.foundation` — you get access to all providers (Claude, MiniMax, Qwen, etc.) using your account credits. No API keys to manage. Skill, template, and prompt definitions you author in the web app become available automatically (Phase 7+). |
182 | | - |
183 | | -## MCP (External Tool Servers) |
| 50 | +# one-liner (macOS / Linux) |
| 51 | +curl -fsSL https://codebase.design/install.sh | sh |
184 | 52 |
|
185 | | -Connect to any MCP-compatible server. Add to `~/.codebase/config.json`: |
| 53 | +# Windows (PowerShell) |
| 54 | +irm https://codebase.design/install.ps1 | iex |
186 | 55 |
|
187 | | -```json |
188 | | -{ |
189 | | - "mcp_servers": { |
190 | | - "github": { |
191 | | - "command": "mcp-server-github", |
192 | | - "args": ["--token", "$GITHUB_TOKEN"], |
193 | | - "transport": "stdio" |
194 | | - } |
195 | | - } |
196 | | -} |
| 56 | +# any platform |
| 57 | +npm i -g codebase-cli |
197 | 58 | ``` |
198 | 59 |
|
199 | | -MCP tools appear alongside built-in tools automatically. |
200 | | - |
201 | | -## Hooks |
| 60 | +## Quick start |
202 | 61 |
|
203 | | -Automate actions on events. Add to `~/.codebase/hooks.json`: |
204 | | - |
205 | | -```json |
206 | | -[ |
207 | | - { |
208 | | - "event": "PostEdit", |
209 | | - "matcher": "write_file|edit_file", |
210 | | - "command": "go vet ./...", |
211 | | - "timeout": 15 |
212 | | - } |
213 | | -] |
| 62 | +```sh |
| 63 | +cd your-project |
| 64 | +codebase |
214 | 65 | ``` |
215 | 66 |
|
216 | | -Events: `PreToolUse`, `PostToolUse`, `PostEdit`, `UserPromptSubmit`, `SessionStart`, `Stop`. |
217 | | - |
218 | | -## Project Instructions |
| 67 | +Type. Hit enter. The agent reads files, runs tests, edits code, and shows you what it did. Slash `/help` for the rest. |
219 | 68 |
|
220 | | -The CLI reads these files from your project root for context: |
| 69 | +A few things worth knowing: |
| 70 | +- `/model` — pick a model interactively (live list of what your account can hit) |
| 71 | +- `/plan` — Q&A before the agent touches anything |
| 72 | +- `!cmd` — run a shell command without spending a turn |
| 73 | +- `@path` — pin a file into the next prompt |
| 74 | +- `\<Enter>` — multi-line input |
| 75 | +- **Ctrl-C** stops the current turn, twice fast exits |
221 | 76 |
|
222 | | -- `CLAUDE.md` — project instructions (Claude Code convention) |
223 | | -- `AGENTS.md` — agent instructions (OpenAI Codex convention) |
224 | | -- `CODEX.md` — project instructions (Codex convention) |
225 | | -- `.cursorrules` — project instructions (Cursor convention) |
| 77 | +## Builder-focused defaults |
226 | 78 |
|
227 | | -## Flags |
| 79 | +- **Any LLM**, not just Anthropic. Provider choice is config. |
| 80 | +- **45+ tools** that all live behind one small interface — adding one is mechanical. |
| 81 | +- **Effect-based permissions** instead of tool-name allowlists. |
| 82 | +- **Single immutable state** driven by a typed reducer — the whole UI is one render of one value. |
| 83 | +- **Multi-process safe OAuth** with lockfile-coordinated token refresh — run 10 instances of codebase at once and they share a single refresh per hour. |
| 84 | +- **Plain `npm i -g`**, single binary, no bundler lock-in. |
228 | 85 |
|
229 | | -``` |
230 | | -codebase # run in current directory |
231 | | -codebase --dir /path/to/proj # run in specific directory |
232 | | -codebase --model claude-sonnet-4-5 # override model |
233 | | -codebase --resume # resume previous session |
234 | | -codebase --version # print version |
235 | | -codebase auth login # authenticate with codebase.foundation |
236 | | -codebase auth logout # revoke authentication |
237 | | -codebase --headless "fix the build" # one-shot, no TUI |
238 | | -``` |
239 | | - |
240 | | -## Environment Variables |
241 | | - |
242 | | -```sh |
243 | | -# LLM Provider (pick one) |
244 | | -OPENAI_API_KEY=... # OpenAI or compatible |
245 | | -ANTHROPIC_API_KEY=... # Anthropic (auto-detected) |
246 | | -OPENAI_BASE_URL=... # Custom endpoint |
247 | | -OPENAI_MODEL=... # Override model |
248 | | - |
249 | | -# Glue (optional — cheap model for routing/narration) |
250 | | -GLUE_API_KEY=... |
251 | | -GLUE_BASE_URL=... |
252 | | -GLUE_FAST_MODEL=... |
253 | | -GLUE_SMART_MODEL=... |
| 86 | +## More |
254 | 87 |
|
255 | | -# Web Search (optional — DuckDuckGo works without keys) |
256 | | -TAVILY_API_KEY=... |
257 | | -BRAVE_API_KEY=... |
258 | | - |
259 | | -# Behavior |
260 | | -CODEBASE_NOBOOT=1 # skip boot animation |
261 | | -CODEBASE_NOSOUND=1 # skip boot audio |
262 | | -``` |
| 88 | +- [`.settings/`](.settings/) — orientation: tenets, architecture, extending, testing |
| 89 | +- [`CLAUDE.md`](CLAUDE.md) — quick reference for AI agents working in this repo |
| 90 | +- [`docs/MIGRATION_v1_to_v2.md`](docs/MIGRATION_v1_to_v2.md) — upgrading from the Go v1 binary |
| 91 | +- [`/help` in the CLI](#) — every slash command and shortcut |
263 | 92 |
|
264 | 93 | ## License |
265 | 94 |
|
266 | | -MIT |
| 95 | +MIT. Built on [pi-mono](https://github.com/earendil-works/pi) (MIT). |
0 commit comments