Kimi Code

Kimi / a practical coding guide

Kimi Code: set up the CLI and verify your first change.

Kimi Code is Moonshot AI’s coding agent for work in a local codebase. The CLI can read project files, propose edits and ask to run shell commands. Start in a small project with a clear expected result, approve the specific actions you need, and run the checks yourself before accepting the change.

Our downloadable example follows one seat-availability bug from failing tests to a one-line fix. After Kimi’s edit, all seven checks passed when run independently. Kimi could not run its own tests in our restricted session, so this was not a fully agent-run repair.

Access in brief: the current membership route starts at paid Plus and needs no separately created API key. The CLI also supports a Kimi Platform API key with separate API billing. Choose your access route, then install and sign in.

By China AI Chat Team · Documentation checked · Local test · Guide edited 1 October 2026 · How we research and test. ChinaAI is independent of Moonshot AI.

Kimi Code illustration showing a code-change review followed by verification with relevant tests.

Is Kimi Code the tool you need?

Use Kimi Code when you want an agent to inspect or change files in an existing project. A Kimi chat answer about code is useful for advice, but it does not by itself make and test a change in your repository. Kimi Websites creates a site through a separate browser workflow; our website-code export guide covers that product.

You want to…Start hereWhat to check
Ask for a code explanationOfficial Kimi chatShare only code you are allowed to send. Test any suggested change yourself.
Work inside a local repositoryKimi Code CLI, desktop or supported editorCheck account access, selected model, proposed file edits and commands.
Generate a website in the browserKimi WebsitesTest the exported code and the public page separately.
Call a model from your own applicationKimi Open Platform APIChoose an API model and keep its key private; this is a different setup.

The steps and example below use the CLI. The VS Code extension offers an editor-based chat and diff review. We did not test that extension or the desktop client here.

Is Kimi Code free? Do you need an API key?

The membership route is paid; a personal API key is optional. The current international membership table includes Kimi Code from Plus upward, not on free Adagio. The specialist Code membership guide lists Plus and above for new plans and Andante and above for legacy plans. A free browser-chat account alone does not grant a coding allowance.

In the CLI, /login offers two built-in routes. Choose the one that matches the allowance you intend to use:

Sign-in routeWhat you needWhat pays for usage
Kimi Code account / device authorizationAn eligible membership. No separately created API key is required for this route.Your Code membership allowance and applicable limits.
Kimi Platform API keyA key for the selected Open Platform region and available API credit.Separate Open Platform API billing; app membership is not an API token balance.

Sources: the current international membership table, Code membership guide and CLI sign-in documentation, checked on 1 October 2026. Check the benefits available in your region and account. A Code console key also draws on Code quota; it is distinct from an Open Platform key.

Which limits apply to your account?

New plans retain a rolling five-hour rate window and a monthly total; their weekly Code limit has been removed. Legacy plans retain the weekly window as well as the five-hour and monthly limits. Requests across your Code clients, devices and Code keys share the applicable allowance.

Enter /usage inside the CLI or open the Kimi Code console to inspect remaining usage and rate-limit status. Remaining monthly allowance does not prevent a five-hour limit from stopping requests. Optional Extra Usage is a paid fallback; check its setting and spending cap before relying on it.

Our recorded account was different: the 23 September test used a Moderato membership with Extra Usage disabled. The console did not report a dollar cost for that task, so the example does not establish a per-task price. For plan prices and the distinction between membership and API billing, see our Kimi pricing guide.

What you need before installing

  • A disposable project and a way to judge success. Use a copy or an isolated repository for a first edit. Write down expected behavior and checks before asking an agent to change files.
  • A supported runtime. The official npm route requires Node.js 22.19.0 or later. On Windows, Kimi’s CLI guide also requires Git for Windows before first launch because the agent uses Git Bash for its shell.
  • Kimi Code access. Choose the membership or Platform API route before starting. Verify your account’s available models and remaining allowance; the two routes use different billing.
  • Permission to share the project with the service. The agent may read project files automatically and send relevant content to its model service. Remove credentials, real customer records and unrelated private files before opening a project. See the official interaction and approval guide.

Install Kimi Code CLI and sign in

Check your runtime, then follow the official npm installation below. These are the documented global-install commands; our recorded test used a local installation in a separate folder:

node --version
npm install -g @moonshot-ai/kimi-code
kimi --version

The same official guide provides an install-script route if you do not want to install Node.js first. Follow the instructions for your operating system at the provider’s site rather than copying an old installer command from a third-party article.

  1. Open a project you can safely modify. In a terminal, move into that folder and run kimi. Check the displayed directory and model before sending a task.
  2. Sign in. On first launch, enter /login. The documented options are a Kimi Code account/device-code flow and a Kimi Platform API key. You can also start the device flow with kimi login. Use the official authorization page shown by the tool; do not paste the temporary code or an API key into a public chat or a repository.
  3. Review trust and action prompts. Our CLI asked whether to trust the isolated project and later sought approval for the exact edit and shell commands. Inspect what the folder contains, including any project MCP configuration, before trusting it. Use /status to check the permission mode: the documented default is Always Ask, but other modes and saved rules can change which actions ask for approval. Approve only the proposed actions you understand.

Do not use non-interactive kimi -p as a first-run substitute for reviewing approvals. The current command reference says prompt mode applies the automatic permission policy to regular tool calls. The interactive route let us inspect and approve the single code edit and each attempted command.

Choose and check the model before your first task

Enter these slash commands in the running CLI’s input box, one at a time. They are current documented steps; our recorded repair remains the separate September test.

  1. Open the available choices with /model. Select an option offered by your signed-in account. Then enter /status to confirm the model, project directory and permission mode before sending a task.
  2. Match the selection to your access. For Code’s K3 option, a new-plan Plus subscription provides 256K context; Pro and higher plans unlock its 1M context. K2.8 Preview has a separate 1M specification, while HighSpeed starts at Pro. Check the Code model and legacy-plan comparison rather than treating every model as having your plan’s K3 limit.
  3. Use a fresh session for a separate task or model change. Finish or save what you need, then enter /new while the CLI is idle and check the selection again. This starts a fresh conversation; it does not undo changes already made to project files.

Sources: the slash-command reference and Code model configuration. The provider recommends a new session when changing model or reasoning effort because the context cache can be invalidated. Aliases and available options can change; record what your own session displays.

Give it a first task you can check

Our fictional project calculates available seats. Its README says that only confirmed reservations occupy seats; pending and cancelled do not. We wrote seven tests first. The original function excluded only cancelled entries, so a pending reservation incorrectly reduced availability. Before asking Kimi, the tests reported 5 passed, 2 failed.

We sent this exact first prompt:

This is a small fictional Node.js project. Read README.md and the existing source and tests. Fix the seat-availability bug so only confirmed reservations occupy seats. Keep the exported function name and signature. Do not edit the tests or add dependencies. Run npm test if you can. Briefly report what you changed and any test or tool failures.

For your own project, specify the relevant files, expected behavior and what must remain unchanged. Then check the change in three steps:

  1. Record the starting result. Run the existing checks before the edit and note which ones fail. Keep a copy of the original tests.
  2. Review the proposed diff. Check that it addresses the stated bug without changing unrelated files, function signatures or dependencies.
  3. Run the same checks afterward. Confirm that the failing cases now pass and that previously passing cases still pass. A change to the tests needs its own review; do not weaken them to make the result look successful.

What changed, and how we verified the fix

Kimi Code read the project and proposed one line in src/availability.mjs. We approved it once:

- .filter((reservation) => reservation.status !== 'cancelled')
+ .filter((reservation) => reservation.status === 'confirmed')

The new condition counts only confirmed reservations. The function name, validation and zero-seat floor remained unchanged. Kimi did not edit the README, tests or package manifest. We checked the Git diff and ran the same prewritten tests ourselves after the agent stopped.

CheckBeforeAfter Kimi’s edit
Empty, confirmed, cancelled, zero floor and invalid capacity5 passed5 passed
Pending-only and mixed-status reservations2 failed2 passed
Total5 passed, 2 failed7 passed, 0 failed

Kimi did not run these tests. Its test commands failed with spawn EPERM in our restricted Windows session. The passing results above came from running the unchanged checks independently after Kimi’s edit. This finding describes that session, not a general inability of Kimi Code to run tests.

The CLI displayed K2.8 Preview during this September 23 test. Check the model label in your own session before comparing its output with this example.

Download the before/after project and test record (ZIP). It includes the unchanged tests, exact prompt, one-line diff and the tool-failure disclosure. You can run the two folders locally without a Kimi account. One passing exercise is evidence for this narrowly defined fix, not a benchmark of coding reliability or production safety.

Common first-run problems

What you seeWhat to check next
kimi is not recognizedCheck that installation completed, reopen the terminal, and verify the executable is on your PATH with kimi --version.
Node version is rejected by npmCheck the current CLI requirement in the official guide; the npm route required Node.js 22.19.0 or later when we reviewed it.
Windows shell actions failConfirm Git for Windows/Git Bash is installed. If your environment restricts child processes, inspect the exact error and run your tests independently; our spawn EPERM result did not identify a product-wide defect.
Sign-in cannot completeRestart the device-code flow if its temporary code expired, and use the official authorization link for the region and account you actually use. Keep the code private.
The model or allowance differs from an articleUse /model and /status to check the selection, then /usage or the Code console for your limits. Confirm whether you are on a new or legacy plan.
The agent says “fixed”Inspect the changed files and run the original checks yourself. A confident final message is not a passing test.

The official getting-started guide covers current install and sign-in steps. If a documented workflow changes, use that source first and send us a correction with the page and date.

Test conditions and command details

View the setup, failed commands and usage record
  • Setup: September 23, 2026; Kimi Code CLI 2.0.2 installed in a separate local folder; Node.js 24.19.0; Windows; a signed-in Moderato account. Kimi’s product page advertised K3 on that date; K2.8 Preview is the model label recorded in the CLI for this trial.
  • Task: One prompt and one approved source-code edit. The README, tests and package manifest were unchanged. The same seven checks ran independently before and after the edit.
  • Command failure: Kimi attempted npm test, then node --test --test-isolation=none. Both returned spawn EPERM. We declined a further PATH probe; Kimi’s final response acknowledged that it had not executed the tests. The independent passing checks do not establish that its shell integration worked.
  • Usage: The console showed 0% weekly usage in both snapshots; the separate rate-limit indicator moved from 0% to 2%. Extra Usage stayed disabled. No credits were purchased or API key created, and no dollar cost was shown for this run. These indicators are not a measured per-task price.

This editorial update was AI-assisted. See our review policy; the named human credit below applies to an earlier version.

Continue with the Kimi guides

Read our Kimi AI overview for the product map, Kimi models guide for model names and inputs, or Kimi API guide if you are adding a model to an application. Kimi Code works on an existing project; Kimi Websites code export is a separate workflow.

This article combines official documentation checked on 1 October 2026 with the separately recorded 23 September 2026 local Kimi Code CLI test. The documentation check did not repeat the repair or measure the new plan limits. Recheck it if the CLI install requirement, login routes, approval behavior or membership rules change. Our methodology · Report a correction.