geocam.cloud · lesson

Kimi Code — the 2026 Method

Not a feature tour. How to work with Moonshot's Kimi Code CLI the way it is built to be used: goals that say what must become true, swarms for work that comes in items, deny rules where other tools use hooks, a cheap model pool for the reading stages — and a clear-eyed answer to the question everyone asks first: where does the code go?

Lesson v1.0 · Written against Kimi Code CLI v0.38.0 (20 August 2026), default model Kimi K2.7 Code · companion sheet: Kimi Code Reference

00Start here

Most Kimi Code write-ups — it has existed in this form only since a June 2026 rewrite — are "the cheap Claude Code" comparisons: install it, notice it reads your AGENTS.md, notice the price, move on. True as far as it goes, and it misses the two things the tool does differently.

The first is goals. Every agent can take a prompt that says what to do next; Kimi's /goal takes an objective that says what must become true, then keeps working turn after turn until it is — or until it can say precisely why it is blocked. The second is swarms: one prompt template, a list of items, one subagent per item in parallel, with a live progress card. Between them they cover the two shapes most real work takes: a finish line you can name, and a pile of similar things.

Around those sit the now-standard pieces — skills, custom agents, hooks, MCP, plugins, plan mode, a local web UI and an ACP server on the same engine — and a model that costs a fraction of the frontier labs' while sitting at the top of the open-weight tier for agentic coding.

Three statements anchor the method:

On goals: "Unlike a normal prompt that says what to do next, a goal says what must become true. Use /goal when the task has a clear finish line, but the next useful step depends on what the agent learns while it works."

Kimi Code documentation, Goals

On hooks: "Precisely because of fail-open, Hooks are suitable for alerts and lightweight interception, but should not be used as the sole security barrier."

Kimi Code documentation, Hooks

On what it already reads: /import-from-cc-codex — "Import Claude Code and Codex instructions, skills, and MCP settings into Kimi Code." There is nothing to port before the first useful session.

Kimi Code built-in skills

Everything below follows from those: describe outcomes rather than steps, put the hard guarantees in permission rules rather than scripts, and reuse the configuration you already have.

Who this is for. Someone who already runs Claude Code, Copilot or Grok Build and wants to know what a fourth agent — from a Chinese lab, at a fifth of the price — adds, what it costs in trust, and how to get the most out of it once installed. The question of where your code goes is section 03, deliberately early.

01Audit your own setup first

Before any technique, check what you have. The install script puts kimi in ~/.kimi-code/bin/ and edits your shell profile, which means it is not on the PATH in non-interactive shells — scripts, cron, IDE-launched processes. That is the first thing to know.

~/.kimi-code/bin/kimi --version        # 0.38.0 or later; it ships several times a week
kimi doctor                           # config.toml and tui.toml valid?
kimi provider list                    # which providers and models are configured
ls ~/.kimi-code/skills ~/.kimi-code/agents ~/.agents/skills ~/.agents/agents
ls .kimi-code/skills .kimi-code/agents .agents/ AGENTS.md 2>/dev/null
grep -c '^\[\[permission.rules\]\]' ~/.kimi-code/config.toml   # any hard rules?
grep -c '^\[\[hooks\]\]' ~/.kimi-code/config.toml

Inside a session: /status (model, mode, cwd), /usage (tokens and quota), /mcp, /plugins list.

If this is emptyWhat you are losing
AGENTS.mdEvery session meets the repository as a stranger. /init writes one in a minute
[[permission.rules]]Nothing is forbidden. YOLO and -p have no floor under them
.kimi-code/agents/ or .agents/agents/No read-only reviewer; every "check this" is a request the worker might drift from
SkillsYour repeatable procedures live in your head; the Friday task is typed fresh every Friday
[secondary_model]Every explore subagent and swarm worker runs on the main model's price
All of themYour setup does not compound. This is the single biggest gap
The highest-leverage idea on this page: when Kimi gets something wrong, don't correct it in chat — write a rule. A correction fixes one turn. A line in AGENTS.md, a skill, a deny rule or an agent's tool list fixes every future run — and because Kimi reads the same AGENTS.md and ~/.agents/ layout as Claude Code, Copilot and Grok, it fixes them for every agent you will ever point at the repo. Your error rate should trend down over months.

02The four shifts

Prompts → goals

The old loop: prompt, read the result, prompt again. The new loop: state the finish line and the evidence, and let the agent run until it holds. "Fix the failing checkout tests" is a prompt. "Every checkout test passes, each fix has a test, the suite runs green, stop if still blocked after 20 turns" is a goal. The difference is who decides the next step when the first clue is not the root cause.

Correcting in chat → writing rules

Covered above. This is the one that compounds — across vendors, because the instruction layer is portable.

Hooks → permission rules

Kimi's documentation is unusually frank: hooks fail open. A hook that errors, times out or returns the wrong exit code allows the call. So the structural guarantees live elsewhere — in [[permission.rules]] with decision = "deny", which survive every mode including headless, and in an agent's tools list, which is enforced before execution. Hooks are for the test run on Stop and for notifications.

One model → a pool

The main agent on K2.7 Code or K3; explore subagents and swarm workers on the cheap alias; the hard subtask on K3 at max effort. [secondary_model] makes that a configuration rather than a habit. That is section 09.

03Where the code goes — decide this first

Kimi is built by Moonshot AI in Beijing. That is the first thing anyone asks, so settle it before the first session rather than after.

RouteYour prompts and code go toUse when
Kimi Code plan (OAuth)Moonshot — kimi.ai / api.moonshot.ai (global) or kimi.com (mainland); you pick a region at loginPersonal projects; anything you would also send to any hosted API
Kimi Platform API keySame servers, per-token billingScripts and headless runs on the same terms
The open weights on a Western hostOpenRouter, a US/EU inference provider, or Copilot's picker (K-series is in it)Work code. Same model, different jurisdiction
The open weights on your hardwareNowhereCode that cannot leave the building

The point that makes the decision tractable: the model is separable from the company. The K-series weights are published under a modified MIT licence, which is how they turn up on Western hosts and inside Copilot. The CLI's provider table takes any OpenAI-compatible endpoint — kimi provider catalog add or a [providers.x] block — so you keep the tooling and change where the tokens are processed. Routes three and four are what make Kimi usable at work at all; routes one and two are fine for what you would send to any cloud API.

Two smaller facts. Telemetry is on by default (telemetry = false). Sessions are stored locally under ~/.kimi-code/sessions/ as event streams that can contain tool output and credential traces — treat kimi export zips like logs, not like documents.

What it will not say. Like every model trained and served under Chinese regulation, Kimi declines or deflects on politically sensitive topics about China. For software this almost never surfaces. For research or writing it can, and the honest position is to know it rather than discover it. And check your employer's AI policy: many permit self-hosted open weights and ban the hosted service, some ban both. That is the one question on this page the docs cannot answer.

04Verification — the primary lever

The single thing that separates an agent that produces mergeable changes from one that produces plausible ones. Kimi's goal mode is built around it: a goal is defined by the evidence that proves it.

The logic is simple. An agent stops when the work looks done. Without a check it can run, "looks done" is the only signal available — and you become the verification loop, at review time. Give it something that returns pass or fail and the loop closes on its own.

The ladder

RungMechanismUse when
1 · In the brief"…then run npm test and paste the summary"Any task, today, zero setup
2 · In the goalThe objective names the command and the expected result; Kimi checks after every turnAnything with a finish line
3 · A Stop hookRuns the suite when the model wants to end the turn; exit 2 and it keeps workingA rule that must hold in every session
4 · A read-only reviewerA custom agent with no Edit or Write, in a fresh context, tries to refute the resultHigh-stakes changes; anything that ran unattended

Rung 4 matters because the agent that did the work is the worst judge of the work — models prefer their own output. A reviewer whose tools: list has no editor cannot "fix" what it finds and is enforced before execution, not just shown to the model. The kit's reviewer.md is exactly that; run it as kimi -p --agent reviewer "…" on the diff, or tell the main agent to delegate to it when done. For the strongest version, run the reviewer on a different vendor's model — the provider table makes that one config block.

One caveat: a reviewer prompted to find gaps will report some, even when the work is sound. Tell it to "report only findings that affect correctness, security or a stated requirement" — and to say plainly when the diff is fine.

Rewrite your prompts — as goals

✗  add retry logic to the client
✓  /goal HttpGateway.Send retries 5xx and timeouts with exponential
   backoff (max 3, jitter). Tests exist for: retries on 503, no retry
   on 400, gives up after 3. `npm test -- gateway` passes. Paste the
   summary. Stop if blocked after 15 turns.

✗  the build is broken
✓  `npm run build` fails with: [paste]. Fix the root cause — do not
   suppress the error or pin the package. Verify the build succeeds
   and paste the last 20 lines.

And always: ask for evidence, not assertions. "Paste the test output" beats "confirm it works." A goal that names the evidence is checked against it every turn; one that does not is checked against the model's opinion.

05Context is the budget

Performance degrades as the window fills. Kimi compacts automatically when the remaining window drops below [loop_control] reserved_context_size; set it, because the default of "when we have to" is late. K2.7's window is 256k; K3's is 1M, which moves the cliff but does not remove it.

ToolWhat it doesUse when
/new · /clearA fresh sessionBetween unrelated tasks — almost certainly more often than you do
/compact <hint>Compress; the hint steers what is keptMid-task and running long
/undo [n]Drop recent prompts and their todo/plan state; files stayA failed approach that is still influencing the model
/forkIndependent copy with full history; you stay putTry a second approach without losing the first
/btwSide question in a forked sub-agent; never enters history"What's the flag for X?" mid-task
Ctrl-SInject a correction into the running turnInstead of Esc, which throws the work away
explore subagentRead-only research in its own context; a summary comes backAny investigation that reads many files
@fileAttach one file, loaded when the agent reads the messageInstead of pasting

Two rules of thumb

AGENTS.md discipline

Kimi reads the project AGENTS.md, a global ~/.kimi-code/AGENTS.md, and the cross-tool ~/.agents/AGENTS.md. /init writes the first one from the codebase — then prune it. The test for every line: "would removing this cause the agent to make a mistake?" Build, test and lint commands; conventions that differ from the default; architecture boundaries with the reason; known traps. Not the directory tour, not what the linter enforces.

Allocation rule: things that apply always go in AGENTS.md. Things that apply sometimes go in a skill, matched by its description and whenToUse. Things that must never happen go in a deny rule. Tone and role go in an agent file. One enormous always-on file is what all of those exist to avoid.

06How to write a brief now

Delegation means full task context in turn one: goal, constraints, acceptance criteria. Think hard once rather than iterating fast.

GOAL        what "done" looks like, in one sentence — this becomes the /goal
CONTEXT     which files (@path); what pattern to follow
CONSTRAINTS what must not change; what is out of scope
VERIFY      the exact command, the expected result, and "paste the output"
STOP        the turn or token budget after which to report blocked

Plan mode — when it earns its place

Shift-Tab. The agent explores read-only and writes a plan; Write and Edit are restricted to the plan file; exiting needs your approval even in YOLO (only auto self-approves). ExitPlanMode can offer up to three alternative approaches for you to pick from — use that for "add authentication" or "add caching", the tasks with a real design choice. Skip it for the single-file fix; planning a task that did not need planning is pure latency.

Let the agent interview you

I want to build [one line]. Interview me before writing anything —
data model, failure cases, what must not change, tradeoffs I haven't
considered. Use AskUserQuestion. Don't ask obvious questions. When
we've covered everything, write SPEC.md and stop.

Then /new and execute the spec as a goal in a fresh session. Clean context, written reference, a finish line.

Three more techniques

07The parallelism ladder

Five rungs, each a different answer to "who holds the plan?"

RungWho decides what runs nextScaleUse for
WorktreesYou3–5 sessionsIndependent features in parallel, no collisions
Background tasks · /tasksThe main agentA fewA long build or test run while the conversation continues
SubagentsThe main agent, turn by turnSeveralResearch (explore), planning (plan), review, implementation (coder)
Swarm · /swarmA template × a listOne per itemWork that comes in similar pieces: files, modules, issues
Goal queue · /goal nextAn ordered listSequentialThree finish lines in a row without you at the keyboard

Worktrees

git worktree add ../repo-ratelimit feature/ratelimit
cd ../repo-ratelimit && kimi -y --plan          # its own session, its own files
/title ratelimit-tests-green                   # name by outcome

Kimi does not manage worktrees for you; git worktree does, and a session per directory follows. Name them by outcome so /sessions reads as a status board.

Subagents — isolated, bounded, one level deep

Just append "use subagents" to a hard prompt, or name one: "use explore to map how auth handles token refresh before you change anything." Three built-ins — coder (read/write/run), explore (read-only), plan (no shell) — plus any agent file you write. Each has its own context; only the final message returns. Built-in subagents cannot spawn further subagents; fan out from the main agent, do not build trees. Each dispatch is an approval unless allowed; "always allow" choices propagate down. /tasks shows background ones working, with their model and effort.

---
name: reviewer
description: Read-only reviewer. Reports only correctness, security and
  stated-requirement findings; says plainly when the diff is sound.
tools: [Read, Grep, Glob, Bash]
disallowedTools: [Write, Edit]
---
You are reviewing a diff you did not write…

Swarm — the big one

/swarm write a unit test file for every module under src/billing/,
  following tests.instructions in AGENTS.md. Run each file's tests
  and include the summary in your final message.

The main agent turns that into an AgentSwarm call: one prompt_template with {{item}}, one subagent per item, in parallel, with rate-limit-aware retries and a progress card; results roll up into one message. It is the right tool when the items are genuinely independent and the wrong one when they are not — two items touching the same file are not independent, and you should say so. From manual mode it offers to switch to auto or yolo first, because approving forty subagents by hand is not a thing anyone does. Cap the ramp with KIMI_CODE_AGENT_SWARM_MAX_CONCURRENCY if the provider rate-limits.

Put the verification in the template. A swarm whose items each run their own check and report the result is a fleet of closed loops. One whose items just "write the tests" is forty plausible files.

The goal queue

/goal next <objective> queues a finish line the agent cannot see until the current one completes; /goal next manage reorders the queue. Three goals — make the suite green, then update the docs, then write the changelog — run to completion without a prompt between them, and the chain stops if any blocks.

08Making it permanent

MechanismWhereLoadsEnforcementUse for
AGENTS.mdrepo root · ~/.agents/ · ~/.kimi-code/Every turnAdvisoryConventions that always apply, for every vendor's agent
Skills.agents/skills/ · .kimi-code/skills/ · user equivalentsBy description, or /nameAdvisoryProcedures with bundled scripts and references
Agent files.agents/agents/ · .kimi-code/agents/When delegated to, or --agenttools list is hardA reviewer that cannot write; a main agent with a different prompt
[[permission.rules]]config.tomlAlways, every modeDeterministicWhat may never run — the real floor
[[hooks]]config.tomlAt lifecycle eventsFail-openThe test run on Stop; notifications; context injection
Plugins/plugins, GitHub URLInstalled per userSkills + agents + MCP + instructions as one unit
SYSTEM.md~/.kimi-code/Every sessionAdvisoryReplace the main agent's prompt outright
Cron toolsin a sessionOn a scheduleA prompt re-injected daily, bound to the session

Prefer the .agents/ directories. Kimi scans both its own .kimi-code/ tree and the generic .agents/ tree (project and user level), and the generic one is what other agents read too. A skill written once under ~/.agents/skills/ is a skill for every tool you own.

Skills

The rule of thumb: if you do something more than once a week, make it a skill. A skill is a folder — SKILL.md plus scripts and references — and its description and whenToUse are the matcher: what it does and when, or the model never reaches for it.

.agents/skills/release-notes/SKILL.md
---
name: release-notes
description: Draft release notes from merged PRs since the last tag.
whenToUse: when asked for release notes, a changelog entry, or "what shipped"
disableModelInvocation: true
arguments: [since]
---
1. `git describe --tags --abbrev=0` for the last tag (or use $since)
2. `gh pr list --state merged --search "merged:>$since" --json number,title,labels`
3. Group by label; one line per PR; link each. Write CHANGELOG.md; do not commit.

disableModelInvocation: true means only you can run it (/release-notes v1.2) — right for anything with side effects. $ARGUMENTS, $0, $since and ${KIMI_SKILL_DIR} expand in the body. /sub-skill.review proposes how to fold a sprawling skill set into parent/child bundles.

Permission rules — the floor

[[permission.rules]]
decision = "deny"
pattern  = "Bash(git push --force*)"
reason   = "never rewrite shared history"

[[permission.rules]]
decision = "deny"
pattern  = "Read(**/.env*)"

[[permission.rules]]
decision = "allow"
pattern  = "Bash(npm test*)"

Matched in order; patterns are Tool or Tool(arg-pattern); MCP tools match as mcp__server__*. Deny rules hold in YOLO, in auto, in -p, and inside subagents. This is where Grok users put a sandbox profile and Claude users put a hook; in Kimi it is the rule table.

Hooks — for the things that should happen, not the things that must not

[[hooks]]
event   = "Stop"
command = "~/.kimi-code/hooks/verify.sh"   # exit 2 → the model keeps working
timeout = 300

[[hooks]]
event   = "Notification"
matcher = "task\\.completed"
command = "terminal-notifier -title Kimi -message 'Task done'"

Event JSON on stdin; exit 0 allows, exit 2 blocks with stderr as the reason; anything else — including a crash or timeout — allows. Only PreToolUse, Stop and UserPromptSubmit can block at all. The Stop hook is the one worth having: it turns "I think I'm done" into "the suite says I'm done."

Sessions

kimi -c continues, kimi -S picks, /fork branches and puts a resume command on your clipboard, /title names. Sessions are event streams under ~/.kimi-code/sessions/; kimi vis replays one in a browser, which is the fastest way to understand what a long unattended run actually did.

09Models and cost — where to spend

ModelContextIn $/M (cache hit)Out $/MPut it on
Kimi K31M3.00 (0.30)15.00The hard subtask; the review; architecture. Declares low / high / max effort
Kimi K2.7 Code256k0.95 (0.19)4.00The main session, most days
K2.6 · K2.5256k0.95 · 0.604.00 · 3.00Explore, swarm workers, mechanical sweeps

Those are Platform API prices; a Kimi Code plan (from about $19/month) provisions kimi-code/k3, kimi-for-coding and a -highspeed variant against a quota instead, and /usage shows what is left. Either way the ratio is the point: K3 output costs nearly four times K2.7's, and cache-hit input is a fifth of fresh. Spend judgement on judgement; spend nothing on reading.

The model pool

# config.toml — requires KIMI_CODE_EXPERIMENTAL_SECONDARY_MODEL=1
[secondary_model]
default_model = "moonshot-ai/kimi-k2.6"
[secondary_model.models]
"moonshot-ai/kimi-k2.6" = "Fast and cheap — explore, swarm workers, small edits."
"moonshot-ai/k3"        = "Strong reasoning — pick for hard debugging or design."

With a pool configured, the Agent and AgentSwarm tools gain a model parameter and the main agent reads your hints to choose per spawn; force = true pins every subagent to the default instead. Register a second alias for the same model with [models."k3-max".overrides] default_effort = "max" and the pool carries effort as well as model. A swarm of cheap workers judged by one K3 reviewer costs a fraction of the all-K3 version and finds the same bugs.

Any provider. type = "anthropic" | "openai" | "openai_responses" | "google-genai" | "vertexai", or kimi provider catalog add anthropic --api-key … from the models.dev catalog. That is how the second-vendor reviewer from section 04 becomes one config block — and how the whole harness runs against a Western host or a local server when the code cannot go to Moonshot. Credentials come only from config.toml; exporting KIMI_API_KEY in the shell does nothing.

10Web UI, IDE and headless

One engine, three front ends. The TUI is the default; the other two exist because some things a terminal does badly.

kimi web

A local server and a browser UI on the same engine: a session sidebar with Open / Done / Workspaces, a goal strip with a token-budget bar, swarm cards that stay open while workers run, Cmd-K search across sessions, and GET /openapi.json for the REST API if you want to drive it. /web from the TUI hands the current session across. It binds to loopback and prints a bearer token; --host opens it to the network, which you do only behind your own TLS proxy, and --dangerous-bypass-auth means exactly what it says.

kimi acp

The Agent Client Protocol over stdio — Zed natively, JetBrains through the AI chat plugin. The editor launches kimi acp as a subprocess and drives sessions and tool calls; MCP servers the editor declares are forwarded. GUI-launched processes do not inherit the shell PATH, so the config needs the absolute path: ~/.kimi-code/bin/kimi.

Kimi as a component

kimi -p "summarise the failing tests" < test.log
git diff main | kimi -p "list any change that alters a public API"
kimi -p --output-format stream-json "…"         # one JSON object per line
kimi -p --agent reviewer "review the diff on this branch"
kimi -p "/goal make `npm test` pass; stop if blocked after 20 turns"
                                                # exit 0 done · 3 blocked · 6 paused

-p runs under auto permission — nobody is there to approve — so the deny rules are the only floor. Pair a scheduled run with a read-only agent file (tools: [Read, Grep, Glob]) and [tools] disabled for anything it must not touch. Print mode stays alive while background tasks finish and feeds each completion back as a turn ([background] print_background_mode = "steer"); set "exit" for a pure one-shot. The goal exit codes make kimi -p "/goal …" a CI step that fails the pipeline when the finish line is not reached.

MCP

/mcp-config to add servers (stdio, HTTP, legacy SSE; OAuth via /mcp-config login), /mcp for status, mcp.json at user or project level. Two disciplines: every server costs context (its tool schemas load each session), and tool output is data, not instructions. A project-level mcp.json runs commands when a session starts — which is why the trust prompt lists them and defaults to Don't trust. Keep write-capable MCP tools out of YOLO sessions: it approves all of them.

11Beyond the repo — documents, data, the desktop

Kimi Code is not a coding tool. It is an agent with a shell, a filesystem and a verification loop — plus, unusually, video input and two official plugins that reach outside the terminal. Anything with files and a command that returns pass or fail is native territory.

Step one — give it something to read

A plain-markdown wiki in git — decisions and why, runbooks, where things live, traps and the incident that proves them — and CLI access to live data, because pasting is stale, truncated and unrepeatable. @-reference a wiki page in the prompt and the agent loads it; --add-dir makes a second tree part of the workspace. None of this is Kimi-specific and all of it matters more than any setting above.

Step two — find the verification loop

DisciplineThe check the agent can run
Documentspandoc builds the docx; pdftotext reads it back; the agent checks its own output against the spec
Dataduckdb or sqlite3 on a CSV; a script that prints a number; the row count before and after
Anything visualReadMediaFile on a screenshot or render — the agent looks and compares to the mock
The browserThe WebBridge plugin drives your own browser: load the page, click through, read what happened
The desktopThe Computer Use plugin operates macOS and Windows apps — for the tool that has no CLI
ResearchThe Datasource plugin: market, macro, academic and statistical sources, cited

Step three — write the domain knowledge down

Every domain has conventions an agent cannot guess. Each becomes an instruction line, a skill or a wiki page — written once. The most quietly valuable is a runbook skill with disableModelInvocation: true: the exact commands, the check at each step, the rollback — run by you, with the agent doing the typing.

12Away from the keyboard

ToolWhat it doesUse for
/goal + /goal nextWorks to a finish line across turns; queued goals follow; blocked goals say whyThe overnight run you want a morning report from
/swarmN parallel workers, results rolled upThe pile of similar things
Background tasks · WaitForLong commands and subagents run on; the agent can wait inside the turnThe slow build in the middle of an otherwise interactive session
CronCreateRe-inject a prompt on a cron, bound to the session, surviving resume"Every morning, check the deploy status and report only if it changed"
kimi -p "/goal …" on a scheduleHeadless goal with exit codes; deny rules and a read-only agent as the floorNightly audits, the weekly report, CI gates
kimi web on a phoneThe goal strip and swarm cards, from the sofa (loopback + your own proxy)Pausing, resuming or cancelling a goal without the laptop
Notification hooktask.completed → a desktop pingComing back at the right moment

The pattern that ties them together is the one from section 04: give the unattended run a way to know it is done — and, because -p runs under auto, a deny-rule floor under what it may do while nobody is watching. A scheduled goal without a named finish line is the one invocation on this page to refuse to write.

13Tools on the PATH

An agent is exactly as capable as the command-line tools it can call. Kimi cannot make a PDF or query a database by wanting to — it needs a binary on the PATH that does it and returns an exit code. It bundles its own rg and fd; the rest is on you.

Three selection rules. Prefer tools with a non-interactive mode — an agent cannot answer a prompt. Prefer machine-readable output (--json, exit codes). Prefer one tool that does a thing well over a GUI app with a CLI bolted on.

ToolInstallWhat the agent gets
ghbrew install ghIssues, PRs, checks from the shell; !gh auth login inside a session; gh run watch is a verification loop for CI
jq, yqbrew install jq yqPrecise checks on any JSON or YAML — including kimi provider list --json and stream-json output
pandoc, typstbrew install pandoc typstmd → docx / PDF, and docx → md so the agent can read what someone sent
pdftotextbrew install popplerExtract a spec with layout, so a table reads as a table
duckdb, sqlite3brew install duckdbSQL questions of a CSV without writing a program
Formattersbrew install prettier ruff shfmtSomething for a PostToolUse hook to call
terminal-notifierbrew install terminal-notifierThe Notification hook's ping on macOS
uvbrew install uvPython envs and tools without the venv dance
ffmpegbrew install ffmpegTrim the screen recording before pasting it; frames out of a video
Kitty / Ghosttybrew install --cask ghosttyThe docs recommend a true-colour, ligature-capable terminal for the TUI
Tell the agent what is installed. One line in AGENTS.md"available: gh, jq, pandoc, typst, duckdb, ffmpeg" — saves a probing which per tool per session. Better: a skill with the exact invocations that work on your machine, so it loads only when a document or a dataset is in play. And remember the PATH trap from section 01: in a cron job or an IDE, kimi itself needs its absolute path.

14The starter kit

Four files that turn the ideas above into configuration. Copy them into a repository's .agents/ (so other agents see them too) and your ~/.kimi-code/config.toml, and adapt.

Test each before trusting it. Ask the reviewer to fix something and confirm the write is refused. Break a test on purpose and confirm the Stop hook sends the agent back to work. Try git push --force in YOLO and confirm the deny rule holds. A guard you have never seen fire is a guard you have.

15What to do, in order

This week — thirty minutes

Next week

The month after

16Anti-patterns

PatternSymptomFix
Not deciding where the code goesWork code on a Beijing-hosted API, discovered laterSection 03, first. The weights run anywhere
The other kimiA Python binary, no ~/.kimi-code/@moonshot-ai/kimi-code; kimi migrate for the old one
"kimi: not found" in a scriptWorks in the terminal, not in cron or the IDEAbsolute path: ~/.kimi-code/bin/kimi
Exporting KIMI_API_KEY"No credentials" despite the variableCredentials come only from config.toml
A hook as the only guardThe guard errored and the command ranHooks fail open. Deny rules and tool lists are the floor
--auto in a cloned repoIt read .env and never askedYOLO at most; deny rules first; read .kimi-code/ before trusting
A goal without a finish line"Find all bugs" blocks or runs foreverName the evidence and the stop condition
Swarming dependent workTwo workers, one corrupted fileItems must be independent; say so in the template
Correcting instead of rulingThe same mistake, every sessionWrite the rule. This is the one that matters
K3 for grepThe quota gone by the 20th[secondary_model]; explore on the cheap alias
Dismissing the cache dialogFresh-price input on every resumeCompact when it offers; cached input is a fifth of the price
Reviewing with the workerThe reviewer agrees with everythingA read-only agent file in a fresh context — ideally another vendor's model
Interrupting to correctEsc, retype, lose the workCtrl-S steers the running turn
The kitchen-sink sessionTask, unrelated task, back again/new between unrelated tasks
Planning trivial workPure latencyPlan mode is for real design choices

The one-paragraph version

Decide where the code goes before the first session — the hosted service is a jurisdiction choice, the open weights are not. Then give the agent a finish line instead of a next step: a goal that names the evidence, checked after every turn, with a stop condition in the text. Put the hard guarantees in deny rules and read-only tool lists, because hooks fail open; use hooks for the test run on Stop. Guard your context like a budget and take the cache dialog's advice. When Kimi gets something wrong, write a rule in AGENTS.md or ~/.agents/ rather than a correction in chat, so every agent you own improves at once. Put the reading on the cheap model and the judgement on K3. And when the work is bigger than one conversation, don't hold it in one: subagents for research and review, a swarm for the pile of similar things, a queue of goals for the evening.