Install and first run
Install KnightCode on macOS, Linux, or Windows, then run setup to connect your first provider.
KnightCode is distributed via npm and runs on Node.js (>=18). It includes pre-built platform binaries that are installed automatically as optional dependencies.
Installation
Install KnightCode globally using npm:
npm install -g @knightcodeai/cliAlternatively, you can run it without global installation using npx:
npx @knightcodeai/cliIf you prefer using Bun:
bun install -g @knightcodeai/cliFirst Run & Setup
To start a session, navigate to any repository folder in your terminal and launch the client:
knightcodeOn your very first run, KnightCode will guide you through an interactive onboarding wizard:
- Enter your OpenRouter API key: The key is checked against OpenRouter. A key that OpenRouter rejects is refused so you can retry, but the check is advisory — if OpenRouter can't be reached (e.g. you're offline, or it returns a network/server error), the wizard warns and continues with the key you entered. The key is stored in a local credentials file —
~/.knightcode/credentials.jsonby default, or under$KNIGHTCODE_HOMEif you've set that variable. On macOS and Linux the file is written with owner-only (0600) permissions; on Windows it follows the default filesystem permissions. - Pick a default model: Choose from a curated shortlist spanning free to frontier models (you can change it later with
/models). - Configure web search (optional): Enable web search by selecting a provider — Brave Search or Tavily — and entering its API key, or skip this step and add it later.
You can re-run this setup dialog at any time inside the app by executing the /setup command.
Build from Source
Prerequisites: Node.js (>=20), and Bun (used as package manager).
# Clone the repository and install dependencies
bun install
# Build the CLI package
bun run build:cli
# Link the package locally
bun run link:cliNow you can start a local development build with hot-reloads:
bun run dev:cli