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

PieceWhat it does
The extensionLives in Chrome. Reads the page, clicks, types — the “hands”.
The bridgeA local socket between kbcode and the extension. One port serves every profile (single-port multiplex) — /port shows it.
CDP fallbackWhen 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

CommandWhen
kb extensionInstall it — opens the Web Store page.
kb extension doctorA 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 fixRepairs 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:

GroupToolsWhat it means
StartlaunchOpen 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 & readnavigate read snapshot tabs framesOpen pages, scrape visible text, list interactable elements with ready-made CSS selectors, walk iframes.
Actclick type select scroll actionClick, 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.
SynchronisewaitWait 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.
Scriptexec evalRun 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 & diagnosescreenshot console dialogs events bridge declutterScreenshots, 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

SymptomCauseFix
“profile ... is not connected to this bridge”That profile has no live extensionkb extension doctor, then open the profile
First browser command does nothingChrome suspends idle extensionskbcode wakes it — just retry
Click does nothing on a React/MUI pageThe element checks event.isTrustedAutomatic — kbcode retries over trusted CDP dispatch
Clicks land on a cookie bannerAn overlay intercepts themThe agent clears overlays first, then clicks
You edited the extension filesUnpacked extensions do not hot-reloadPress 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
  1. Browser login — opens https://kbcode.dev/login; the token is sent back to your terminal automatically via a localhost callback.
  2. 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

SymptomCauseFix
It re-reads everything and feels slowYou skipped kb init / /initBuild the kb/ notes once
It edited files you did not want touchedYou were in code mode/mode ask for questions; /undo to revert
Long session gets expensiveContext filled up/compact, or start a fresh session
It asks permission constantlyDefault is ask-modeShift+Tab, or run with -y
Answers ignore your conventionsNothing told itWrite them in AGENT.md
It stopped saying "step limit"KBCODE_MAX_STEPS reachedSay continue, or set KBCODE_MAX_STEPS=0
CI passes even when the task failedOld behaviourOne-shot runs now exit non-zero on failure
Nothing happens in CI, no errorMissing -yPrompts cannot be answered headless — pass -y

8 Terminal Commands

CommandWhat it does
kbStart 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 -cContinue 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 initInitialize project — creates AGENT.md + kb/ notes
kb modelRun the provider + key + model wizard
kb login / logoutSign in or sign out
kb whoamiShow signed-in email and auth method
kb doctorHealth check — PATH, install, config, provider
kb updateSelf-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.

CategoryCommands
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

KeysAction
Shift+TabToggle auto-approve mode (all edits/commands run without asking)
EscInterrupt a running tool or stop the agent mid-response
Alt+VPaste a screenshot from clipboard into the chat
/Open slash-command autocomplete
Ctrl+LClear the screen

11 Modes

Switch modes with /mode <name> to apply tool guardrails. Each mode gets only the tools it needs:

ModeToolsUse case
codeAll toolsRead, write, edit, and run commands (default)
architectRead-only + designHigh-level planning & architecture
askRead-onlyQuestions, explanations, code review
debugRead + runSystematic failure triage & diagnosis
drivenRead + askRequirements gathering before building
pilotRead + subagentsAutonomous subagent delegation
orchestratorRead + subagentsMulti-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):

  1. Project .kbcode/config.json — overrides everything for this project
  2. Environment variables.env in the project root or launch folder
  3. Global ~/.kbcode/config.json — your defaults across all projects
  4. 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. /undo reverts 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.