Settings Reference
This reference lists user-configurable settings, their types, defaults, and purposes. Project settings override agent-directory settings. Resource lists are combined. See...
This reference lists user-configurable settings, their types, defaults, and purposes. Project settings override agent-directory settings. Resource lists are combined. See Configuration for file locations and trust behavior.
Add "$schema": "https://knightcode.dev/schemas/settings.schema.json" to settings.json for editor validation and completion.
Model and thinking
| Setting | Type | Default | Description |
|---|---|---|---|
defaultProvider | string | Automatic | Startup AI provider. Saved by Ctrl+S in /model. |
defaultModel | string | Automatic | Startup model ID. Saved by Ctrl+S in /model. |
defaultThinkingLevel | "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | "medium" | Startup thinking level. |
modelThinkingLevels | object | None | Per-model startup thinking levels keyed by exact provider/modelId. |
thinkingBudgets | object | Built-in budgets | Token budgets for minimal, low, medium, and high thinking levels. |
enabledModels | string[] | All available models | Model patterns used for startup selection and model cycling. Uses the same format as --models. |
hideThinkingBlock | boolean | false | Hide thinking blocks in the transcript. |
showCacheMissNotices | boolean | false | Show notices for significant cache misses, successful cache warming, compaction usage, and provider recovery. |
cacheWarming | "off" | "streaming" | "idle" | "streaming" | Keep eligible provider prompt caches warm during active runs or, with "idle", between runs. Global setting only. |
Cache warming runs only when the model declares a cache lifetime and KnightCode estimates at least $0.05 in avoided cache-miss cost. Refresh usage counts toward session totals but does not enter model context. /session shows the next decision; extensions can override it with cache_warming_decision. See Prompt Cache Lifetimes.
See Choose a Model for model selection and thinking controls.
Interaction
| Setting | Type | Default | Description |
|---|---|---|---|
steeringMode | "all" | "one-at-a-time" | "one-at-a-time" | How queued steering messages are delivered. |
followUpMode | "all" | "one-at-a-time" | "one-at-a-time" | How queued follow-up messages are delivered. |
externalEditor | string | $VISUAL, $EDITOR, then platform default | Command opened by the external-editor keybinding. |
doubleEscapeAction | "tree" | "fork" | "none" | "tree" | Action for double Escape with an empty editor. /undo is the quick way to a user message. |
treeFilterMode | "default" | "no-tools" | "user-only" | "labeled-only" | "all" | "default" | Initial filter used by /tree. |
defaultProjectTrust | "ask" | "always" | "never" | "ask" | Fallback project-trust behavior. Can only be set in agent-directory settings. |
Tools
| Setting | Type | Default | Description |
|---|---|---|---|
defaultTools | string[] | read, bash, edit, write | Tools enabled at startup. Plain names replace the defaults; +name adds a tool and -name removes one. An empty array disables all built-in tools but not extension or SDK tools. |
codemode.mode | "on" | "only" | "on" | How the codemode tool presents tools while it is active. on: declared tools get a note on calling them from scripts appended to their description, and codemode lists only tools that are not declared. only: codemode lists every tool scripts can call, and active built-in and extension tools are hidden from the model, so it reaches them through codemode. |
codemode.inlineBudget | number | 3000 | Estimated tokens (characters / 4) the codemode tool's description may spend on tool declarations. Tools that do not fit are left out and found with searchTools(). 0 lists only namespaces. |
Available built-in tools are read, bash, powershell, edit, write, grep, find, and ls. defaultTools can also name codemode and tool_search, which built-in extensions register inactive, and other extension tools registered inactive.
A list of only +name and -name entries changes the inherited selection instead of replacing it. For example, this enables codemode next to the default tools:
{
"defaultTools": ["+codemode"]
}This replaces bash with powershell and enables grep: ["-bash", "+powershell", "+grep"]. Project settings apply on top of user settings: a project list with only +name and -name entries changes the user's selection, and a project list with a plain name replaces it. In one list, plain names form the selection, and +name and -name then apply in order.
/reload enables tools newly added to defaultTools. It does not disable tools removed from it or re-enable unchanged tools you turned off. --tools with plain names, --no-tools, and --no-builtin-tools override defaultTools, also on reload.
CLI tool options override this setting for one invocation. --tools with only +name and -name entries changes the resolved defaultTools selection instead, for example knightcode --tools +codemode. On /reload, these entries apply to the reloaded setting too, so a tool removed with -name stays removed. See Command Line.
The web tools webfetch and websearch and the question tool ask_user are not part of the default defaultTools. /tools turns them on for the current session, which writes nothing to disk, or on or off by default, which is saved in ~/.knightcode/agent/tools.json together with the websearch provider and Brave key. Naming one in defaultTools also turns it on, unless /tools has it off.
Sessions and context
| Setting | Type | Default | Description |
|---|---|---|---|
sessionDir | string | Agent session directory | Session storage directory. Relative paths resolve from the working directory. KNIGHTCODE_CODING_AGENT_SESSION_DIR and --session-dir override this setting. |
sessionShareDestination | "auto" | "gist" | "radius" | "auto" | Destination used by /share. auto uses Radius when authenticated and otherwise creates a GitHub gist. gist always uses a gist. radius requires Radius authentication and never falls back to a gist. |
Compaction
| Setting | Type | Default | Description |
|---|---|---|---|
compaction.enabled | boolean | true | Enable automatic compaction. |
compaction.reserveTokens | number | 16384 | Free context tokens below which automatic compaction starts. |
compaction.keepRecentTokens | number | 20000 | Recent tokens retained without summarization. |
compaction.modelOverrides | object | None | Per-model token settings keyed by exact provider/modelId. |
Compaction token values must be non-negative safe integers. Each value resolves independently from the matching model override, then the ordinary compaction setting, then the built-in default. Project and user objects merge before model lookup.
See Compaction Reference for trigger, summarization, and validation behavior.
Branch summaries
| Setting | Type | Default | Description |
|---|---|---|---|
branchSummary.reserveTokens | number | 16384 | Tokens reserved when summarizing branch history. |
branchSummary.skipPrompt | boolean | false | Skip the branch-summary prompt and default to no summary. |
Terminal and display
| Setting | Type | Default | Description |
|---|---|---|---|
theme | string | "system" | Built-in or custom theme name. system derives colors from the terminal theme. |
quietStartup | boolean | "header" | false | true hides the startup header and loaded-resource listing. "header" keeps the header (version and key hints) but hides the model scope line and loaded-resource listing. |
tuiMode | "regular" | "fullscreen" | "fullscreen" | Interactive terminal UI mode. Fullscreen captures the mouse and owns text selection, so dragging copies to the clipboard; regular leaves selection and copying to the terminal emulator (see Text selection and copy). |
fullscreenExitOutput | "transcript" | "resume-hint" | "transcript" | Output printed when fullscreen mode exits. |
fullscreenScrollbar | "auto" | "always" | "hidden" | "auto" | Fullscreen transcript scrollbar behavior. |
fullscreenCopyOnSelect | boolean | true | Copy selected text automatically in fullscreen mode. When disabled, selections stay highlighted and Ctrl+X copies the active selection. Has no effect in regular mode. |
fullscreenWheelScrollLines | "auto" | number | "auto" | Lines per mouse-wheel event in fullscreen mode, from 1 to 100. "auto" moves one line per event in local macOS terminals, which already accelerate wheel and trackpad input; elsewhere, and over SSH, it speeds up fast wheel spins to at most 6 lines per event. Alt+wheel moves five times as far. |
editorPaddingX | number | 0 | Horizontal editor padding from 0 to 3 cells. |
outputPad | 0 | 1 | 1 | Horizontal transcript padding for messages, tool output, ! command output, and summary blocks. |
autocompleteMaxVisible | number | 5 | Visible autocomplete entries, from 3 to 20. |
showHardwareCursor | boolean | false | Use the terminal cursor instead of KnightCode's drawn cursor. KnightCode still positions it for input methods. |
terminal.showImages | boolean | true | Display inline images when supported. |
terminal.imageWidthCells | number | 60 | Preferred inline image width in terminal cells. |
terminal.clearOnShrink | boolean | false | Clear empty rows when rendered content shrinks. When unset, KNIGHTCODE_CLEAR_ON_SHRINK=1 enables it. |
terminal.showTerminalProgress | boolean | false | Show OSC 9;4 progress in the terminal tab. |
terminal.hyperlinks | boolean | "auto" | "auto" | Override OSC 8 hyperlink detection. |
terminal.images | "kitty" | "iterm2" | "auto" | false | "auto" | Override inline-image protocol detection. |
terminal.trueColor | boolean | "auto" | "auto" | Override true-color detection. |
images.autoResize | boolean | true | Resize images to at most 2000 by 2000 pixels before sending them to a model. |
images.blockImages | boolean | false | Prevent images from being sent to models. |
markdown.codeBlockIndent | string | " " | Prefix used to indent rendered code blocks. |
markdown.mermaid | "off" | "final" | "streaming" | "streaming" | Mermaid rendering mode. |
See Themes and Terminal Setup for format and platform details.
Worktrees
Worktree settings belong to the user: they are read from the agent-directory settings file only, never from a project's.
| Setting | Type | Default | Description |
|---|---|---|---|
worktrees.root | string | <agent dir>/worktrees | Absolute directory that holds managed worktrees as <root>/<4 hex digits>/<repository name>. Worktrees made under an earlier root are no longer managed. |
worktrees.autoDelete | boolean | true | Archiving a thread deletes its worktree, and the least recently used worktrees past worktrees.keep are pruned. Each deletion first keeps a snapshot under refs/knightcode/snapshots/. |
worktrees.keep | number | 15 | Managed worktrees kept before pruning starts. |
worktrees.fetchBeforeCreate | boolean | false | Fetch the base's remote before each new worktree. |
worktrees.branchPrefix | string | "kc/" | Prefix of the branch a handoff to the main checkout creates. |
Environments
A project's environments live in .knightcode/environments.json, which can be
committed:
{
"version": 1,
"environments": [
{
"name": "node",
"setup": { "default": "cd \"$KNIGHTCODE_WORKTREE_PATH\" && npm ci" },
"cleanup": { "default": "rm -rf \"$KNIGHTCODE_WORKTREE_PATH/.cache\"" },
"actions": [{ "name": "Test", "command": { "default": "npm test" } }]
}
]
}Each script has default, macos, linux and windows variants; the
platform's wins. Scripts run in bash on every platform (Git Bash on Windows, or
the shellPath setting), so one default usually covers all three; a platform
variant is for a command that differs. The setup script runs when a worktree is
created and the cleanup script before one is deleted, both at the project root,
with
KNIGHTCODE_SOURCE_TREE_PATH (the checkout the worktree came from) and
KNIGHTCODE_WORKTREE_PATH (the worktree) set. Since they start in the main
checkout, work on the worktree through KNIGHTCODE_WORKTREE_PATH, as the
example does: a bare npm ci would install into the main checkout. A failing setup keeps the
worktree and marks it setupFailed; a failing cleanup is a warning. An
untrusted project's scripts never run. actions are for the desktop app's
toolbar.
.worktreeinclude
Ignored files are not copied into a new worktree unless the repository root's
.worktreeinclude (gitignore syntax) lists them, such as .env. A file is
copied only if the worktree ignores it too, so it can never be committed or
handed off by accident, and nothing is created through a symlink or junction.
Network and retries
| Setting | Type | Default | Description |
|---|---|---|---|
transport | "auto" | "sse" | "websocket" | "websocket-cached" | "auto" | Preferred transport for AI providers that support multiple transports. |
httpProxy | string | None | Proxy URL applied as HTTP_PROXY and HTTPS_PROXY for KnightCode-managed HTTP clients. Can only be set in agent-directory settings. |
httpIdleTimeoutMs | number | "disabled" | 300000 | HTTP header and body idle timeout in milliseconds. Set to 0 or "disabled" to disable. |
websocketConnectTimeoutMs | number | "disabled" | 15000 | WebSocket connection timeout in milliseconds. Set to 0 or "disabled" to disable. |
retry.enabled | boolean | true | Enable automatic agent-level retry for transient failures. |
retry.maxRetries | number | 3 | Maximum agent-level retry attempts. |
retry.baseDelayMs | number | 2000 | Initial exponential-backoff delay in milliseconds. |
retry.maxAgentDelayMs | number | 60000 | Maximum agent-level retry delay in milliseconds. |
retry.provider.timeoutMs | number | httpIdleTimeoutMs | Provider request timeout in milliseconds. |
retry.provider.maxRetries | number | 0 | Provider-level retry attempts. |
retry.provider.maxRetryDelayMs | number | 60000 | Maximum server-requested delay in milliseconds. Set to 0 to disable the limit. |
Keep retry.provider.maxRetries at 0 unless provider-level retries are required. Provider retries can delay KnightCode from handling quota and usage-limit errors itself.
Shell
| Setting | Type | Default | Description |
|---|---|---|---|
shellPath | string | Platform default | Custom shell executable path. Supports a leading ~. |
shellCommandPrefix | string | None | Prefix prepended to every shell command. |
npmCommand | string[] | npm | Command and arguments used for npm package lookup and installation. |
See Shell aliases for shell setup and KnightCode Packages for package-manager behavior.
Resources
Resource paths in user settings resolve from the agent directory. Paths in project settings resolve from the project .knightcode directory. Absolute paths and ~ are supported.
| Setting | Type | Default | Description |
|---|---|---|---|
packages | array | [] | npm, git, or local KnightCode package sources. See KnightCode Packages. |
extensions | string[] | [] | Extension files or directories. |
skills | string[] | [] | Skill files or directories. |
prompts | string[] | [] | Prompt-template files or directories. |
themes | string[] | [] | Theme files or directories. |
enableSkillCommands | boolean | true | Register skills as /skill:name commands. |
Resource arrays support glob exclusions with !pattern, exact inclusion with +path, and exact exclusion with -path. KnightCode loads resources listed in both user-level and project settings.
The built-in extensions are named builtin:mcp, builtin:llama.cpp, builtin:codemode, and builtin:tool-search in extensions. They load by default; -builtin:mcp disables one. A +builtin:<name> or -builtin:<name> entry in project settings overrides the user setting. knightcode config lists them under Built-in. --no-extensions disables them too, and -e builtin:<name> loads one explicitly.
Updates, telemetry, and warnings
| Setting | Type | Default | Description |
|---|---|---|---|
autoUpdate | boolean | true | Download KnightCode CLI updates automatically while retaining update notices when false. Can only be set in agent-directory settings. KNIGHTCODE_DISABLE_AUTO_UPDATE=1 overrides this setting. See Disable automatic updates. |
collapseChangelog | boolean | false | After an update, show a one-line notice instead of the top three changes. |
enableInstallTelemetry | boolean | true | Enable anonymous install/update reporting and selected provider attribution headers. Does not control update checks. |
enableAnalytics | boolean | false | Opt in to analytics data sharing. Currently used only by the experimental first-run setup. |
warnings.anthropicExtraUsage | boolean | true | Warn when Anthropic subscription authentication may use paid extra usage. |
Disable automatic updates
Automatic updates are on by default. Open /settings, search for
Automatic updates, and change it from true to false. KnightCode saves the
preference in your user-level settings.json; no restart or /reload is needed.
It applies to subsequent update checks and does not cancel a download already
running. Change it back to true in /settings to re-enable automatic updates.
Alternatively, add "autoUpdate": false to your user-level settings.json:
- Windows:
%USERPROFILE%\.knightcode\agent\settings.json - macOS / Linux:
~/.knightcode/agent/settings.json
{
"autoUpdate": false
}Create the file if it does not exist; otherwise add this property to the existing
JSON object, keeping your other settings. If KNIGHTCODE_CODING_AGENT_DIR overrides
the agent directory, use settings.json in that directory instead. Project-local
.knightcode/settings.json cannot override this preference.
KnightCode still checks for new versions and shows update notices, but does not
download or install updates automatically. Run knightcode update whenever you
want to update manually. Set autoUpdate to true, or remove it, to restore
automatic updates.
After manually editing the file, restart KnightCode or run /reload. The new preference
applies to subsequent update checks; it does not cancel a download already running.
Environment variables are optional alternatives, set in the shell or operating
system environment before launching KnightCode, not inside settings.json:
KNIGHTCODE_DISABLE_AUTO_UPDATE=1disables automatic downloads even whenautoUpdateistrue. Unset the variable to let the setting control downloads again. The updater treats any non-empty value as disabling, including0.KNIGHTCODE_SKIP_VERSION_CHECK=1disables both automatic checks and downloads.
Neither variable blocks explicit knightcode update. Offline, print, JSON, and
RPC sessions never start background updates. See Command Line
for update behavior and Environment Variables
for shell examples.
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.
Models Configuration
This reference lists the fields of models.json. See Configure a compatible endpoint for examples and Configuration for the file location.