Skip to content

About

Open-source coding agent for the terminal, with a desktop IDE. Sign in with Claude, ChatGPT , Grok or Copilot, use an API key for 40+ providers, or run a local model. The system prompt is ~1,100 tokens, and you can continue a session from your phone.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

KnightCode

A local, BYOK terminal coding agent. Bring your own OpenRouter key (or any of ~39 other providers) and run an agent that reads files, runs commands, edits code, and writes new files — with a token floor of roughly 1,100 tokens per request instead of the 20k+ typical of hosted agents.

curl -fsSL https://knightcode.dev/install.sh | sh
export OPENROUTER_API_KEY=sk-or-...
knightcode

On Windows, install with powershell -c "irm https://knightcode.dev/install.ps1 | iex". The installer pins all dependencies and updates KnightCode with knightcode update. Alternatively, install with npm, which does not pin transitive dependencies: npm install -g --ignore-scripts @knightcodeai/cli.

There is also a desktop app for Windows, macOS and Linux. It runs the same agent and shares sessions and settings with the terminal: download it from knightcode.dev.

Why

Most terminal agents spend 20–25k tokens on tool descriptions and system prompt before you type anything. On a 200k model that is over 10% of the window every turn, and open-weight models on gateways mostly do not get prompt caching — so you pay it in latency and cash on every request. KnightCode's floor is ~1,100 tokens, measured.

Layout

Package What it is
packages/cli The knightcode binary — CLI, TUI mode, print mode, RPC mode, sessions, extensions, skills
packages/ai Multi-provider LLM layer: ~39 providers, 20 API adapters, OAuth, model catalog
packages/agent Agent loop, proxy stream, and their types
packages/durable Durable conversation, task and document runtime (Pico)
packages/tui Terminal UI library with differential rendering
packages/telemetry Vendor-neutral telemetry contracts
apps/desktop The desktop app: an Electron window over knightcode app-server

Development

bun install
bun run check-types          # tsc --noEmit across every package
bun run start                # run from source
bun run build:cli            # build the Node bundle npm ships (packages/cli/dist)
bun run build:binary         # compile the standalone release binary for this platform

Source runs directly under Bun — there is no build step for development. The root tsconfig.json maps every @knightcode/* specifier to package source.

Configuration

Config lives in .knightcode/ (project) and ~/.knightcode/ (user). Provider keys come from the environment (OPENROUTER_API_KEY, ANTHROPIC_API_KEY, …) or from knightcode auth. Run knightcode --help for flags and packages/cli/docs/ for the full documentation.

License

MIT — see LICENSE, which also carries the notices for the third-party code included in this distribution.

About

Open-source coding agent for the terminal, with a desktop IDE. Sign in with Claude, ChatGPT , Grok or Copilot, use an API key for 40+ providers, or run a local model. The system prompt is ~1,100 tokens, and you can continue a session from your phone.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages