AI agents

Kimi Code CLI

Workflows

Tool-specific mini-workflows for Kimi Code CLI. Cross-tool versions of these walkthroughs live in Example: Understand a new repository (and the other walkthroughs such as Example: Build a new feature end to end).

Understand a new codebase

cd unfamiliar-repo
kimi --plan
/init                                # generate AGENTS.md so future sessions know the project
Use explore to map the top-level architecture: entry points, main modules, data flow.
/compact keep the architecture summary   # if the session runs long

Why: Plan mode keeps the agent read-only while it researches, explore subagents fan out without polluting your main context, and /init persists the findings.

Build a feature

kimi          # default Always Ask mode
/plan on
Add CSV export to the reports page. Draft a plan first.
# → review the plan, approve with Enter (ExitPlanMode always requires confirmation)
# agent implements; approve each edit/command as prompted
/new                                # fresh session when moving to the next task

Why: plan-then-execute catches wrong approaches before code is written; Always Ask mode keeps each edit reviewable.

Debug a failure

kimi -c          # continue the session where the failure appeared, or:
kimi
The test "checkout applies discount" fails with: <paste output>
Find the root cause, write a failing-test-first reproduction, then fix it.
/undo                              # if a fix attempt went the wrong direction (rolls back prompts, not code)
/export-debug-zip                  # package the session if you need to report a CLI bug

Why: pasting the raw failure output anchors the investigation; /undo lets you retract bad directions; /btw can answer side questions without disturbing the debugging turn.

Refactor

kimi -y          # Ask When Needed: routine edits auto-run in a trusted directory
/goal Rename the `Customer` model to `Account` across the repo. Stop when `pnpm typecheck` and `pnpm test` both pass.
/goal status                       # check elapsed turns/tokens later

Why: /goal with an explicit stop condition keeps the agent working across auto-continuing turns; yolo mode avoids approving hundreds of mechanical edits — but only use it in a trusted directory, and see the warnings in Permissions and Approvals. Routine operations auto-run; sensitive files and dangerous commands still ask.

Code review

kimi --agent-file ./agents/reviewer.md    # or use the default agent
Review the changes on this branch vs main for correctness and security issues.
Cite every finding as path:line.
/export-md review-notes.md          # share the findings

Why: a read-only custom agent guarantees no edits during review; /export-md produces a shareable artifact. For parallel review of many files, /swarm <task> fans out subagents (up to 128).

Quick one-shot from scripts/CI

kimi -p "Summarize what changed in the last commit" --output-format text
kimi -p "List TODO comments added today" --output-format stream-json

Why: -p runs non-interactively (auto permission; static deny rules still apply), streaming results to stdout with diagnostics on stderr — easy to pipe. Exit codes in goal mode: 0 complete, 3 blocked, 6 paused.


Last verified: 2026-09-07

Official sources:

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