kbcode Documentation
Everything you need to install, configure, and master kbcode — the terminal AI coding agent that remembers your project.
1 Installation
Paste one line into PowerShell or cmd.exe — no Python, no admin rights, no clone needed:
powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol='Tls12'; Invoke-Expression (Invoke-RestMethod -UseBasicParsing https://kbcode.dev/install.ps1)"
PowerShell • works in cmd.exe too — just paste and press Enter
cmd.exe (Command Prompt — no PowerShell):
curl -fsSL https://kbcode.dev/install.bat -o "%TEMP%\kbi.bat" && "%TEMP%\kbi.bat"
The installer downloads kb.exe, verifies its SHA-256 hash, installs to %LOCALAPPDATA%\kbcode, adds it to your user PATH, and installs the Chrome extension. Open a new terminal and run kb --version to verify.
2 Chrome Extension
kbcode drives your real Chrome — your profile, your logins, your sessions. The extension is the bridge that makes that possible, and there is no Playwright/Selenium fallback by design.
The extension is published in the Chrome Web Store — install it in one click and Chrome keeps it updated automatically:
kb extension
Running kb extension opens the store page for you. (Or install it directly: extension page →.)
The extension is optional — kbcode works without it. Install it any time you like; you only need it when you want browser automation.
Why an extension, and not Playwright?
Every other agent launches a separate, logged-out browser: you re-login on every site, 2FA fires every time, and anything behind a session simply fails. The extension makes kbcode act inside the Chrome you already use — your profile, your cookies, your open tabs. That is why there is no Playwright/Selenium fallback: falling back would silently throw away the one thing that makes it work.
How it fits together
| Piece | What it does |
|---|---|
| The extension | Lives in Chrome. Reads the page, clicks, types — the “hands”. |
| The bridge | A local socket between kbcode and the extension. One port serves every profile (single-port multiplex) — /port shows it. |
| CDP fallback | When the extension cannot act (a chrome:// page, a strict CSP, a cross-origin frame), kbcode redoes the step over the Chrome DevTools Protocol and says so in the result. |
Multiple profiles stay connected at the same time. Nothing is closed or switched: each command names the profile it should run in, and the others keep their tabs and sessions.
The three commands
| Command | When |
|---|---|
kb extension | Install it — opens the Web Store page. |
kb extension doctor | A real check, not a reminder: per profile, whether Chrome loaded it, from which folder, which version, and whether the bridge socket is live. |
kb extension fix | Repairs a broken install, then re-runs doctor so you see the result. |
What kbcode can do in the browser
25 browser tools. You never call them by name — you describe the task and the agent picks — but this is the actual reach:
| Group | Tools | What it means |
|---|---|---|
| Start | launch | Open Chrome on the profile you name (by signed-in email), attaching to a debugging session you already started when there is one — a running Chrome is never closed. |
| Navigate & read | navigate read snapshot tabs frames | Open pages, scrape visible text, list interactable elements with ready-made CSS selectors, walk iframes. |
| Act | click type select scroll action | Click, fill forms (fires the events React/Vue listen for), dropdowns, plus 40+ extras via action: hover, drag, keypress, upload, copy/paste, back/forward, media control. |
| Synchronise | wait | Wait for an element, text, URL, or for a spinner to disappear — polling inside the page in one round-trip instead of re-checking in a loop. |
| Script | exec eval | Run arbitrary JS in the page — exec through the extension (works everywhere, CSP-safe), eval over CDP when you need the page's own globals. |
| See & diagnose | screenshot console dialogs events bridge declutter | Screenshots, the page's console errors, auto-answered alert/confirm history, the toasts and validation messages a page flashes then removes, bridge status, and hiding overlays/cookie bars that intercept clicks. |
Try it
kb extension # once
kb
open github, go to my notifications, and summarise the unread ones
Save and restore a whole browser state — tabs plus cookies, encrypted and local
only — with /session save <name> and /session restore.
When it does not work
| Symptom | Cause | Fix |
|---|---|---|
| “profile ... is not connected to this bridge” | That profile has no live extension | kb extension doctor, then open the profile |
| First browser command does nothing | Chrome suspends idle extensions | kbcode wakes it — just retry |
| Click does nothing on a React/MUI page | The element checks event.isTrusted | Automatic — kbcode retries over trusted CDP dispatch |
| Clicks land on a cookie banner | An overlay intercepts them | The agent clears overlays first, then clicks |
| You edited the extension files | Unpacked extensions do not hot-reload | Press Reload in chrome://extensions |
It is your real browser. The agent is acting as you — logged into your accounts. Watch what you approve, exactly as you would with shell commands.
3 Sign In
Register at kbcode.dev/register with email+password or Google. Then authenticate in the terminal — kb login asks you to choose:
kb login
- Browser login — opens
https://kbcode.dev/login; the token is sent back to your terminal automatically via a localhost callback. - Paste a token — copy your token from the dashboard (Copy token button) and paste it in the terminal. No browser needed.
Check your status: kb whoami • Sign out: kb logout
No browser / headless machine? The token paste path is first-class: open kbcode.dev/dashboard, click Copy token, and paste it when kb login asks. The same token works with kb login --token <jwt>.
If kb login says "server unreachable," ensure you have an internet connection and that no firewall is blocking outbound HTTPS on port 443.
4 Model Setup
Run the interactive wizard to pick your provider and model:
kb model
Choose from 15+ providers — Anthropic Claude, OpenAI, Google Gemini, xAI Grok, DeepSeek, Moonshot, OpenRouter, Mistral, Groq, Together, Qwen, Ollama (local), or any OpenAI-compatible API via Custom.
Your API key is Fernet-encrypted and machine-bound in ~/.kbcode/config.json — it goes to your provider and nowhere else.
Want to switch providers per project? Set KBCODE_PROVIDER in that project's .env or .kbcode/config.json. See Config & Precedence below.
5 Your First Task
Installed and signed in? Here is the whole loop, start to finish.
1. Teach kbcode your project — once
cd C:\path\to\your-project
kb init
This creates AGENT.md (your standing instructions, read every session)
and kb/ (short notes about your code). Then start the chat with kb
and type /init — kbcode reads the project and writes those notes.
Why it matters: without kb/, an agent re-reads your repo
every session and you pay for it in tokens and time. With it, kbcode answers from notes
and opens only the files a task actually touches. Session two is cheaper than session one.
2. Ask for something small and verifiable
add a --verbose flag to the CLI and a test for it
It states what it will do, reads the relevant files, asks permission before each edit or command, then runs the tests and reports the real result.
3. Do not like it? Undo
/undo
Every edit is checkpointed first, so undo always works. /diff shows exactly
what changed before you decide.
4. Make it remember
/learn # turn what we just did into a reusable skill
/kb # read or refresh the project knowledge base
/memory # durable facts across every session
A skill you teach once runs later in any session with /<name>.
6 Recipes
Complete workflows for real jobs — copy, paste, adapt.
Review a branch before you push
git diff origin/main... | kb "review this diff — correctness, edge cases, tests"
Piped input becomes context (50k cap, secrets redacted). Gotcha: plain
git diff shows only unstaged work.
Understand code without risking edits
/mode ask
how does session resume work, end to end?
In ask mode the write tools are not offered to the model at all — it
cannot change anything while explaining.
Plan before building
/mode architect
we need multi-tenant support — what are the options and trade-offs?
Then: write the chosen approach into kb/ as a note. Next session starts
already knowing the decision.
Start something brand new
/mode driven
I want to build a CLI that syncs my notes to S3
driven asks you the requirements first instead of guessing and building
the wrong thing.
Run a whole task unattended
kb -y "update every deprecated API call and run the tests"
Exit codes: 0 completed · 1 did not complete ·
2 usage error / not activated · 130 interrupted.
Gotcha: -y means full shell approval — do not use it on code you
have not read.
Automate a site with your real logins
kb extension # one time
kb
open github, go to my notifications, and summarise the unread ones
kbcode drives your Chrome — your profile, your sessions. Nothing to log into again.
Use a cheap model for grunt work
KBCODE_MODEL_TIERS={"planning":"claude-sonnet-4-5","editing":"deepseek-chat"}
Planning on a strong model, editing on a cheap one. Most agents lock you to one vendor; this is kbcode's biggest cost lever.
Run risky work in the background
/bg refactor the payment module to use the new API
Background tasks run in their own git worktree and land as a branch — your working
tree is untouched. /tasks lists them.
7 Common Mistakes
| Symptom | Cause | Fix |
|---|---|---|
| It re-reads everything and feels slow | You skipped kb init / /init | Build the kb/ notes once |
| It edited files you did not want touched | You were in code mode | /mode ask for questions; /undo to revert |
| Long session gets expensive | Context filled up | /compact, or start a fresh session |
| It asks permission constantly | Default is ask-mode | Shift+Tab, or run with -y |
| Answers ignore your conventions | Nothing told it | Write them in AGENT.md |
| It stopped saying "step limit" | KBCODE_MAX_STEPS reached | Say continue, or set KBCODE_MAX_STEPS=0 |
| CI passes even when the task failed | Old behaviour | One-shot runs now exit non-zero on failure |
| Nothing happens in CI, no error | Missing -y | Prompts cannot be answered headless — pass -y |
8 Terminal Commands
| Command | What it does |
|---|---|
kb | Start interactive chat in the current folder |
kb "task" | Run one task, print the answer, exit |
kb -y "task" | Same, but auto-approve all edits and commands |
kb -c | Continue the last session for this folder |
kb --resume [id] | Pick an older session from history |
kb --json "query" | Machine-readable JSON answer (no REPL) |
kb -C "path" "task" | Work on another project without cd |
kb init | Initialize project — creates AGENT.md + kb/ notes |
kb model | Run the provider + key + model wizard |
kb login / logout | Sign in or sign out |
kb whoami | Show signed-in email and auth method |
kb doctor | Health check — PATH, install, config, provider |
kb update | Self-update kb.exe to the latest version |
Piping context:
git diff | kb "review this change for bugs"
9 Slash Commands (In Chat)
Type /help inside the chat to see all 96 commands. Here are the
most-used ones — the full commands reference explains
what each one does, why you would use it, and how.
| Category | Commands |
|---|---|
| Undo & Review | /undo /rollback /diff /review /explain |
| Session & Cost | /status /context /compact /sessions /usage /cost |
| Model | /model /provider /thinking /temperature /fallback |
| Memory & KB | /kb /curate /kb-check /memory /skills /learn |
| Behaviour | /mode /auto /todo /worklog /agents /tools |
| Work | /commit /pr /bg /tasks /gate /open |
Skills you create with /learn become slash commands. E.g., /deploy runs your saved deploy workflow. See /skills to list them.
10 Keyboard Shortcuts
| Keys | Action |
|---|---|
Shift+Tab | Toggle auto-approve mode (all edits/commands run without asking) |
Esc | Interrupt a running tool or stop the agent mid-response |
Alt+V | Paste a screenshot from clipboard into the chat |
/ | Open slash-command autocomplete |
Ctrl+L | Clear the screen |
11 Modes
Switch modes with /mode <name> to apply tool guardrails. Each mode gets only the tools it needs:
| Mode | Tools | Use case |
|---|---|---|
code | All tools | Read, write, edit, and run commands (default) |
architect | Read-only + design | High-level planning & architecture |
ask | Read-only | Questions, explanations, code review |
debug | Read + run | Systematic failure triage & diagnosis |
driven | Read + ask | Requirements gathering before building |
pilot | Read + subagents | Autonomous subagent delegation |
orchestrator | Read + subagents | Multi-subagent coordination |
Full details: Modes reference page with all guardrails per mode.
12 Configuration & Precedence
Configure via .env in your project or global ~/.kbcode/.env:
KBCODE_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...
KBCODE_MODEL=claude-sonnet-4-5
Precedence (highest to lowest):
- Project
.kbcode/config.json— overrides everything for this project - Environment variables —
.envin the project root or launch folder - Global
~/.kbcode/config.json— your defaults across all projects - Built-in defaults — fallback when nothing else is set
Run kb doctor to see which config is active and where it's coming from.
13 MCP Tool Servers
Connect any stdio MCP server — its tools become built-in commands inside kbcode:
kb mcp-add my-server -- python -m my_mcp_server
kb mcp-remove my-server
MCP servers are configured per-project (.kbcode/settings.json) or globally (~/.kbcode/settings.json). kbcode also auto-detects installed servers (like ai-knowledgebase) at startup — no manual config needed.
After adding a server, its tools appear as mcp__<server>__<tool> in the agent's tool set. Run /tools to list them.
14 Safety & Privacy
- Checkpoints: Automated git snapshot before every edit.
/undoreverts the last turn instantly — nothing is lost. - Key Encryption: API keys are Fernet-encrypted and machine-bound in
~/.kbcode/config.json. They go only to your provider. - Secret Redaction: Logs, prompts, and feedback automatically strip API keys and credentials before touching disk or network.
- Untrusted Envelope: External web content (search results, fetched pages) is wrapped to block prompt-injection attacks.
- Tool Approval: Dangerous operations (writing files, running commands) require your explicit approval — kbcode never runs them silently unless you enable auto mode.
15 Troubleshooting / FAQ
'kb' is not recognized as an internal or external command?
PATH changes require a new terminal window. Open a fresh terminal and try again. If still stuck:
python -m kbcode fixpath
Or manually add %LOCALAPPDATA%\kbcode to your user PATH via System Properties → Environment Variables.
Do I need Python installed?
No. The installer sets up everything kbcode needs — Python is completely optional.
"Activation required" — what does this mean?
You need to sign in first. Run kb login and sign in with the account you registered at kbcode.dev/register. Only --version, login, logout, and doctor work without activation.
Login timeout — browser didn't open or timed out?
Visit kbcode.dev/dashboard in any browser, sign in, and copy your JWT token. Then paste it in the terminal:
kb login --token eyJh...
This works anywhere — SSH, headless servers, or when the localhost callback can't reach your terminal.
Browser automation isn't working?
Install the kbcode Chrome extension from the Chrome Web Store — run
kb extension and it opens the store page for you. Then check
kb extension doctor to verify Chrome loaded it and the bridge is connected.
How do I switch models mid-session?
Type /model inside the chat — it re-runs the model picker without losing your session context.