A single-binary terminal agent from the lab behind the Kimi K-series: three permission modes, a plan mode that writes only the plan, goals that persist across turns, swarms of item-based subagents, and a local web UI and ACP server on the same engine. It reads the same AGENTS.md and ~/.agents/ layout as every other agent, and imports Claude Code and Codex configuration in one command. Guide cards explain the mechanisms; the index below is a searchable dictionary of every command, flag, slash command, config key, hook event and tool.
A terminal coding agent from Moonshot AI: reads and edits files, runs shell commands, searches with a bundled ripgrep, fetches the web, plans, and applies changes after you approve. Written in TypeScript, shipped as a single binary (no Node needed), open source at MoonshotAI/kimi-code. The command is kimi.
| Mechanism | What it gives you |
|---|---|
| Three permission modes | manual · yolo (still asks about .env, SSH keys, plan exit) · auto (never asks) |
| Plan mode | Write/Edit restricted to the plan file; exit needs your approval even in YOLO |
/goal | A persistent objective the agent works toward across turns — complete, blocked or paused |
/swarm · AgentSwarm | One prompt template × N items → N parallel subagents |
| Web UI · ACP · REST | The same engine in a browser, in Zed/JetBrains, or behind an API |
| Video input | Paste a clip; the model reads it. Unusual among agents |
Authenticate with a Kimi Code plan (OAuth, kimi.ai global or kimi.com mainland) or a Kimi Platform API key; or point a provider at Anthropic, OpenAI, Google or any OpenAI-compatible endpoint.
The 30-second orientation: install, /login, /init to generate an AGENTS.md (or /import-from-cc-codex if you already have Claude Code config), then a real task with Shift-Tab plan mode on.
The script puts kimi in ~/.kimi-code/bin/ and adds it to your shell profile — so it is not on the PATH in non-interactive shells until you source the profile or use the absolute path. On Windows it runs in the bundled Git Bash; set KIMI_SHELL_PATH if Git is somewhere unusual.
Two products install a binary called kimi. This is Kimi Code CLI (package @moonshot-ai/kimi-code, home ~/.kimi-code/). The older Python kimi-cli is the legacy one; kimi migrate pulls its sessions across.
/login → Kimi Code (OAuth device code) or Platform API key. Then /init analyses the codebase and writes AGENTS.md. Read-only tools run without asking; the first write shows an approval panel with approve for this session.
| Mode | Runs without asking |
|---|---|
manual (default) | Read-only tools: Read, Grep, Glob, ReadMediaFile, WebSearch, FetchURL, task queries |
yolo · -y | Regular tool calls. Still asks for sensitive files (.env, SSH keys), plan-mode exit, and questions to you |
auto · --auto | Everything, including sensitive files and plan exits. The agent never asks. What -p uses |
Switch with /permission, /yolo, /auto; set a default with default_permission_mode. --yolo and --auto are mutually exclusive; -p accepts neither.
Matched in order; Bash(command-pattern), Read(path-pattern), mcp__github__* with */**. Static deny rules apply in -p and YOLO alike. "Always allow" choices made in the approval panel propagate to subagents.
Trust prompt. A new folder is untrusted until you say otherwise; project-level MCP servers and hooks are shown in the prompt, which defaults to Don't trust. A cloned repo's .kimi-code/ can replace the main agent — read it first.
Shift-Tab or /plan. The agent explores with read-only tools and writes a plan; Write/Edit are restricted to the plan file and TaskStop is blocked; Bash follows the normal rules. ExitPlanMode presents the plan — with up to three alternative approaches — and needs your approval even in YOLO; only auto self-approves. /plan clear discards it; default_plan_mode = true starts every session in it.
A goal says what must become true, not what to do next. After every turn Kimi checks: complete (clears and summarises), blocked (needs input, impossible, or budget hit — writes why), or paused (you, an interrupt, a resume, or an error). Name the finish line and the evidence; write stop conditions into the text — there is no separate limit flag. 4 000-character cap.
Good goals: a failing suite to make green, a build to fix at the root cause, an ordered list of artifacts that must exist. Bad goals: "find all bugs", "greetings", "make a game in one file". A fork does not carry the goal.
| Built-in | Can |
|---|---|
coder (default) | Read, write, run, search — most of the main agent's tools; cannot spawn further subagents |
explore | Read-only. Survey a repo without touching it |
plan | Planning only — no shell at all |
The main agent dispatches on its own (each dispatch is an approval unless allowed), or you say "use explore to map the auth code". Each subagent has its own context; only its final message returns. /tasks shows background ones live; /btw forks a side conversation that never touches the main turn.
AgentSwarm takes a prompt_template with {{item}} and an items list; one subagent per item, in parallel, with rate-limit-aware retries and a live progress card. /swarm on|off toggles the mode; /swarm <task> runs one and turns it off after. From manual it offers to switch to auto or yolo first. Cap the ramp with KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY.
A Markdown file with frontmatter — name, description, tools, disallowedTools, subagents — and a body that is the system prompt. A reviewer with tools: [Read, Grep, Glob] cannot edit: the list is enforced before execution, not just shown to the model. Run one as the main agent with --agent reviewer. Subagent timeout 2 h ([subagent] timeout_ms).
| Scope | Skills | Agents |
|---|---|---|
| Project | .kimi-code/skills/ · .agents/skills/ | .kimi-code/agents/ · .agents/agents/ |
| User | ~/.kimi-code/skills/ · ~/.agents/skills/ | ~/.kimi-code/agents/ · ~/.agents/agents/ |
| Extra | extra_skill_dirs | extra_agent_dirs |
| Built-in / plugin | lowest | plugin beats built-in |
Project beats user beats extra beats built-in. The generic ~/.agents/ directories are shared with other tools and stay under the real home even when KIMI_CODE_HOME moves everything else.
name and description are required in a SKILL.md. Invoke as /skill:release-notes v1.2, or just /release-notes if no system command owns the name; sub-skills appear as /parent.child. Type / after whitespace to stack several skills in one prompt. Nesting 3 deep. $ARGUMENTS, $0, $name, ${KIMI_SKILL_DIR} expand in the body.
/plugins — Installed · Official · Curated · Custom tabs; install from a GitHub URL, zip or path. Bundle skills, agents, MCP servers and instructions. Per-user only; /reload after changes. Official: Kimi Datasource (market, macro, academic and Chinese government data), WebBridge (drive your browser), Computer Use (macOS/Windows desktop).
Event JSON arrives on stdin (hook_event_name, session_id, cwd, plus tool_input etc.). Exit 2 blocks and stderr becomes the reason the model sees; exit 0 allows and stdout may be appended to context; any other exit, a crash or a timeout allows. Or return {"hookSpecificOutput":{"permissionDecision":"deny",…}}.
| Blockable | Observation only |
|---|---|
PreToolUse · Stop · UserPromptSubmit | PostToolUse · PostToolUseFailure · PermissionRequest/Result · SessionStart/End · SessionHeartbeat · SubagentStart/Stop · TaskStarted · TurnStarted · StopFailure · Interrupt · PreCompact/PostCompact · Notification · UserPromptQueued |
Fail-open is the point to remember. A hook that errors lets the call through, so hooks are for alerts and lightweight interception — the docs say so. The hard guarantee is a deny permission rule or an agent tools list. Stop is the one to hang a test run on: block it and the model keeps working.
kimi --resume … goes to the clipboard
/btw [q]side question in a forked sub-agent; never enters history
/usage · /statustokens, context, quota · version, model, cwd, mode
/sessions · /titlebrowse and resume · rename (200 chars)Auto-compaction fires when the remaining window drops below [loop_control] reserved_context_size. Sessions live under ~/.kimi-code/sessions/<workDirKey>/<id>/ as wire.jsonl event streams — do not edit them; kimi export zips one for a bug report, /export-md writes it as Markdown, kimi vis replays it in a browser.
Instructions: the project's AGENTS.md; global Kimi-specific ~/.kimi-code/AGENTS.md; cross-tool ~/.agents/AGENTS.md. ~/.kimi-code/SYSTEM.md replaces the system prompt outright (${base_prompt}, ${agents_md}, ${skills} placeholders).
The cache-expiry hint: resume after a long idle and the TUI warns the prompt cache has likely expired and offers to compact or start fresh. That dialog is a bill-saver — cached input on K2.7 is a fifth of the fresh price.
The web UI adds what a TUI cannot: sidebar tabs, a session manager, a goal strip with a token-budget bar, swarm cards, Cmd+K search, and GET /openapi.json for the REST API. --host binds all interfaces — only behind your own TLS proxy; --dangerous-bypass-auth means what it says. kimi web rotate-token revokes the old token everywhere.
Print mode stays alive for background tasks: with [background] print_background_mode = "steer" (default) each completion re-enters the agent as a synthetic message until nothing is pending. Set "exit" for a pure one-shot.
Zed: agent_servers → {"command":"kimi","args":["acp"]}; GUI-launched IDEs do not inherit the shell PATH, so use the absolute path to ~/.kimi-code/bin/kimi.
| Model | Ctx | In $/M (hit) | Out $/M |
|---|---|---|---|
| Kimi K3 | 1M | 3.00 (0.30) | 15.00 |
| Kimi K2.7 Code | 256k | 0.95 (0.19) | 4.00 |
| Kimi K2.6 | 256k | 0.95 | 4.00 |
| Kimi K2.5 | 256k | 0.60 | 3.00 |
Platform API prices. A Kimi Code plan (from about $19/month) provisions kimi-code/k3, kimi-for-coding and -highspeed under the managed:kimi-code provider against a quota instead; /usage shows what is left. K3 declares support_efforts = [low, high, max]; the rest think at one level.
The subagent model pool ([secondary_model], experimental: KIMI_CODE_EXPERIMENTAL_SECONDARY_MODEL=1) lets the main agent pick a cheap model for explore and swarm workers and K3 for the hard subtask; force = true pins them all. Register a second alias for the same model with [models."k3-max".overrides] default_effort = "max" to put effort in the pool too.
Any provider: type = "anthropic" | "openai" | "openai_responses" | "google-genai" | "vertexai", or kimi provider catalog add anthropic --api-key … from the models.dev catalog. Credentials come only from config.toml — exporting KIMI_API_KEY in the shell does nothing unless it is in the provider's [env] table or KIMI_MODEL_*.
| It reads | Where |
|---|---|
AGENTS.md | Repo root — the cross-vendor standard; /init writes one |
~/.agents/ skills, agents, AGENTS.md | The shared user-level layout other agents also scan |
.agents/ in a project | Same, project-scoped |
| Claude Code agent files | Comma-separated tools: loads; model: is ignored |
/import-from-cc-codex | Imports Claude Code and Codex instructions, skills and MCP settings in one go |
mcp.json | The common {"mcpServers":{…}} shape, user and project level |
The durable point is the same as on the other sheets: the instruction layer is portable. Time spent on AGENTS.md and ~/.agents/skills/ is not a bet on Moonshot.
Bash(rm -rf*), Bash(git push --force*), Read(**/.env) — they apply in every mode, including -p.Edit cannot edit; a polite request can be drifted from.Ctrl-S to steer, not Esc to interrupt. Injecting a correction mid-turn keeps the work; interrupting throws it away.The machinery operates on context. /init once, then an AGENTS.md you prune, a wiki it can @-reference, and CLIs for your data. None of that is Kimi-specific, and all of it matters more than any setting above.
Kimi is built by Moonshot AI in Beijing. Using it for real work raises questions the other sheets on this site do not, and it is worth being able to answer them accurately — both the objections and why they may not apply to you.
With a Kimi Code plan or Platform key, your prompts, file contents and tool output are processed on Moonshot's servers, under PRC jurisdiction. Two regions exist — kimi.com (mainland) and kimi.ai (global, api.moonshot.ai) — and the CLI records which you logged into. Code that cannot leave your organisation should not go through either. The same is true of any hosted API; the difference is whose law applies to the logs.
Telemetry is on by default (telemetry = false turns it off); sessions, including tool output and credentials traces, are stored locally under ~/.kimi-code/sessions/.
The CLI is open source (MIT) and the K-series weights are published under a modified MIT licence — which is how K2.x appears in Copilot's model picker, on OpenRouter, and on Western-hosted inference providers. That is the answer to the data question: the model is separable from the company. Run it through a US or EU host, or on your own hardware, and nothing goes to Beijing. The CLI's provider table takes any OpenAI-compatible endpoint.
Benchmarks put K3 at or near the top of the open-weight tier for agentic coding, and K2.7 Code is a fraction of frontier prices. That is the reason to bother.
Like every model trained and served under Chinese regulation, Kimi declines or deflects on politically sensitive topics about China. For software work this almost never surfaces. For research, policy or journalism it is a real limitation, and the honest position is to know it rather than discover it.
Policy. Many employers ban Chinese-hosted AI services outright while permitting self-hosted open weights; some ban both. Check before the first session at work — it is the one question on this sheet you cannot answer from the docs.
The short version: the hosted service is a jurisdiction choice, the weights are not, and the tooling is good enough that the choice is worth making deliberately rather than by default.