| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The terminal-native AI coding agent, powered by Klaatu smart model routing.
Claude Code-grade accuracy, at a fraction of the cost — and it's reproducible, not a marketing claim.
npm install -g klaatcode
klaatcodeKlaatAI is an AI platform built around Klaatu-o1, a small, fast, agentic router model. Instead of sending every request to one large, expensive model, Klaatu-o1 reads what you're asking, decides which model tier actually needs to handle it, and dispatches accordingly — automatically, per request. Three products sit on top of it: KlaatAI Web Chat (browser), Klaat Code (this CLI), and the KlaatAI API for developers building on the same router directly.
Klaatu is the routing brain — a hosted service, not something that runs on your machine. Every message you send from Klaat Code goes to Klaatu, which classifies it and routes it through one of six cost tiers (nano → fast → code → reason → heavy → titan), escalating automatically when a task turns out harder than it looked, and never charging you frontier prices for a trivial turn. Tool calls inside a single request — reads, edits, shell commands, searches — are free; only your messages count against quota. This is also the architectural reason Klaat Code can be open source without giving away the thing that makes it good: the client is a thin terminal to a service, the same relationship gh has to GitHub. The intelligence — routing decisions, model health tracking, pricing, the code-graph index — lives server-side, at klaatai.com.
Klaat Code is this repo: a terminal-native coding agent you install once and run in any project. It reads your code, edits files, runs commands, and verifies its own work — asking permission before anything risky. Functionally it sits in the same category as Claude Code, opencode, Codex CLI, and Aider — same agentic loop, same terminal-first philosophy — but six things are genuinely different:
What's new in each release: CHANGELOG.md.
Same 33 fixtures, same prompts, same verify command, run against KlaatCode, Claude Code, opencode, Cursor, and Grok Build in one harness. Full methodology and honesty notes: bench/README.md. Interactive version with per-task drill-down: klaatai.com/benchmarks.
Latest run — 2026-07-20, 33 tasks:
| Metric | Klaat Code (Klaatu-o1) | Claude (Sonnet 5) | Cursor (Composer 2.5) | Cursor (Composer 2.5 Fast) | opencode (Nemotron 3 Ultra) |
|---|---|---|---|---|---|
| Solved | 33/33 | 33/33 | 33/33 | 33/33 | 31/33 |
| Cost per solved task | $0.027 | $0.146 | ~$0.047 est | ~$0.094 est | ~$0.048 est |
| Tokens per solved task | 51.7K | 171.5K | ~86K | ~28.9K | 89.1K |
| Median time per task | 23s | 16s | ~113s | ~12s | 26s |
5.4× cheaper than Claude Code, 1.7× cheaper than the nearest rival, at a perfect solve rate — and no rival is both cheap and fast. Agents near our cost are ~5× slower (Composer 2.5 standard: ~113s/task vs our 23s) or drop tasks; agents near our speed cost 3.5–5.4× more. Promo-free and subsidized lanes are normalized to published per-token rates so the comparison reflects real token cost (details in the honesty notes). Grok Build's refresh on this suite is pending an API rate-limit window; on the previous 30-task suite it solved 30/30 at ~$0.058 est.
Reproduce it:
git clone https://github.com/KlaatAI/klaatcode.git && cd klaatcode
bun install
bun run bench # klaatcode
bun bench/compare-agents.ts --agent claude # or opencode / grok / cursorPick any method — all install a standalone compiled binary (no Node or Bun runtime required at runtime):
npm (Node ≥ 18 or Bun ≥ 1)
npm install -g klaatcodemacOS EACCES error? Prefix with sudo, or fix npm's global prefix once:
mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
One-line installer (macOS/Linux)
curl -fsSL https://klaatai.com/api/install | bashWindows (PowerShell)
irm https://klaatai.com/api/install-windows | iexHomebrew (macOS/Linux)
brew install KlaatAI/klaatcode/klaatcodeAll methods install both klaatcode and klaatai — identical commands, use whichever you like.
Shell completions (bash / zsh / fish)
# bash
klaatai completions bash >> ~/.bashrc
# zsh
mkdir -p ~/.zfunc
klaatai completions zsh > ~/.zfunc/_klaatai
# ensure fpath includes ~/.zfunc, then: autoload -Uz compinit && compinit
# fish
klaatai completions fish > ~/.config/fish/completions/klaatai.fishklaatcode login # browser sign-in — your KlaatAI account, no API keys to manage
klaatcode # open current directory
klaatcode ~/projects/my-app # open a specific project
klaatcode run "Fix all TS errors" # headless / CI mode
klaatcode whoami # check authEach request is classified and routed to one of five auto-routed tiers by Klaatu (a sixth, titan, is opt-in only). You see which tier answered (badge in the header) and why.
/tier # lock a tier, or open the picker /tier smart # restore automatic routing /model # switch between Klaatu and your own third-party models /why # explain the last routing decision /cost # session spend + what routing saved you
| Tier | Used for |
|---|---|
| nano | Trivial turns, completions |
| fast | Quick questions, small edits |
| code | Default — most coding work |
| reason | Debugging, architecture, tricky logic |
| heavy | Large refactors, hardest problems |
| titan | Kimi K3 (2.5T) — frontier power. Ask for it with /tier titan, or let the router escalate into it from heavy; it is never inferred from a prompt's wording. Pro and above, capped per day (Starter only during a promo window). |
The router escalates automatically when a task turns out harder than it looked and de-escalates when you don't need the big guns. The ladder is nano → fast → code → reason → heavy → titan: titan is the top rung, reachable by asking for it by name and as the one step above heavy when a turn keeps failing or outgrows the context. It de-escalates back to heavy when your daily cap is spent. Tool rounds, retries, and failovers are never billed — one user message = one request.
Bring your own model. Don't want Klaatu for a task? Add any OpenAI-compatible endpoint and switch to it per-session:
/model add gpt4o https://api.openai.com gpt-4o env:OPENAI_API_KEY /model gpt4o
After a successful edit, Klaat Code runs your project's typechecker/linter on the changed file (auto-detects eslint/biome, ruff, gofmt, rubocop, swiftlint, phpstan/pint, ktlint, shellcheck, or a configured command) and hands any errors straight back to the model in the same turn — it fixes them before returning control to you, instead of costing you a round-trip.
Markdown responses render with per-language syntax highlighting directly in the terminal. Code blocks show language labels and are mouse-selectable (drag to auto-copy).
Switch to Plan mode (Tab) and the model gets only read-only tools — it researches and proposes a plan, you approve, it switches back to Build with the full toolset to implement. No accidental edits while you're just trying to think something through.
| Tool | What it does |
|---|---|
| read_file | Read files with line numbers, offset/limit for big files |
| write_file | Create/overwrite files (parent dirs auto-created) |
| edit_file / multi_edit | Surgical string replacement, single or batched atomic |
| apply_patch | Multi-file envelope-diff patch — add/update/delete/move, applied atomically |
| glob / grep / list_dir | Find files and search code |
| run_command | Execute shell commands (permission-gated) |
| web_fetch / web_search | Read pages, search the web |
| todo_write / todo_read | Persistent task list the agent maintains |
| ask_user | The agent can ask you a blocking multiple-choice question mid-task |
| delegate_task | Spawn a sub-agent for a scoped piece of work, optionally in the background |
| task_status | Check on or list background sub-agents |
| plan_exploration | Plan the optimal file-read order for a task from the code graph — before reading anything |
| project_graph_query | Query the code graph: symbols, callers, callees |
| project_semantic_search | Meaning-based code search (Pro) |
| file_outline | Symbol outline of a file without reading it all |
| impact_check | Blast-radius analysis: what breaks if this changes |
| browser_* | Navigate, read, and click pages (5 tools) |
The agent can delegate scoped work to sub-agents with their own context — keeping your main conversation small and cheap. Sub-agent tool rounds are free like all tool calls.
> explore the auth and billing modules, then implement token refresh ✻ delegate_task: "map auth module structure" … ✻ delegate_task: "map billing module usage of tokens" …
Sub-agents can also run in the background (background: true): you keep chatting while they work, a ◔ N bg agents chip tracks them, and results are injected into the conversation when they finish (task_status / /agents to check in).
Long sessions stay affordable without losing the thread:
The viral horror stories — $6,500 overnight bills, agents looping on the same failing call — can't happen here:
Every conversation is saved as a transcript in ~/.klaatai/sessions/.
/sessions # list saved sessions /resume <id> # pick up exactly where you left off /export # export session to Markdown (optional path) /share # alias for /export
Three-layer model — safe read-only tools run silently; everything else asks:
{
"allowed_commands": ["git status", "git diff *"],
"denied_commands": ["rm -rf /"],
"trusted_tools": ["read_file", "glob", "grep"]
}Full MCP client, both transports:
Manage live with /mcp.
/diff # show git diff /review # AI code review of current changes /commit # AI-generated commit message + confirm /undo # undo last AI file changes /checkpoint # snapshot project state /rollback # restore a checkpoint
Save prompts as .md files, invoke by name. Project skills in .klaatai/skills/, global in ~/.klaatai/skills/.
/skill list /skill fix-types /skill new fix-types # create in $EDITOR
Run shell commands on agent lifecycle events. Hooks receive a JSON payload on stdin (tool name, arguments, result) plus KLAATAI_* env vars, can be scoped with a matcher regex, and before_tool hooks can block a tool call (exit code 2, or print {"decision":"block","reason":"…"}).
// .klaatai/hooks.json
{
"after_message": ["afplay /System/Library/Sounds/Glass.aiff"],
"before_tool": [
{ "matcher": "run_command", "command": "./scripts/guard-shell.sh" }
],
"after_tool": ["notify-send \"$KLAATAI_TOOL_NAME done\""]
}Events: before_message · after_message · before_tool · after_tool
.klaatai/rules.md in your repo is injected into every session — coding standards, architecture notes, dos and don'ts. /init auto-generates one from your tech stack. AGENTS.md is also respected.
Custom tools as JavaScript modules — ~/.klaatai/plugins/*.js (global) or .klaatai/tools/*.js (project). /plugin list · /plugin reload.
This README covers the highlights. For every shell flag, slash command, config key, and MCP/hooks/skills detail: klaatai.com/docs.
| Command | Description |
|---|---|
| /help | Show all commands |
| /tier [name] | Lock a Klaatu routing tier, or open the picker |
| /model | Switch between Klaatu and custom third-party models |
| /why | Explain last routing decision |
| /cost | Session cost, burn rate, per-task + per-phase breakdown |
| /context | What's in the context window vs. compacted away |
| /compact | Summarize context to free the window |
| /diff [file] · /review [ref] · /commit | Git workflows |
| /undo · /checkpoint [label] · /rollback [id] | Safety nets |
| /test [args] | Run tests (auto-detects Bun/Vitest/Jest/pytest/Go/Cargo) |
| /skill <name> · /hooks | Skills and hooks |
| /init | Generate project rules from your stack |
| /sessions · /resume <id> · /export [path] · /share | Session management |
| /mcp | Manage MCP servers |
| /agents | List agent personas + running background sub-agents |
| /perms | Review tool permissions |
| /theme <name> · /vimmode on|off | UI |
| /logout | Sign out and clear stored credentials |
| /doctor | Diagnose auth, API, MCP, project health |
| /clear | Clear chat |
Typing / shows a live, fuzzy-filtered autocomplete strip for all of the above.
| Shortcut | Action |
|---|---|
| ctrl+p | Command palette |
| ctrl+r | Fuzzy history search |
| ctrl+v | Attach image from clipboard (screenshots) |
| ctrl+y | Copy last AI response |
| ctrl+b | Collapse/expand thinking blocks |
| ctrl+d | Quit |
| ctrl+c / esc | Cancel streaming |
| ctrl+x ctrl+e | Compose message in $EDITOR |
| @ | Fuzzy file picker — inserts file reference |
| !cmd | Run shell command, inject output |
| Tab | Switch Build / Plan mode |
| Mouse drag | Select + auto-copy |
| Key | Action |
|---|---|
| esc | NORMAL mode |
| i / a / A / I | INSERT mode |
| h / l | Move cursor |
| j / k | Scroll chat |
| w / b / e | Word motion |
| 0 / $ | Line start / end |
| dd / D | Clear input / kill to EOL |
| gg / G | Top / bottom |
| ctrl+u / ctrl+d | Half-page scroll |
klaatcode run "Summarise CHANGELOG.md" # streams to stdout
echo "Explain this function" | klaatcode run - # pipe input
klaatcode run "Fix type errors" --model fast # with options
klaatcode run "Security-check auth.ts" < auth.ts # in CI# GitHub Actions
- name: Fix lint errors
env:
KLAATAI_API_KEY: ${{ secrets.KLAATAI_API_KEY }}
run: klaatcode run --model code "Fix all ESLint errors and commit"klaatcode serve --port 4200klaatcode web serves a browser UI on top of the same server.
~/.klaatai/config.json:
{
"baseUrl": "https://api.klaatai.com",
"routingDisplay": "minimal",
"theme": "dark",
"vimMode": false
}| Key | Values | Description |
|---|---|---|
| routingDisplay | off / minimal / full | Routing detail in chat header |
| theme | see theme list above | UI theme |
| vimMode | true / false | Vim keybindings |
| sandbox | project / off | Write sandbox scope |
| diagnostics | on / off | Post-edit typecheck/lint feedback loop |
| customModels | array | Third-party OpenAI-compatible models (see /model add) |
| outputFilter | on / off | Noise-filter command output (progress bars, passing-test spam) before it costs tokens |
| attentionOrder | on / off | Arrange old history so the most relevant turns sit where models attend |
| maxSessionCost | USD number | Hard session cost cap — pauses agent rounds when reached |
| phaseBudgets | on / off | Per-phase token budgets; pause a stuck explore phase before it burns the budget |
| telemetry | on / off | Install-level reporting (see Staying up to date) |
Full reference, incl. every config key: klaatai.com/docs/configuration.
~/.klaatai/ credentials.json # auth tokens (never committed, never shared) config.json # user preferences permissions.json # tool permission rules mcp.json # global MCP servers mcp-oauth.json # cached OAuth tokens for remote MCP servers hooks.json # global lifecycle hooks sessions/ # saved session transcripts skills/ # global prompt skills (.md) plugins/ # custom tool plugins (.js) todos.json # persistent todo list .klaatai/ # project-level (in your repo) rules.md # project rules (injected every session) mcp.json # project MCP servers hooks.json # project lifecycle hooks skills/ # project prompt skills tools/ # project tool plugins (.js)
klaatcode checks for a newer release when it starts (cached 4h, fail-silent — offline never blocks a launch) and asks before doing anything:
Update available: v2.4.2 → v2.4.3 Update now? [Y/n]
Say yes and it upgrades through whichever channel installed it (npm, Homebrew, the install script, or the PowerShell installer), verifies the new binary actually reports the new version, and relaunches with your original arguments. Say no and it won't ask again for that release. If the upgrade command fails or the version doesn't change — usually a half-broken global install, or an old klaatcode-ai 1.x binary still winning on PATH — it falls back to a clean uninstall + reinstall, then tells you exactly what to run if even that fails. It never leaves you without a working CLI.
klaatcode upgrade # upgrade now
klaatcode upgrade --check # just report what's available
klaatcode --no-update-check # skip the check for this runOpt out permanently with KLAATAI_NO_UPDATE=1. The check is skipped automatically in CI and any non-interactive shell — those print one line to stderr instead of prompting.
Very old builds can be refused by the server (HTTP 426) after a breaking protocol change, with the upgrade command in the response. That floor is off unless a release note says otherwise; KLAATAI_SKIP_VERSION_GATE=1 bypasses the client-side check at your own risk.
Every request carries four headers so we can tell how many installs are live and which builds are still out there:
| Header | Example | Why |
|---|---|---|
| X-KlaatAI-Client-Version | 2.4.3 | Version adoption; enforcing the minimum supported build |
| X-KlaatAI-Platform | darwin-arm64 | Which platforms need testing/builds |
| X-KlaatAI-Install-Channel | npm | Which install channel to fix when upgrades fail |
| X-KlaatAI-Install-Id | random UUID | Counting installs — one chatty user is not a thousand installs |
The install id is a random UUID generated once and stored in ~/.klaatai/install-id. It is not derived from your machine — no hostname, no MAC address, no hardware hash — and it identifies an install, not a person or a device. Nothing about your project is ever included: no paths, no repo names, no file names, no prompt or code content. Coarse country/city is derived server-side from the connecting IP, the same as any web request.
Opt out and no install id is sent at all, so no per-install record exists:
export KLAATAI_TELEMETRY=0 # or DO_NOT_TRACK=1or in ~/.klaatai/config.json:
{ "telemetry": "off" }Version and platform still travel when you opt out — the server needs them to refuse unsupported builds and route around version-specific bugs.
Sign-in is browser-based OAuth against your KlaatAI account — there are no API keys to generate or paste. klaatcode login opens a browser tab, you authenticate with KlaatAI, and a short-lived JWT plus refresh token are stored locally in ~/.klaatai/credentials.json (mode 0600, never synced or logged). The CLI silently refreshes the token in the background and recovers automatically from expiry mid-session; klaatcode logout clears everything. Every chat request goes straight to Klaatu over HTTPS with that token — the server enforces your plan's quota and never proxies your credentials anywhere else.
We welcome contributions — see CONTRIBUTING.md for dev setup, the PR process, and what bun run bench:selfcheck needs to pass before a PR is reviewed.
Found a vulnerability? Please don't open a public issue — see SECURITY.md for how to report it responsibly.
Apache License 2.0 © KlaatAI — see LICENSE.
The KlaatAI, Klaat Code, and Klaatu names and logos are trademarks of KlaatAI and are not covered by this license — see LICENSE for the trademark notice.
| Back | FazBrowse Home | New Git URL |