Kimi Code CLI
A single-binary, terminal-native coding agent that reads, edits, and runs code end to end, built by Moonshot AI for Kimi models but pluggable with Anthropic, OpenAI, and Google providers too.
Repository Health
Technical Analysis
Dependency Health
Kimi Code CLI is Moonshot AI’s open-source, agentic coding tool for the terminal: it reads and edits files, runs shell commands, searches a codebase, fetches web pages, and decides its next step from the feedback it gets back, all inside a purpose-built TUI rather than a bolted-on chat window. It installs as a single native binary via a one-line curl or PowerShell script, so there’s no Node.js runtime, no global npm conflicts, and a startup fast enough that opening a session never feels heavy.
Under the CLI sits a layered monorepo rather than one monolithic app: a VSCode-style dependency-injection container powers the core agent runtime (agent-core and its in-progress successor agent-core-v2), while cross-cutting concerns are split into their own reusable packages — kosong for LLM/provider abstraction, kaos for the execution-environment/tool backend, protocol for the shared client-server schema, and kap-server for an optional HTTP/websocket-exposed engine that also backs the web and VS Code surfaces. A documented goal-mode driver formalizes autonomous multi-turn execution as an explicit active/paused/blocked/complete state machine instead of trusting free-text “I’m done” claims, and a GitHub-sourced plugin marketplace lets teams install skills, MCP servers, and data sources conversationally.
Beyond the terminal, Kimi Code CLI speaks the Agent Client Protocol, so the same authenticated session can drive Zed or any JetBrains IDE over stdio with no second login, and it accepts video input — drop a screen recording into the chat and have the agent turn it into a LUT, a short, or working code. Lifecycle hooks let teams gate risky tool calls, audit decisions, or wire in their own automation at key points in a run.
The project is MIT licensed with no enterprise tier or license-gated features: it works identically against Moonshot AI’s managed Kimi models, a bring-your-own Anthropic, OpenAI, or Google GenAI/Vertex AI key, or any OpenAI-compatible endpoint, so self-hosters aren’t funneled toward a single paid backend.
What You Get
- A single-binary CLI installable with one curl or PowerShell command — no Node.js runtime and no global npm conflicts.
- A purpose-built terminal UI (the project’s own pi-tui library) tuned end to end for long, focused agent sessions.
- Native multi-provider model support so the same CLI can point at Kimi, Claude, GPT, Gemini, Vertex AI, or any OpenAI-compatible endpoint.
- A goal-mode driver that runs autonomous multi-step tasks to a structured completion or blocked state instead of stopping after one turn.
- A conversational MCP server manager (
/mcp-config), a GitHub-sourced plugin marketplace, and lifecycle hooks for gating or auditing tool calls. - First-class editor integration via the Agent Client Protocol for Zed and JetBrains, driving the same session without a second login.
Common Use Cases
- Interactive terminal pair programming on an existing codebase
- Driving the same agent session from inside Zed or JetBrains via ACP
- Long-running autonomous refactors and migrations run in goal mode
- Wiring up custom MCP tools and data sources conversationally
- Turning a screen recording or demo clip into a working code change
Under The Hood
Architecture
Kimi Code CLI is organized as a pnpm monorepo separating concerns into independently versioned packages rather than one monolithic app. Execution starts in apps/kimi-code/src/main.ts, which parses CLI options via Commander.js, runs an update preflight, and dispatches into either a headless print-mode run or the interactive TUI (kimi-tui.ts) built on the project’s own pi-tui rendering library rather than an off-the-shelf framework like Ink. The agent brain lives in packages/agent-core (v1) and its successor agent-core-v2, both built around a VSCode-style dependency-injection container (packages/agent-core/src/di) with branded service identifiers, singleton/child-container resolution, and cycle detection — a conscious tradeoff documented in its own README as ~600 lines of zero-dependency code over pulling in tsyringe or inversify. Cross-cutting abstractions are split into their own packages: kosong is the LLM/provider abstraction layer, kaos is the execution-environment abstraction, protocol defines the shared event schema consumed by both the CLI and the optional kap-server, and acp-adapter implements the Agent Client Protocol so Zed and JetBrains can drive the same session over stdio. A goal-mode driver (documented at length in GOAL.md) formalizes autonomous multi-turn execution as an explicit state machine injected at turn boundaries, and a plugin subsystem with its own manifest/store/manager lets skills and MCP servers be installed from a marketplace or arbitrary GitHub repo — this layering keeps core-abstraction changes isolated behind well-defined package boundaries rather than rippling through the CLI directly.
Tech Stack
The stack is almost entirely TypeScript on Node.js (24.x for development, 22.19+ at runtime), built with tsdown and shipped as a single native binary via Node’s Single Executable Application feature, with custom native-asset build scripts so end users install with a curl or PowerShell script and need no local Node.js at all. The CLI layer uses Commander.js for argument parsing, chalk and cli-highlight for terminal output, and Zod for runtime schema validation; the TUI is the project’s own pi-tui package rather than Ink or blessed. Multi-provider LLM access is normalized through kosong across several protocol types — Moonshot’s OpenAI-compatible kimi endpoint, anthropic, openai, openai_responses, google-genai, and vertexai — with model catalogs optionally pulled from models.dev. Persistence runs through an in-house minidb package rather than a general-purpose database, telemetry is handled by a dedicated kimi-telemetry package, and tooling is Vitest for testing (with a single workspace-wide config spanning every package and app), oxlint (including a type-aware pass) for linting, and Changesets for versioned monorepo releases, backed by CI workflows for standard and native builds plus a Nix flake for reproducible environments.
Code Quality Every package ships its own test directory exercised by Vitest, including substantial suites for security-sensitive surfaces such as the shell-execution tool, which builds fake process-runner and environment doubles to exercise real process-task timeout and interrupt semantics rather than mocking them away. The TypeScript configuration enables full strict mode plus several stricter-than-default flags (no unchecked indexed access, no implicit override, no property access from index signatures, verbatim module syntax), and oxlint runs both a fast pass and a type-aware pass in CI and via pre-commit hooks. Error handling is explicit and typed throughout the sampled tool and auth code via custom error classes rather than swallowed catches, naming is consistent across the DI-container-derived interface conventions, and the release script gates a publish behind typechecking, linting, a monorepo dependency-hygiene check, the full test suite, the build, and package-shape validation before anything ships.
What Makes It Unique Rather than wrapping an existing agent framework, the team built its own layered stack from scratch: a standalone LLM-abstraction package, a standalone execution-environment abstraction, and a hand-rolled VSCode-style DI container chosen explicitly to stay dependency-free — all published as independently reusable packages rather than internal-only code. Distinctive product features include video input for turning a screen recording into a code change, a formalized goal-mode state machine for autonomous multi-turn execution with explicit active/paused/blocked/complete states rather than an ad hoc “continue until done” loop, conversational MCP server configuration instead of hand-edited JSON, and first-class Agent Client Protocol support so the same session drives Zed and JetBrains without a second login. Individually none of these is unprecedented in the broader agentic-coding-CLI space, but the combination of reusable core packages, a documented goal-state machine, and editor-protocol-level integration in one MIT-licensed single-binary tool is a genuinely differentiated design rather than a thin wrapper around an existing SDK.
Self-Hosting
Licensing Model MIT licensed — all CLI code, the TUI, the plugin system, the ACP adapter, and every package in the monorepo are available with no license keys or feature gates in self-hosted use.
Self-Hosting Restrictions
None found. No ee/, enterprise/, pro/, or cloud/ directories exist in the repository, and no license/feature-flag gating (requiresLicense, isPro, isEnterprise) was found anywhere in the source.
Enterprise Features Not applicable — there is no separate paid tier of the CLI itself. The optional Kimi Code OAuth login connects to Moonshot AI’s managed Kimi model service, but the CLI works identically against a self-supplied Anthropic, OpenAI, Google GenAI/Vertex AI, or any OpenAI-compatible provider key, so no CLI feature is withheld from users who bring their own model credentials.
Cloud vs Self-Hosted
Not applicable — this is a local terminal tool, not a hosted SaaS product. The only “cloud” component is the optional managed Kimi model API reachable via /login, which is a model-hosting convenience rather than a feature gate.
License Key Required
No. /login (OAuth) or a provider API key configured in config.toml is required only to reach an LLM backend, never to unlock CLI functionality.
Related Apps
OpenCode
AI Code Assistants
A fully open-source AI coding agent built for the terminal, with a TUI, desktop app, web client, plugin system, and SDK — one of the most-starred AI coding agents on GitHub.
claw-code
AI Agents · AI Code Assistants
A Rust-built CLI agent harness for Claude AI with persistent sessions, MCP tool integration, plugin hooks, and multi-provider support — designed to run autonomous coding workflows without human babysitting.
Ollama
AI Development · Developer Tools
Run Llama, Gemma, DeepSeek, and other open LLMs on your own machine with one command and an OpenAI-compatible API.