The Terminal

Kimi Code CLI: Moonshot AI Ships an Open-Source Terminal Agent With Built-In Subagents

Moonshot AI open-sourced Kimi Code CLI — an MIT-licensed terminal coding agent with subagents, MCP support, and lifecycle hooks.

G

Gabriel

Chief AI Correspondent

Kimi Code CLI: Moonshot AI Ships an Open-Source Terminal Agent With Built-In Subagents

Hero image: A sleek modern terminal interface with glowing indigo code streams, AI agent circuits, and neural network patterns flowing through a dark terminal window

The terminal coding agent space just got a serious new entrant. On June 6, Moonshot AI open-sourced Kimi Code CLI — a TypeScript-based terminal agent that reads code, runs shell commands, searches files, and plans its own next steps based on feedback. It's MIT-licensed, installs via npm or a single shell script, and comes with something most terminal agents lack: built-in subagents that run in isolated contexts.

This isn't a wrapper around an existing tool. It's a ground-up rewrite of Moonshot's earlier kimi-cli, designed for long-horizon agent sessions where a single model loop isn't enough. The subagent architecture — coder, explore, and plan — lets the main agent dispatch parallel work streams without context contamination. That's a meaningful architectural choice for anyone running local agents on Linux.

Here's what it does, how it compares, and whether you should install it today.


What Kimi Code CLI Actually Is

At its core, Kimi Code CLI is a feedback-driven execution engine. The agent:

  1. Reads your codebase and terminal environment
  2. Plans a sequence of steps
  3. Runs read-only operations automatically (file reads, searches, web fetches)
  4. Asks for approval before writes or shell commands
  5. Observes the results and adjusts its plan

This approval model is the right default for a tool with file-system access. Read-only operations happen silently; destructive ones require a human gate. You can override with --yolo or /yolo for trusted batch work, but the default posture is safe.

The CLI connects to Moonshot's Kimi models out of the box. You authenticate via OAuth or an Open Platform API key. It can also be pointed at other compatible providers if you want to run it against a local model served through Ollama or vLLM — though the subagent orchestration is tuned for Kimi's context window and tool-use capabilities.


The Subagent Architecture

The standout feature is the subagent system. Kimi Code CLI ships with three built-in subagents:

Subagent Purpose Runs
coder Implements features, fixes bugs, writes tests In isolated context
explore Maps architecture, traces dependencies, answers structure questions In isolated context
plan Generates research plans before file modification In isolated context

These aren't just prompt prefixes. Each subagent runs in its own context isolation, meaning the main agent can dispatch parallel work without the exploration history polluting the coding context, or vice versa. When a subagent finishes, its results are folded back into the main session.

The /fork command creates an experimental branch of the current session you can abandon if it goes wrong. The /compact command compresses context to free tokens. Together with subagents, these are primitives for managing long agent sessions without hitting context limits or losing coherence.


Installation: Two Paths

Kimi Code CLI is distributed as a single binary or npm package. The script install requires no Node.js:

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

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

If you already have Node.js 24.15.0+:

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

Verify and start:

kimi --version
cd your-project
kimi

On first launch, type /login and choose OAuth or API key. One-off tasks without the TUI:

kimi -p "Refactor the auth module to use JWT instead of sessions"

Resume the previous session:

kimi -C

MCP: Configured by Conversation

Kimi Code CLI supports the Model Context Protocol, but with a twist: you add and authenticate MCP servers conversationally via /mcp-config rather than editing raw JSON. This sounds like a small UX detail, but it matters in practice. MCP server configs are often the first thing to drift out of date when you're managing multiple integrations. A conversational interface lowers the friction to keep them current.

Lifecycle hooks are also supported — local commands that gate tool calls, audit decisions, or trigger notifications. If you want your agent to ping Slack before running a database migration, or log every shell command to a local audit trail, hooks make that possible without forking the codebase.


Comparison: Where It Fits

Attribute Kimi Code CLI Claude Code Codex CLI Gemini CLI
Developer Moonshot AI Anthropic OpenAI Google
Model Kimi Claude GPT-5.3-Codex Gemini 2.5 Pro
Runtime TypeScript Node.js Rust TypeScript
License MIT Proprietary Open source Apache 2.0
Subagents Yes (coder/explore/plan) Yes Yes No (sequential)
MCP Yes (/mcp-config) Yes Yes Yes
Plan mode Yes (Shift-Tab) Yes Yes Yes
Install Script or npm Native / npm npm / native npm single binary

The field is converging on a common feature set: terminal-first, MCP-native, approval-gated writes. Where Kimi Code CLI differentiates is the subagent granularity and MIT license. You can fork it, embed it in your own tooling, or run it in air-gapped environments without license anxiety.


Local Model Compatibility

Kimi Code CLI is designed for Kimi models, but the architecture is model-agnostic enough that other providers work if they expose a compatible chat completions API. For Linux self-hosters, this raises an obvious question: can you point it at a local Ollama or vLLM instance?

The short answer: yes, with configuration. Kimi Code CLI accepts a custom base URL and API key, so an Ollama server running qwen3-coder or glm-5.1 on localhost:11434 is reachable. The longer answer: subagent orchestration and tool-use reliability depend on the target model's function-calling accuracy and context window. Kimi K2.6's 256K context and strong tool-use performance are what make the subagent pattern work smoothly. A smaller local model may need num_speculative_tokens tuned down and subagent depth limited.

If you're experimenting with local models, start with the single-agent mode (kimi -p) before enabling subagents. Validate that file reads, searches, and simple edits work reliably. Only then add coder and explore subagents to the mix.


When to Use It

Scenario Recommendation
Greenfield feature implementation ✅ Use coder subagent with clear acceptance criteria
Debugging unfamiliar legacy code ✅ Use explore first, then coder
Batch refactoring across modules ✅ Use --yolo after validating on a subset
One-off log analysis or report generation ✅ Use kimi -p without the TUI
Production database migrations ⚠️ Use lifecycle hooks for audit + approval
Air-gapped / no internet environment ✅ MIT license, self-hosted model compatible

The Bigger Picture

Kimi Code CLI arriving as an MIT-licensed tool from a frontier model lab is part of a trend: the coding agent layer is being commoditized faster than the model layer. Anthropic's Claude Code is proprietary but polished. OpenAI's Codex CLI is open source but Rust-heavy. Google's Gemini CLI is Apache-licensed but lacks subagents. Moonshot's entry adds a TypeScript-native, subagent-capable, fully open-source option to the mix.

For Linux developers running local inference stacks, this matters because:

  1. MIT license means no deployment restrictions — you can ship it inside containers, CI pipelines, or internal developer tools without license review.
  2. TypeScript runtime means it integrates with Node.js tooling — your existing package.json, eslint, and prettier configurations are inspectable by the agent without translation layers.
  3. Subagents map well to local compute constraints — if your GPU can only run one 32B model at a time, the main agent can dispatch subagents sequentially rather than loading multiple models in parallel.

The coding agent space is now a four-way race. Each option has a distinct posture: Claude Code is the polished commercial product, Codex CLI is the Rust performance play, Gemini CLI is the Google ecosystem bridge, and Kimi Code CLI is the open-source extensibility platform. For terminal-dwelling Linux developers who value source access and forkability, Kimi Code CLI is the one to watch.


Installation Checklist

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

# 2. Verify
kimi --version

# 3. Enter a project
cd ~/projects/my-codebase
kimi

# 4. Authenticate
# Inside the TUI: type /login → choose OAuth or API key

# 5. Run a task
kimi -p "List all TODO comments in the src/ directory and group by file"

Kimi Code CLI is available now at github.com/MoonshotAI/kimi-code. MIT licensed. TypeScript. Subagents included.


Sources:

Originally published at smfworks.com.