DEV Community

Cover image for Kimi Code CLI: How to Install and Run Moonshot's Agentic Coding Agent
Hassann
Hassann

Posted on • Originally published at apidog.com

Kimi Code CLI: How to Install and Run Moonshot's Agentic Coding Agent

Moonshot AI shipped Kimi Code alongside the Kimi K2.7 Code model. It is a terminal-native coding agent that can read your repo, edit files, run shell commands, and spawn sub-agents for parallel work. If you already use Claude Code or Codex, the workflow will feel familiar. The main difference is the backend model and pricing: Kimi Code runs on an open-weight model and uses a flat subscription instead of per-token billing.

Try Apidog today

This guide walks through installation, login, first-run setup, daily commands, editor integration, and API testing.

What Kimi Code is

Kimi Code is Moonshot’s coding-agent framework for the K2.7 Code model. It is designed for multi-step coding tasks where the agent needs to inspect files, reason across turns, call tools, and update code.

Kimi Code overview

Out of the box, Kimi Code can:

  • Write, debug, and refactor code across multiple files
  • Explore and explain large codebases
  • Run shell commands and process files
  • Search the web for docs and current information
  • Spawn sub-agents to run tasks in parallel

You can run it in:

  • A terminal
  • VS Code through the Kimi Code extension
  • JetBrains or Zed through the ACP protocol
  • OpenAI-compatible tools using the Moonshot API

The model behind it is open weight, so the same model can also be self-hosted if your team needs that. For model-level details, see the Kimi K2.7 Code explainer.

Install Kimi Code

The installer first pulls in uv, then installs the Kimi Code CLI.

macOS and Linux

curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Windows PowerShell

irm https://code.kimi.com/kimi-code/install.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

After installation, move into the repo you want Kimi Code to work on:

cd path/to/your-repo
kimi
Enter fullscreen mode Exit fullscreen mode

Kimi Code treats the current directory as the project root, so always launch it from the repo root unless you intentionally want to scope it to a subdirectory.

Log in

Inside the Kimi Code session, run:

/login
Enter fullscreen mode Exit fullscreen mode

This starts an OAuth flow with your Kimi account and connects the CLI to the Kimi Code platform.

If you want to use Kimi from another tool, generate an API key from the Kimi Code console. Each account allows up to 5 keys.

You can check your current quota at any time:

/usage
Enter fullscreen mode Exit fullscreen mode

Kimi Code uses subscription plans. Limits refresh every 7 days instead of monthly. Depending on your plan, rate limits are around 300 to 1200 requests per 5 hours, with up to 30 concurrent requests.

Run your first agent task

Start by letting Kimi Code inspect your project:

/init
Enter fullscreen mode Exit fullscreen mode

/init analyzes the codebase and writes an AGENTS.md file. That file captures project structure, conventions, commands, and important entry points.

This is useful because future sessions can start from that saved context instead of rediscovering the repo each time. If you have used DESIGN.md for coding agents, AGENTS.md serves a similar purpose, but Kimi Code generates it automatically.

After initialization, give the agent a concrete task:

Add input validation to the POST /users endpoint and write a test for the empty-email case.
Enter fullscreen mode Exit fullscreen mode

A good task prompt should include:

  • The feature or bug to change
  • The files, endpoint, or module if you know them
  • The expected behavior
  • Whether tests should be added or updated

Example:

In the user service, reject requests where email is empty or missing. Add tests for both cases and run the relevant test command before finishing.
Enter fullscreen mode Exit fullscreen mode

By default, Kimi Code asks before potentially destructive actions. If you want it to proceed without repeated approvals, toggle auto-approval:

/yolo
Enter fullscreen mode Exit fullscreen mode

Use /yolo carefully. It is convenient for experiments and scratch projects, but risky on important branches.

Slash commands you will use often

Command What it does
/help List all commands
/login Authenticate with your Kimi account
/init Analyze the project and generate AGENTS.md
/model Switch the active model
/usage Check remaining quota for the current cycle
/sessions List past sessions
/resume Reopen a previous session with its context
/clear Reset the current context
/compact Compress the conversation to free up context
/yolo Toggle auto-approval of actions
/exit Quit the session

The most useful command during long sessions is often:

/compact
Enter fullscreen mode Exit fullscreen mode

Agent runs can fill the context window with logs, diffs, and tool output. /compact summarizes the session so you can continue without starting over.

Connect Kimi Code to your editor or existing agent

You do not need to replace your current setup to try the K2.7 Code model.

VS Code

Install the Kimi Code extension from the marketplace and sign in with the same account.

JetBrains and Zed

Use the CLI’s ACP protocol integration so the agent can run inside your editor.

Claude Code, Cline, and RooCode

Kimi K2.7 Code is available through an OpenAI-compatible API.

Use:

Base URL: https://api.moonshot.ai/v1
Model: kimi-k2.7-code
Enter fullscreen mode Exit fullscreen mode

Then add your API key from the Kimi platform console.

The setup is similar to the flow for running Kimi inside Claude Code and Cursor. The main change is the model ID.

Customize Kimi Code with MCP and sub-agents

Two features are worth configuring once you move beyond basic tasks.

Use MCP tools

Kimi Code is an MCP client. That means you can connect external tool servers such as:

  • Database readers
  • Browser automation tools
  • Internal APIs
  • Issue trackers
  • Documentation search tools

Once connected, Kimi Code can call those tools during a task.

If you are building or validating an MCP server, this MCP server testing playbook explains how to test the tool contract before giving it to an agent.

Use sub-agents for parallel work

Kimi Code can spawn sub-agents for tasks that split cleanly.

Good examples:

Scan every service for usage of the deprecated auth helper and report the files that need changes.
Enter fullscreen mode Exit fullscreen mode
Draft tests for these six modules in parallel, then summarize the coverage gaps.
Enter fullscreen mode Exit fullscreen mode

You define custom agents in config, similar to Claude Code subagents.

Test the API before building around it

If you are wiring kimi-for-coding or kimi-k2.7-code into your own tool, test the raw API first. That helps you verify response shape, tool-call structure, status codes, and token usage before you write integration code.

Apidog gives you a visual workspace for this.

Create a request like this:

POST https://api.moonshot.ai/v1/chat/completions
Authorization: Bearer <your-key>
Content-Type: application/json
Enter fullscreen mode Exit fullscreen mode

Example body:

{
  "model": "kimi-k2.7-code",
  "messages": [
    {
      "role": "user",
      "content": "Explain the responsibilities of this service and suggest one safe refactor."
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

In Apidog:

  1. Create a POST request to https://api.moonshot.ai/v1/chat/completions.
  2. Add Authorization: Bearer <your-key> using a key from the Kimi platform console.
  3. Send an OpenAI-style body with "model": "kimi-k2.7-code" and your messages.
  4. Inspect the formatted response and token usage.
  5. Save the request as a reusable test.

From there, you can assert on status codes, validate response fields, and re-run the checks whenever Moonshot updates the model.

Download Apidog to set it up.

Is Kimi Code worth switching to?

It depends on what you optimize for.

The K2.7 Code model trails GPT-5.5 and Claude Opus by a few points on most coding benchmarks, so if you only care about the highest single-shot coding score, closed frontier models still lead.

But Kimi Code combines:

  • A capable terminal-native agent
  • An open-weight model
  • Flat-rate pricing
  • IDE and OpenAI-compatible API support
  • MCP and sub-agent support

That combination matters if you run long agent sessions throughout the day.

For a broader comparison of the agent landscape, see this Claude Code vs OpenAI Codex comparison.

The low-risk way to evaluate it:

cd path/to/side-project
kimi
Enter fullscreen mode Exit fullscreen mode

Then run:

/init
Enter fullscreen mode Exit fullscreen mode

And give it one real task from your backlog. You will know quickly whether it deserves a place next to your current agent.

FAQ

How do I install Kimi Code?

Run the installer for your OS:

curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Or on Windows PowerShell:

irm https://code.kimi.com/kimi-code/install.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

Then start it with:

kimi
Enter fullscreen mode Exit fullscreen mode

How do I log in?

Run this inside the session:

/login
Enter fullscreen mode Exit fullscreen mode

For third-party tools, create an API key in the Kimi Code console.

Which model does it run?

Kimi K2.7 Code.

On the Kimi Code subscription, the model ID is:

kimi-for-coding
Enter fullscreen mode Exit fullscreen mode

On the pay-per-token Moonshot API, the model ID is:

kimi-k2.7-code
Enter fullscreen mode Exit fullscreen mode

Does it work in VS Code?

Yes. Install the Kimi Code extension and sign in.

JetBrains and Zed connect through the ACP protocol.

Can I use it with Claude Code or Cline?

Yes. The API is OpenAI-compatible. Point the tool to the Kimi endpoint and set the model ID.

https://api.moonshot.ai/v1
Enter fullscreen mode Exit fullscreen mode
kimi-k2.7-code
Enter fullscreen mode Exit fullscreen mode

What does it cost?

Kimi Code runs on subscription plans with quota that refreshes every 7 days. It is not billed per token in the Kimi Code subscription flow.

Check your quota with:

/usage
Enter fullscreen mode Exit fullscreen mode

Does it support MCP?

Yes. Kimi Code is an MCP client and supports custom sub-agents.

Summary

Kimi Code is a terminal-and-IDE coding agent built on Moonshot’s open-weight K2.7 Code model.

The practical setup is:

  1. Install the CLI.
  2. Start it from your repo root with kimi.
  3. Log in with /login.
  4. Run /init to generate AGENTS.md.
  5. Give it a specific coding task.
  6. Use /compact, /resume, and /usage during longer sessions.
  7. Test API integrations in Apidog before building around them.

It may not be the highest-scoring coding agent on paper, but flat-rate pricing, open-weight model access, MCP support, and editor integrations make it a strong option for heavy daily agent use.

Top comments (0)