How to Run the Kimi-Code Application: Installation, CLI Commands, and TUI Walkthrough

Run the kimi binary after installing via the official script, authenticate with /login on first launch, then use the TUI for interactive sessions or CLI flags for one-off tasks.

The kimi-code application from MoonshotAI/kimi-code is a terminal-based AI coding assistant that ships as a self-contained binary. This guide explains how to install, authenticate, and run the application using both its interactive TUI and command-line interface, with references to the actual source implementation in apps/kimi-code.

Installation: Get the Kimi-Code Binary

Kimi-code distributes pre-built binaries through install scripts. Choose your platform:

macOS and Linux

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

This script downloads the appropriate binary and places it on your PATH【source 5†https://github.com/MoonshotAI/kimi-code/blob/main/README.md#L14-L20】.

Windows (PowerShell)

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

Verify the installation:

kimi --version

This prints the current version and confirms the binary is executable【source 6†https://github.com/MoonshotAI/kimi-code/blob/main/README.md#L32-L34】.

Running Kimi-Code: Two Modes

The application supports interactive TUI sessions and one-off CLI commands. The entry point is apps/kimi-code/src/main.ts, which parses arguments and routes to the appropriate handler.

Interactive TUI Mode (Default)

Navigate to your project directory and run:

cd /path/to/your/project
kimi

This launches the TUI (Terminal User Interface) built on pi-tui【source 1†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/tui/tui-state.ts】. The main loop in src/main.ts initializes the runtime environment, resolves the data directory (~/.kimi-code), loads bundled binaries, and hands control to src/tui/tui-state.ts【source 3†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/main.ts】.

First-Time Authentication

On initial launch, run this command inside the TUI:


/login

Choose OAuth or API-key authentication. The session token persists to the data directory for subsequent runs【source 8†https://github.com/MoonshotAI/kimi-code/blob/main/README.md#L47-L51】.

One-Off CLI Commands

Skip the TUI for quick tasks using run-prompt or sub-agents:

Execute a single prompt:

kimi run-prompt "Explain the main directories of this repo"

This command is implemented in src/cli/run-prompt.ts and processes the request without loading the full UI【source 9†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/cli/run-prompt.ts】.

Use a specialized sub-agent:

kimi coder "Add a unit test for my new function"

Sub-agents (coder, explore, plan) are dispatched from the TUI's command palette and execute focused tasks【source 10†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/tui/utils/foreground-task.ts】.

Runtime Architecture: What Happens When You Run

Understanding the three-layer architecture helps troubleshoot issues when running kim-code:

Layer Purpose Key Source File
Bootstrap Detects platform, resolves $KIMI_CODE_HOME, prepares ~/.kimi-code data and binary directories src/utils/paths.ts【source 2†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/utils/paths.ts】
Core CLI Parses --agent/--agent-file flags, routes commands (run-shell, run-prompt, etc.) src/main.ts【source 3†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/main.ts】
TUI / Runtime Manages interactive UI, event handling, plugin execution, and feedback loops src/tui/tui-state.ts【source 4†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/tui/tui-state.ts】

The native asset manager (src/native/native-assets.ts) locates bundled executables like fd and rg in dist-native/bin, enabling tool-augmented responses without external dependencies【source 1†https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/tui/tui-state.ts】.

Advanced: Running from Source

For development or customization, build and run from the repository:


# Clone and install dependencies

git clone https://github.com/MoonshotAI/kimi-code.git
cd kimi-code
npm install

# Build the binary

npm run build

# Run the development build

node apps/kimi-code/dist/main.js

The build process compiles TypeScript and bundles native assets into the dist-native/bin directory.

Platform Support

Kimi-code runs on:

  • macOS (Intel and Apple Silicon)
  • Linux (x86_64, ARM64)
  • Windows (via Git Bash or native PowerShell)

The bootstrap layer in src/utils/paths.ts handles platform-specific path resolution and directory creation automatically.

Summary

  • Install with the official curl/PowerShell scripts, then verify with kimi --version
  • Authenticate once using /login inside the TUI; credentials persist to ~/.kimi-code
  • Run interactively with bare kimi command in any project directory
  • Execute one-off tasks with kimi run-prompt "<query>" or kimi coder "<task>"
  • Architecture: Bootstrap (paths.ts) → CLI routing (main.ts) → TUI runtime (tui-state.ts)

Frequently Asked Questions

Do I need to authenticate every time I run kimi-code?

No. Run /login once inside the TUI on first launch. The session token persists to ~/.kimi-code as handled by the authentication flow in src/tui/tui-state.ts. Subsequent launches use the cached credentials automatically.

Can I use kimi-code without the interactive TUI?

Yes. Use kimi run-prompt "<your question>" for single queries, or invoke sub-agents directly like kimi coder "<task description>". These commands execute via src/cli/run-prompt.ts without initializing the full terminal interface.

Where does kimi-code store its data and bundled binaries?

Runtime data lives in ~/.kimi-code (or $KIMI_CODE_HOME if set). Bundled native binaries like fd and rg are managed by src/native/native-assets.ts and extracted to dist-native/bin within the application directory. Platform detection and path resolution occur in src/utils/paths.ts.

What sub-agents are available when running kimi-code?

The main sub-agents include coder (code generation/editing), explore (repository exploration), and plan (task planning). These are dispatched through the foreground task system in src/tui/utils/foreground-task.ts and can be invoked directly from the CLI or selected in the TUI command palette.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →