# Docs - [KnightCode](/docs): KnightCode is an extensible AI agent that works from your terminal or the desktop app. Give it a goal and a working folder, and it can inspect files, run commands, edit... - [Quickstart](/docs/quickstart): KnightCode runs in your terminal and works with files on your machine. To use it, you need access to a model through a supported provider. This can be a subscription, an API... - [How KnightCode Works](/docs/how-knightcode-works): KnightCode coordinates model requests, tool execution, context assembly, and session storage. A session is KnightCode's record of a conversation, including messages, tool calls... - **Guides** - Run KnightCode - [Use KnightCode in the terminal](/docs/run/usage): Run knightcode from the folder you want to work in. KnightCode uses that folder to discover files, instructions, and configuration, and to group saved sessions. If you have not... - [Desktop App](/docs/run/desktop): The KnightCode desktop app is an Electron window over the app server. It runs one knightcode app-server process and every window talks to it, so the desktop and the terminal... - [Plan mode](/docs/run/plan-mode): Plan mode separates investigation from implementation. Enter with /plan, or send a task with /plan . The model explores, asks about unresolved trade-offs, and submits a... - [Choose a Model](/docs/run/models): For a built-in provider, start with /login, then choose a model with /model. Use custom model configuration only when KnightCode does not already include the provider or... - [Sessions and Context](/docs/run/sessions): KnightCode saves a conversation as a session. The active branch of that session supplies conversation history for the next model request. Use session commands to continue work,... - [Remote sessions](/docs/run/remote): /remote publishes the session running in your terminal to the web, so you can watch it and reply from another device. The terminal keeps working normally. - [Run KnightCode safely](/docs/run/security): Treat model-generated commands and code as untrusted. KnightCode can read, change, and execute files with the permissions of the account that started it, and it does not ask... - [Run KnightCode in an isolated environment](/docs/run/containerization): Use an isolated environment to limit the files, credentials, processes, and network services that generated commands can access or affect. - [Local Models with llama.cpp](/docs/run/llama-cpp): KnightCode supports the llama.cpp router server. The router discovers multiple GGUF models and loads or unloads them on demand. - [Run KnightCode with NVIDIA RTX and llama.cpp](/docs/run/nvidia-rtx-llama-cpp): NVIDIA Local AI Inference Recipes provides llama.cpp settings tuned for specific NVIDIA hardware and models. Each recipe gives a single-model llama-server command. KnightCode... - [Configure your terminal](/docs/run/terminal-setup): Most modern terminals work with KnightCode without additional setup. Use this page when modified keys, scrolling, links, images, colors, or input-method editor (IME)... - [Configure shell commands](/docs/run/shell-aliases): KnightCode starts a separate non-interactive shell process for each Bash command. Non-interactive Bash does not expand aliases by default and usually does not load the same... - [Run KnightCode in tmux](/docs/run/tmux): KnightCode works inside tmux, but tmux can report Shift+Enter, Ctrl+Enter, and plain Enter as the same key. Enable extended keys so KnightCode can distinguish them. - [Run KnightCode on Windows](/docs/run/windows): Run KnightCode either as a native Windows process or inside Windows Subsystem for Linux (WSL). Native Windows uses Git Bash by default for Bash commands and can optionally... - [Run KnightCode on Android with Termux](/docs/run/termux): KnightCode runs on Android through Termux, a terminal emulator and Linux environment. Text input, file tools, and shell commands are supported. KnightCode can copy and paste... - Customize KnightCode - [Configuration](/docs/customize/configuration): KnightCode supports user-level and project configuration. User-level configuration lives in the agent directory, which defaults to ~/.knightcode/agent. Project configuration... - [Prompt Templates](/docs/customize/prompt-templates): Prompt templates turn Markdown files into reusable / commands. Use one when you want to reuse the same prompt without adding executable behavior or a larger set of supporting... - [Skills](/docs/customize/skills): Skills give KnightCode specialized instructions and supporting files for a particular kind of work. KnightCode advertises each available skill by name and description, then... - [Customize KnightCode with themes](/docs/customize/themes): Themes control the colors KnightCode uses in interactive mode and HTML exports. KnightCode includes the system theme and the dark and light themes, warm grays with an orange... - [KnightCode Packages](/docs/customize/packages): KnightCode packages install and distribute extensions, skills, prompt templates, and themes as one unit. Use a package when a customization should be shared through npm or git,... - [MCP Servers](/docs/customize/mcp): KnightCode connects to Model Context Protocol servers over stdio or streamable HTTP and makes their tools and resources available to the model. - [Plugins](/docs/customize/plugins): KnightCode installs Claude Code and Grok Build plugins. A plugin's skills, slash commands, and MCP servers work in KnightCode; its hooks, agents, LSP servers, and output styles... - Build on KnightCode - [Extensions](/docs/build/extensions): > KnightCode can create extensions. Ask it to build one for your use case. - [Declarative Views](/docs/build/declarative-views): A view is a small tree of data that describes what to draw: text, markdown, a table, a progress bar, a button. An extension hands one to a widget, a tool result or an extension... - [Custom Providers](/docs/build/custom-provider): A provider extension connects KnightCode to a model service that needs custom authentication, model discovery, request handling, or streaming. If the service already speaks a... - [Virtual Models](/docs/build/virtual-models): A virtual model is a selectable model that picks a physical model for each request. Use one to route by task, cost, or conversation state. For example, a router can send quick... - [Terminal UI](/docs/build/tui): @knightcode/tui provides the terminal component system used by KnightCode. Extensions use it when built-in dialogs, notifications, status text, and widgets are not enough for... - [CLI Integration](/docs/build/cli-integration): By default, running knightcode opens the interactive terminal interface. When input or output is piped or redirected, KnightCode uses print mode instead. You can also select... - [SDK](/docs/build/sdk): @knightcodeai/cli embeds KnightCode in a Node.js or Bun process. It provides direct TypeScript access to the agent, sessions, tools, models, and resources used by the... - Reference - [Command Line](/docs/reference/cli): This page documents KnightCode's built-in command-line commands and options. Run knightcode --help or append --help to a command for the exact interface in your installed... - [Codemode](/docs/reference/codemode): The codemode tool lets the model write a JavaScript script that calls KnightCode's other tools and runs non-LLM models, such as decision models and image models. Only the... - [Slash commands](/docs/reference/slash-commands): Type / in KnightCode's terminal editor to search the commands available in the current session. This page lists the built-in commands in the current KnightCode release. - [Settings Reference](/docs/reference/settings): This reference lists user-configurable settings, their types, defaults, and purposes. Project settings override agent-directory settings. Resource lists are combined. See... - [Models Configuration](/docs/reference/models-configuration): This reference lists the fields of models.json. See Configure a compatible endpoint for examples and Configuration for the file location. - [Environment Variables](/docs/reference/environment-variables): KnightCode uses environment variables in three ways: - [Keybindings Reference](/docs/reference/keybindings): KnightCode exposes named actions, such as app.session.new, that can be assigned keybindings. You can change default assignments or bind unassigned actions in KnightCode's user... - [Providers](/docs/reference/providers): Most hosted providers support one or both of these authentication methods: - [Session File Format](/docs/reference/session-format): Sessions are stored as JSONL (JSON Lines) files. Each line is a JSON object with a type field. Session entries form a tree structure via id/parentId fields, enabling in-place... - [Compaction Reference](/docs/reference/compaction): This reference describes automatic compaction, branch summarization, persisted entries, and extension hooks. For the user workflow, see Sessions and Context. - [JSON Event Stream](/docs/reference/json): JSON mode emits structured progress for one invocation: - [RPC Mode](/docs/reference/rpc): RPC mode runs KnightCode as a long-lived subprocess controlled through JSON records on stdin and stdout. Use it for language-independent integrations, process isolation, IDEs,... - [RPC Commands](/docs/reference/rpc-commands): This reference lists commands accepted on stdin in RPC mode. Each command and response is one JSON object. Shared message values use the message types. - [RPC Extension UI](/docs/reference/rpc-extension-ui): Extensions can request user interaction through ctx.ui. In RPC mode, supported calls become a request/response subprotocol alongside normal RPC commands and session events. - [App Server](/docs/reference/app-server): knightcode app-server hosts many conversation threads in one process. The threads share models and credentials but own separate session files, extension runtimes, tools,... - [Message Types](/docs/reference/message-types): KnightCode uses AgentMessage values in SDK state, lifecycle events, RPC responses, and persisted session message entries. This page defines those shared messages and their...