AI agents

Kimi Code CLI

Configuration

Files and locations

FilePurpose
~/.kimi-code/config.tomlMain user config (created on first run)
~/.kimi-code/tui.tomlTerminal UI preferences
~/.kimi-code/mcp.jsonMCP server definitions (see MCP: Connecting Servers to Kimi Code)
<project-root>/.kimi-code/local.tomlProject-local: only [workspace] additional_dir (absolute paths; add to .gitignore)

KIMI_CODE_HOME relocates the entire data root (~/.kimi-code/) — it is resolved before all other configuration. Note that generic cross-tool resources (~/.agents/skills/, ~/.agents/AGENTS.md) live in the real OS home and do not move with KIMI_CODE_HOME.

The docs state explicitly: “The CLI currently reads a single user-level config file and has no project-level config file mechanism” (beyond local.toml for workspace directories). TOML keys are snake_case; quote keys containing dots, e.g. [models."gpt-4.1"].

config.toml essentials

default_model = "k3"
default_permission_mode = "manual"   # manual | yolo | auto
default_plan_mode = false
merge_all_available_skills = true
extra_skill_dirs = ["~/team-skills"]
extra_agent_dirs = ["~/team-agents"]
builtin_product_skills = true
telemetry = true

[providers.kimi]
type = "kimi"
api_key = "sk-..."

[models."k3"]
provider = "kimi"
model = "k3"
max_context_size = 256000

[secondary_model]
default_model = "kimi-for-coding-highspeed"
force = false

[thinking]
enabled = true
effort = "high"        # low | medium | high | xhigh | max

[loop_control]
max_steps_per_turn = 0             # unset/0 = unlimited
max_attempts_per_step = 10

[permission]
dangerous_command_guard = true

[[permission.rules]]
decision = "deny"
pattern = "Bash(rm -rf*)"
reason = "never delete recursively without asking"

[[hooks]]
event = "PreToolUse"
matcher = "Bash"
command = "~/bin/my-hook.sh"
timeout = 30

Key field notes:

  • providers: type (required; one of kimi, anthropic, openai, openai_responses, google-genai, vertexai), api_key, base_url, oauth (auto-injected by login), env (sub-table of conventional key names as fallback), custom_headers.
  • models: provider (required), model (required), max_context_size (required), max_input_size, capabilities, default_effort, per-model base_url, display_name, and more.
  • secondary_model: the subagent model pool (stable since 0.40.0, enabled by default); force = true pins all subagents to default_model.
  • permission.rules: decision (allow/deny/ask), scope, pattern (ToolName or ToolName(arg-pattern)), reason; first match wins. See Permissions and Approvals.
  • hooks: only event, matcher, command, timeout (1–600 s, default 30) are allowed. Hooks are fail-open — do not rely on them as the sole security barrier.

Other documented tables: [background], [subagent], [swarm], [mcp], [identity], [tools] (global allow/deny lists), [image], [services.moonshot_search], [services.moonshot_fetch], [token_counting].

tui.toml

theme = "auto"            # auto | dark | light | custom
render_latex = true
disable_paste_burst = false

[editor]
command = "code --wait"

[notifications]
enabled = true
notification_condition = "unfocused"   # unfocused | always

[upgrade]
auto_install = true

[status_line]
items = ["mode", "goal", "model", "tasks", "cwd", "git", "tips"]

/reload-tui applies tui.toml changes immediately; /reload reloads both config files without restarting.

Environment variables

Highlights (full list on the env-vars docs page):

VariablePurpose
KIMI_CODE_HOMERelocate the entire data root
KIMI_DISABLE_TELEMETRY1/true/yes/y disables anonymous telemetry
KIMI_MODEL_NAME / _API_KEY / _PROVIDER_TYPE / _BASE_URL / _MAX_CONTEXT_SIZESynthesize a temporary in-memory provider (takes priority over default_model; -m still wins)
KIMI_CODE_OAUTH_HOSTOAuth host (default https://auth.kimi.com)
KIMI_CODE_BASE_URLCoding API base URL (default https://api.kimi.com/coding/v1)
KIMI_LOG_LEVELoff/error/warn/info/debug (default info)
KIMI_CODE_DANGEROUS_COMMAND_GUARDfalse disables the dangerous-command guard
KIMI_SUBAGENT_TIMEOUT_MSSubagent timeout (default 7200000 = 2 h)
KIMI_MCP_STARTUP_TIMEOUT_MS / KIMI_MCP_TOOL_TIMEOUT_MSMCP timeouts
KIMI_SHELL_PATHCustom Git Bash path on Windows
KIMI_DISABLE_CRON1 disables cron tools
HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXYStandard proxy support (SOCKS via scheme in ALL_PROXY)

Credentials come from config.toml, not the shell environment. Shell env vars are NOT read for provider credentials (exceptions: GOOGLE_APPLICATION_CREDENTIALS, read by the Google SDK directly, and the KIMI_MODEL_* family). Credential priority: [providers.<name>].api_key > [providers.<name>.env] sub-table > startup failure.

Override precedence

Not a simple stack — three roles:

  1. KIMI_CODE_HOME locates everything (runs before all other resolution).
  2. Runtime switches (e.g. KIMI_DISABLE_TELEMETRY) disable subsystems regardless of config (“additionally disable” semantics).
  3. Endpoint/diagnostic vars (KIMI_CODE_OAUTH_HOST, KIMI_CODE_BASE_URL, KIMI_LOG_LEVEL) are read at subsystem init.

For ordinary parameters: CLI options > user config file. Specific env vars override specific config fields where documented. Validate your files with kimi doctor (Terminal Commands (kimi)).


Last verified: 2026-09-07

Official sources:

AI coding tools evolve quickly. If you find outdated information, please open an issue or pull request.