About KnightCode
A local, bring-your-own-key terminal coding agent. Install it from npm, run it in a repository, and connect a provider you already have.
What it is
KnightCode is a terminal coding agent. The knightcode command runs an interactive session, and the same agent is available in print, JSON, and RPC modes and through createAgentSession(). It starts with the read, bash, edit, and write tools; grep, find, and ls are built in and off until you enable them. Tools run with the permissions of the KnightCode process.
You bring the provider account. /login stores a credential, or you set an API key in the environment. OpenRouter is one of the built-in providers, next to direct adapters for Anthropic, OpenAI, Google, xAI, Groq, GitHub Copilot, Amazon Bedrock, and others. There is no KnightCode account and no bundled model subscription.
Who builds it
Mostly me - Raghav. I built it because I wanted a coding agent that runs in the terminal, talks to the provider I already pay, and does not spend tens of thousands of tokens on its own instructions before I type.
Contributions, bug reports, and feature requests are welcome on GitHub.
How it's built
The published command is @knightcodeai/cli. It depends on the other packages in this repository. @knightcode/ai is the provider layer: catalogs, API adapters, OAuth, and streaming.@knightcode/agent is the loop, the harness, compaction, session state, and the built-in tools. @knightcode/tui draws the terminal. @knightcode/durable is the Pico record runtime, with memory, JSONL, and SQLite storage. RPC is split across protocol, client, and server. SQLite session storage lives in its own package so the agent core does not require it. @knightcode/tools is the built-in extension for optional tools, the scratchpad, and the classifier gate. @knightcode/remote is remote sessions. Bun runs the repo from source. The website is a separate Next.js app.
- Node.js 22.19Published npm install
- @knightcode/tuiTerminal UI
- @knightcode/aiProviders, auth, streaming
- @knightcode/agentLoop, tools, compaction, sessions
- @knightcode/durablePico record storage
- protocol / client / serverRPC
- session-backend-sqliteSQLite session backend
- @knightcode/toolsOptional tools and the classifier gate
- @knightcode/remoteRemote sessions
What it isn't
- It isn't a hosted service. There's no KnightCode account.
- It isn't a bundled AI subscription. Provider usage is handled through your own key.
- It isn't a sandbox. Tools use the operating-system permissions of the process that started KnightCode. Project trust only decides whether a folder's settings, skills, and extensions load.
License
MIT. The license text, including third-party notices, is in the repository.