Try Kimi at kimi.com →

Kimi Code: Setup and First Coding Task

Kimi Code is a coding assistant that works inside your own project, from the terminal. This guide takes you from nothing installed to your first finished task, one small and safe step at a time.

About 20 minutesMac, Linux and Windows
Your design page.html 1 2 3 4 5 6 7 8 terminal $ kimi > Build this page from my screenshot ● Reading the design… ● Writing 3 files… ● Running tests… ✓ All tests passed ✓ Preview ready

Kimi Code reads your project, writes the code, runs the tests and shows you the result.

Independent guide. We are not Moonshot AI. The install commands on this page are the ones published in the official Kimi Code documentation. Commands and plans can change, so check kimi.com/code if something looks different.
BASICS

What is Kimi Code?

Kimi Code is Moonshot AI's coding assistant. You open it in your project folder, type what you want in plain words, and it does the work in your files. It is different from chatting at kimi.com because it can see your whole project and act on it.

It reads

It searches and reads your files to understand how the project fits together.

It writes

It edits code across several files, and asks you before each change.

It runs

It can run commands and tests, then fix what fails, with your approval.

BEFORE YOU START

What you need

You needDetails
A way to pay for usageA Kimi Code membership (usage is included), or an API key from the Kimi platform (pay as you go). The free chat plan does not cover Kimi Code.
A terminalTerminal on Mac, any terminal on Linux, or PowerShell on Windows.
Windows only: Git for WindowsInstall it before you start Kimi Code for the first time. Kimi Code uses the Git Bash that comes with it.
Node.js (optional)Only if you install with npm or pnpm. You need version 22.19.0 or later. The install script does not need Node.js.
A project to practise onAny small folder with code in it. A personal or test project is best for your first try.

Not sure about plans? See Kimi pricing or the Kimi Code notes on the home page.

Step 1

Install Kimi Code

Open your terminal, copy the line for your system, paste it and press Enter.

Mac and Linux

curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash

Paste into Terminal.

Windows

irm https://code.kimi.com/kimi-code/install.ps1 | iex

Paste into PowerShell. Install Git for Windows first.

With npm (any system)

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

Needs Node.js 22.19.0 or later.

Then check that it worked:

kimi --version

If you see a version number, Kimi Code is installed.

Safety habit: these lines download and run a script. Only run install commands that come from the official Kimi documentation, and check the address is code.kimi.com before you press Enter.
Step 2

Open your project and start Kimi Code

Kimi Code works on the folder you start it in. So first move into your project folder, then start it.

cd your-project
kimi

Replace your-project with the path to your own folder. When Kimi Code opens, you will see a box where you can type.

Tip: type /help at any time to see every command and shortcut.
Step 3

Sign in

  1. Inside Kimi Code, type /login and press Enter.
  2. Choose Kimi Code if you have a membership. Choose Kimi Platform API key if you pay as you go.
  3. For a membership: open the link it shows on any device, sign in to your Kimi account, and enter the code.
  4. For an API key: paste the key you created on the Kimi platform.
  5. Type /usage to confirm your plan and how much quota you have left.
Keep keys private. Never paste an API key into a chat, a public file or a website other than the official Kimi platform. To sign out later, type /logout.
Step 4

Make your project safe first

Kimi Code can change files. Before your first task, save a snapshot of your project so you can always go back. If your project uses Git, run this in a normal terminal window:

git add -A && git commit -m "Before Kimi Code"

No Git? Make a copy of the project folder instead. It takes ten seconds and does the same job.

Good first project: start with a small personal or test project, not important work code. Check your company's rules before using any AI tool on work code.
Step 5

Your first coding task

Do this in three small moves: look, plan, then change. Each one builds your trust in the tool.

A. Look: ask it to explain the project

This only reads files, so nothing can break. Reading runs without asking you.

Explain the project

Read this project and explain how it is organized. List the main folders, what each one does, and how to run it. Do not change any files.

B. Plan: describe one small change

Press Shift + Tab to turn on Plan mode. Kimi Code will write a plan before it touches anything. Then ask for something small and easy to check.

Plan a small change

I want to add a "Back to top" link to the footer of the home page. Make a short plan first. Tell me which files you will change and why, and wait for my OK.

C. Change: approve and watch

  1. Read the plan. If something looks wrong, say so in plain words and it will revise the plan.
  2. When you are happy, tell it to go ahead.
  3. Kimi Code asks before it edits a file or runs a command. Read each request, then approve or refuse.
  4. Ask it to run your tests, or to tell you how to check the change yourself.
my-project $ cd my-project $ kimi > Add a "Back to top" link to the footer ● Reading index.html, style.css ... ● Plan: 1) add link 2) style it 3) run tests ? Allow edit to index.html? [ Yes ] No ✓ 2 files changed ✓ Tests passed

A first task from start to finish. Your screen will look a little different.

Keep the first task tiny. A small text change, a new link, a renamed button or one failing test is ideal. Small tasks are easy to review, and reviewing is the skill you are learning.
Step 6

Review the changes, then keep or undo

Never skip this step. Kimi Code is good, but it can misunderstand you or make mistakes, like any assistant.

See what changed

In a normal terminal, this shows every line that was added or removed.

git diff

Happy? Keep it

Save the work as a new snapshot.

git add -A && git commit -m "Add back to top link"

Not happy? Undo it

This puts your edited files back to the last snapshot.

git restore .

New files it created are not removed by this. Delete those by hand.

You can also ask Kimi Code itself: "Summarize what you changed, file by file." It is a quick way to check its work against the diff.

NEXT TASKS

Prompts to try next

Once the first task works, try these. Each one is a little bigger than the last.

Fix a failing test

Run the tests. If any fail, find the cause, fix it, run the tests again and tell me what you changed.

Add tests

Write tests for the main functions in this file. Cover the normal case and two edge cases. Run them and show me the result.

Explain one file

Explain what this file does in plain English, step by step. Point out anything that looks risky or confusing.

Tidy up safely

Suggest three small clean-ups for this file that do not change how it behaves. Show me the plan before you edit anything.

Write the README

Read the project and write a clear README with what it does, how to install it and how to run it.

Build from a picture

Here is a screenshot of a page design. Build it as a responsive web page and match the colours, spacing and fonts as closely as you can.

The last one uses Kimi's vision. Press Ctrl + V to paste an image. See the Visual Coding guide and Design to Code.

REFERENCE

Kimi Code commands and shortcuts

Commands you type

CommandWhat it does
/helpShows all commands and shortcuts
/loginSigns you in
/modelSwitches the model
/usageShows your quota and plan
/newStarts a fresh session for a new task
/sessionsOpens a past session again
/compactShortens a long session so it keeps working well
/exitCloses Kimi Code

Keyboard shortcuts

KeysWhat they do
Shift + TabTurns Plan mode on or off
EscStops the current answer
Ctrl + CStops the answer. Press twice when idle to exit
Ctrl + VPastes an image
Ctrl + OShows or hides long tool output
Ctrl + SSends a message while it is still working

From the normal terminal

kimi -c

Continues your last session.

kimi upgrade

Updates Kimi Code to the newest version.

CHECKLIST

Setup and first task checklist

Tick these off as you go.

0 of 8 done

Your ticks are not saved if you close or reload this page.

HELP

Fix common setup problems

"kimi: command not found"
  • Close your terminal and open a new one, then try kimi --version again.
  • Run the install command once more and read its last lines for any error.
  • If you installed with npm, check Node.js is version 22.19.0 or later with node --version.
It will not start on Windows
  • Install Git for Windows, then open a new PowerShell window and try again.
  • If Git Bash is installed in an unusual place, the official docs describe a KIMI_SHELL_PATH setting that points to bash.exe.
Sign-in does not finish
  • Open the link again and enter the code exactly as shown. Codes expire, so run /login again for a fresh one.
  • Make sure you sign in with the account that holds your membership.
  • More help: the login guide.
It says I have no quota
  • Type /usage to see your plan and limits.
  • Kimi Code has usage limits that reset over time. Wait for the reset, or upgrade at kimi.com/code.
  • See Kimi pricing for how plans compare.
It changed something I did not want
  • Press Esc to stop it.
  • Run git restore . in a normal terminal to put edited files back, or use your folder copy.
  • Next time, use Plan mode and give a smaller, more exact task.
Answers get worse in a long session
  • Type /new to start fresh for each new task.
  • Or type /compact to shorten the current session.

Is Kimi itself down? See Kimi not working.

FAQ

Kimi Code questions

No. Kimi Code needs a paid Kimi Code membership, or a pay-as-you-go API key from the Kimi platform. Check kimi.com/code for current plans, because Moonshot has been changing how coding plans work.

Yes. Install Git for Windows first, then run the PowerShell install command. Kimi Code uses the Git Bash that comes with Git for Windows.

Not if you use the install script. You only need Node.js (version 22.19.0 or later) if you choose to install with npm or pnpm.

By default, no. It reads files on its own, but it asks for your confirmation before it edits a file or runs a shell command. Read each request before you approve it.

Run "kimi upgrade" in your terminal and choose to install the update. If you installed with npm, run "npm install -g @moonshot-ai/kimi-code@latest".

Type /model inside Kimi Code to see and switch the models on your plan, such as Kimi K2.7 Code and Kimi K3. The list depends on your membership.
NEXT

Related guides

Ready to try Kimi Code?

Plans, sign-in and the official documentation are on Moonshot's own site.