### Start Kimi Server Service Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Starts the OS-managed Kimi server service. This command will error if the service has not been installed. ```bash kimi server start ``` -------------------------------- ### Install Kimi Code CLI Source: https://www.kimi.com/code/docs/en Use this command to install the Kimi Code CLI. This is the recommended method for developers who prefer terminal operations. ```bash curl -fsSL https://kimi.ai/cli/install.sh | bash ``` -------------------------------- ### Verify Kimi Code CLI Installation Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Run this command after installation to confirm the executable is available and check its version. ```bash kimi --version ``` -------------------------------- ### Complete Kimi Code Configuration Example Source: https://www.kimi.com/code/docs/en/kimi-code-cli/configuration/config-files.html This TOML example demonstrates commonly used configuration fields for Kimi Code CLI, including default model, provider settings, model specifics, thinking parameters, loop control, background task limits, and hook configurations. Adjust these values to suit your needs. ```toml default_model = "kimi-code/kimi-for-coding" default_permission_mode = "manual" default_plan_mode = false merge_all_available_skills = true telemetry = true [providers."managed:kimi-code"] type = "kimi" base_url = "https://api.kimi.com/coding/v1" api_key = "" [models."kimi-code/kimi-for-coding"] provider = "managed:kimi-code" model = "kimi-for-coding" max_context_size = 262144 [thinking] enabled = true effort = "high" [loop_control] max_retries_per_step = 3 reserved_context_size = 50000 [background] max_running_tasks = 4 keep_alive_on_exit = false [experimental] micro_compaction = false [[permission.rules]] decision = "allow" pattern = "Read" [[permission.rules]] decision = "deny" pattern = "Bash(rm -rf*)" [[hooks]] event = "PreToolUse" matcher = "Bash" command = "node ~/.kimi-code/hooks/check-bash.mjs" timeout = 5 ``` -------------------------------- ### Start a Basic Goal Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/goals.html Initiate a goal by writing the objective after the `/goal` command. Kimi Code will save this objective and enter goal mode. ```shell /goal Fix bugs listed in the issue tracker. ``` -------------------------------- ### Start Kimi Visualizer Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Launches the Kimi visualizer. Can open to the home view, a specific session, or bind to a fixed port and host without opening a browser. ```bash kimi vis ``` ```bash kimi vis 01HZ...XYZ ``` ```bash kimi vis --host 0.0.0.0 --port 8123 --no-open ``` -------------------------------- ### Install Kimi Code CLI with npm Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Install Kimi Code CLI globally using npm. This method requires Node.js version 22.19.0 or later. ```shell node --version npm install -g @moonshot-ai/kimi-code ``` -------------------------------- ### Launch Kimi Code CLI Interactive UI Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Navigate to your project directory and run this command to start the interactive user interface for Kimi Code. ```bash cd your-project kimi ``` -------------------------------- ### Handle Goal Objectives Starting with Reserved Words Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/slash-commands.html When a goal objective needs to start with a word that is also a subcommand (e.g., `cancel`, `manage`), use `--` to differentiate. For objectives starting with `cancel`, `status`, etc., place `--` after `/goal`. For objectives starting with `manage` after `next`, place `--` after `/goal next`. ```bash /goal -- cancel the old rollout note after the new docs are published ``` ```bash /goal next -- manage the release checklist ``` -------------------------------- ### Install Kimi Code CLI with pnpm Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Install Kimi Code CLI globally using pnpm. This method also requires Node.js version 22.19.0 or later. ```shell pnpm add -g @moonshot-ai/kimi-code ``` -------------------------------- ### OpenAI Compatible Full Endpoint Example Source: https://www.kimi.com/code/docs/en An example of a full API request address for tools using the OpenAI compatible protocol. ```text https://api.kimi.com/coding/v1/chat/completions ``` -------------------------------- ### Visualize Kimi Session Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Launch the session visualizer in your browser to inspect a session as it unfolds. The command starts an in-process server and opens your browser. ```sh kimi vis [sessionId] [options] ``` -------------------------------- ### Basic `kimi` Command Usage Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Run `kimi` without arguments to start an interactive session in the current working directory. ```shell kimi [options] kimi [options] ``` ```shell kimi ``` -------------------------------- ### Install Kimi Code on Windows (PowerShell) Source: https://www.kimi.com/code/docs/en Use this PowerShell command to install Kimi Code on Windows systems. ```powershell irm https://code.kimi.com/kimi-code/install.ps1 | iex ``` -------------------------------- ### Install Kimi Code on macOS/Linux Source: https://www.kimi.com/code/docs/en Use this command to install Kimi Code on macOS and Linux systems via curl. ```bash curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash ``` -------------------------------- ### Open Kimi Web UI Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Opens Kimi's graphical session in the web browser. This command starts a local Kimi server in the background (if not already running) and automatically opens the web UI. ```bash kimi web ``` -------------------------------- ### kimi vis Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Launches the session visualizer in your browser to inspect a session as it unfolds. The command starts an in-process server, prints the URL, opens your browser, and keeps running until interrupted. ```APIDOC ## kimi vis ### Description Launch the session visualizer in your browser to inspect a session as it unfolds. The command starts an in-process server pointed at your local sessions, prints the URL, opens your browser, and keeps running until you press `Ctrl-C`. ### Method `sh kimi vis [sessionId] [options]` ### Parameters #### Path Parameters - **sessionId** (string) - Optional - Open the visualizer directly to this session. When omitted, it opens the home view listing your sessions. #### Options - **--port ** - Type: number - Description: Port to bind. By default an available port is picked automatically. - **--host ** - Type: string - Description: Host to bind. Default: `127.0.0.1`. - **--no-open** - Type: boolean - Description: Do not open the browser automatically; just print the URL. ### Request Example ```sh # Example usage (no specific examples provided in source for options) kimi vis kimi vis 01HZ...XYZ kimi vis --port 8080 kimi vis --no-open ``` ``` -------------------------------- ### Install Kimi Server as an OS Service Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Registers the Kimi server as an OS-managed service for automatic startup and crash recovery. The command adapts to the current platform (macOS, Linux, Windows). ```bash kimi server install --port 58627 --log-level info ``` -------------------------------- ### Run Kimi Server Daemon Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Starts the Kimi server, which exposes REST and WebSocket APIs and serves the web UI. It can run as a background daemon or in the foreground. ```sh kimi server run # start or reuse a background daemon ``` ```sh kimi server run --foreground # run attached to the current terminal ``` -------------------------------- ### Check Kimi Server Status Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Prints the status of the installed Kimi server service, including installation, running state, PID, port, and log path. Use the --json flag for automation. ```bash kimi server status ``` ```bash kimi server status --json ``` -------------------------------- ### Generate Project Architecture Overview Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/use-cases.html Use this prompt to get a high-level understanding of a repository's architecture, including entry points, module dependencies, and configuration loading. It can also generate a module dependency diagram. ```shell Give me an overview of this repository's architecture. Specifically: 1. Where is the entry point and what happens at startup? 2. How do the main modules depend on each other? 3. How are configuration and data loaded? Finally, draw a simple module dependency diagram. ``` -------------------------------- ### Anthropic Compatible Full Endpoint Example Source: https://www.kimi.com/code/docs/en An example of a full API request address for tools using the Anthropic compatible protocol. ```text https://api.kimi.com/coding/v1/messages ``` -------------------------------- ### Queue Upcoming Goal with /goal next Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/goals.html Use this command to queue a new goal without interrupting the current one. If no goal is active, it starts immediately. ```shell /goal next Update the release notes after the tests pass ``` -------------------------------- ### Start or Manage Autonomous Goal Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/slash-commands.html Use `/goal` to start or manage autonomous goals. This feature allows Kimi Code to work towards a persistent objective across turns. See Goals for usage guidance. ```bash /goal Update the checkout docs, run docs build, and stop if still blocked after 20 turns ``` -------------------------------- ### Define a Skill with YAML Frontmatter and Markdown Body Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/skills.html This example shows the structure of a Skill file, including YAML frontmatter for metadata and a Markdown body for instructions. Ensure all required fields like 'name' and 'description' are present in the frontmatter for directory-form skills. ```markdown --- name: code-style description: Project code style guidelines defining naming, indentation, comments, and file organization type: prompt whenToUse: When the user asks me to write, modify, or review project source code disableModelInvocation: false arguments: - target - mode --- Please handle code according to the following guidelines: - Use 2-space indentation - Variable names use `camelCase`, type names use `PascalCase` - Public functions must have TSDoc comments - Lines must not exceed 100 characters ``` -------------------------------- ### Plugin Directory Structure for Skills Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/plugins.html Example directory structure for a plugin that includes skills. The `skills` field in `kimi.plugin.json` points to the directory containing `SKILL.md` files. ```text my-plugin/ kimi.plugin.json skills/ using-my-plugin/ SKILL.md another-workflow/ SKILL.md ``` -------------------------------- ### Enter Plan Mode Temporarily Source: https://www.kimi.com/code/docs/en/kimi-code-cli/configuration/overrides.html Start Kimi Code CLI in Plan mode for the current session. To make this permanent, set `default_plan_mode = true` in the config file. ```shell kimi --plan ``` -------------------------------- ### Plugin Directory Structure for Commands Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/plugins.html Example directory structure for a plugin that includes slash commands. The `commands` field in `kimi.plugin.json` points to the location of command definition files. ```text kimi-finance/ kimi.plugin.json commands/ report.md ``` -------------------------------- ### Start a Goal in TUI Source: https://www.kimi.com/code/docs/en/kimi-code-cli/release-notes/changelog.html Use the `/goal` slash command within the TUI to initiate a new goal-oriented task. Provide the objective as an argument to the command. ```text /goal Fix the failing checkout test ``` -------------------------------- ### MCP Server Configuration Example Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/mcp.html Defines MCP servers in `mcp.json`. Use `command` for stdio servers and `url` for HTTP servers. `transport: "sse"` is for legacy SSE endpoints. ```json { "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"] }, "linear": { "url": "https://mcp.linear.app/mcp" }, "legacy-events": { "transport": "sse", "url": "https://mcp.example.com/sse" } } } ``` -------------------------------- ### Run Kimi Web UI without Opening Browser Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Starts a local Kimi server in the background without automatically opening the web browser. This is equivalent to `kimi server run --no-open`. ```bash kimi web --no-open ``` -------------------------------- ### Upgrade Kimi Code CLI using npm Source: https://www.kimi.com/code/docs/en/kimi-code/faq.html Use npm to install the latest version of Kimi Code CLI. This command ensures you have the most up-to-date features and bug fixes. ```sh npm install -g @moonshot-ai/kimi-code@latest ``` -------------------------------- ### Start `kimi acp` in ACP Mode Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-acp.html Execute this command to switch the Kimi Code CLI to ACP mode. It will then communicate with an ACP client using JSON-RPC over stdin/stdout. ```bash kimi acp ``` -------------------------------- ### Skill Definition Example (review-pr) Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/skills.html This markdown file defines a 'review-pr' Skill. It specifies the skill's name, description, type, when to use it, and its arguments. The 'arguments' section details expected inputs for the skill. ```markdown --- name: review-pr description: Review a Pull Request according to team standards and produce a structured review report type: prompt whenToUse: When the user asks me to review a PR, inspect code changes, or evaluate commit quality arguments: - pr_ref --- Please review the PR the user specified: $pr_ref 1. Fetch and read the full diff for `$pr_ref`. 2. Check each of the following items: - Whether corresponding test cases are included - Whether public API documentation has been updated - Whether new dependencies have been introduced; if so, state the reason - Whether error handling covers edge cases 3. Refer to the checklist in the same directory: `references/checklist.md` 4. Produce a review report containing: - Overall conclusion (approve / request changes / comment) - Required changes (blocking) - Suggested improvements (non-blocking) - Noteworthy positives ``` -------------------------------- ### Enable Experimental Goal Mode Source: https://www.kimi.com/code/docs/en/kimi-code-cli/release-notes/changelog.html To enable the experimental goal mode for longer tasks, set the environment variable `KIMI_CODE_EXPERIMENTAL_GOAL_COMMAND` to `1` before starting Kimi Code CLI. ```bash KIMI_CODE_EXPERIMENTAL_GOAL_COMMAND=1 ``` -------------------------------- ### Manage Kimi Server Service Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Commands to manage the Kimi server as an OS-managed service, including installation, starting, stopping, and checking status. ```sh kimi server install # register with launchd / systemd / schtasks ``` ```sh kimi server start # start the OS-managed service ``` ```sh kimi server status # snapshot of installed/running state ``` -------------------------------- ### Describe Project Directory Structure Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Use this prompt to have Kimi Code CLI analyze and describe your project's directory structure. Read-only operations are executed automatically. ```shell Take a look at this project's directory structure and briefly describe what each directory is for. ``` -------------------------------- ### Uninstall Kimi Code CLI via npm Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Remove the Kimi Code CLI from your system if it was installed using npm. ```bash npm uninstall -g @moonshot-ai/kimi-code ``` -------------------------------- ### Access Help Panel Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html Type `/help` to open the built-in command and keyboard shortcut panel. Use arrow keys to navigate and Esc to close. ```shell /help ``` -------------------------------- ### Schedule a Future Check Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/use-cases.html Use this prompt to schedule a check in the future, for example, to see if a build has finished. The agent will re-prompt you at the specified time. ```shell Come back in about 10 minutes and check whether the build has finished. ``` -------------------------------- ### Initiate Kimi Code Login Flow Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started.html In the interactive UI, enter this command to begin the process of authenticating with Kimi Code, which may involve OAuth or API key entry. ```bash /login ``` -------------------------------- ### Validate Kimi Configuration Files Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Validates the default `config.toml` and `tui.toml` files without starting the TUI or modifying them. Checks files under `KIMI_CODE_HOME` by default. ```bash kimi doctor ``` -------------------------------- ### Define a Notification Hook Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/hooks.html Configure a hook to send a terminal notification when a background task completes. This example triggers `terminal-notifier` for 'Task done' messages. ```toml [[hooks]] event = "Notification" # Trigger: when a background task status changes matcher = "task\.completed" # Only care about "completed" notifications command = "terminal-notifier -title Kimi -message 'Task done'" ``` -------------------------------- ### Configure Kimi Server Run Options Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Options for `kimi server run`, including specifying the port, log level, enabling debug endpoints, running in the foreground, and automatically opening the web UI. ```sh kimi server run --port ``` ```sh kimi server run --log-level ``` ```sh kimi server run --debug-endpoints ``` ```sh kimi server run --foreground ``` ```sh kimi server run --open ``` -------------------------------- ### Inquire About Feature Implementation Details Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/use-cases.html Investigate the implementation of a specific feature, like 'permission approval', to identify involved files and key data types. ```shell How is "permission approval" implemented in this project? Which files are involved, and what are the key types? ``` -------------------------------- ### Toggle Plan Mode Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/slash-commands.html Use `/plan` to toggle Plan mode. Without arguments, it flips the current state. Explicitly passing `on` or `off` forces the setting. Toggling Plan mode does not create an empty plan file. ```bash /plan [on|off] ``` -------------------------------- ### kimi migrate Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Migrates local data from a legacy kimi-cli installation to kimi-code, including session history and configuration files. This command runs entirely interactively. ```APIDOC ## kimi migrate ### Description Migrate local data from a legacy kimi-cli installation to kimi-code, including session history and configuration files. Runs entirely interactively, guiding you through the full process. ### Method `sh kimi migrate` ### Notes For full migration instructions, see Migrating from kimi-cli. ``` -------------------------------- ### Custom Marketplace Plugin Manifest Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/plugins.html Defines a plugin's metadata, skills, and session start behavior. `kimi.plugin.json` takes precedence over custom marketplace JSON if both exist. ```json { "name": "kimi-finance", "version": "1.0.0", "description": "Finance data and analysis workflows for Kimi Code CLI", "skills": "./skills/", "sessionStart": { "skill": "using-finance" }, "interface": { "displayName": "Kimi Finance", "shortDescription": "Market data and financial analysis workflows" } } ``` -------------------------------- ### Configure Stdio MCP Server in Plugin Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/plugins.html Define a local command-line tool as an MCP server within a plugin's manifest. The 'command' can be an executable in the system's PATH or a relative path within the plugin directory. 'args' are passed to the command. ```json { "mcpServers": { "finance": { "command": "uvx", "args": ["kimi-finance-mcp"] } } } ``` -------------------------------- ### Internal Connection Error Examples Source: https://www.kimi.com/code/docs/en/kimi-code/error-reference.html This group of errors covers various internal network anomalies on the server side, such as connection resets and timeouts. These are usually transient faults. ```text internal: conn closed internal: driver: bad connection internal: read tcp ...: i/o timeout internal: unexpected EOF internal: failed to evaluate rate limit script: read tcp ...: i/o timeout ``` -------------------------------- ### Event Data Format Example Source: https://www.kimi.com/code/docs/en/kimi-code-cli/customization/hooks.html This JSON structure represents the base information passed to a script when a hook is triggered. Specific events may include additional fields. ```json { "hook_event_name": "PreToolUse", "session_id": "session_abc", "cwd": "/path/to/project" } ``` -------------------------------- ### Implement New Feature with Acceptance Criteria Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/use-cases.html Describe a new feature requirement, including its signature, options, error handling, and necessary unit tests. Use Plan mode for complex changes to confirm the approach. ```shell Add a retry utility under src/utils: - Signature: retry(fn: () => Promise, options): Promise - Options: maxAttempts, initialDelayMs, backoffFactor - On failure, throw the error from the last attempt - Add a unit test suite covering: success on first try, success after retries, and all attempts failing ``` -------------------------------- ### List Configured Providers Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Prints configured providers to the console. Use the --json flag for programmatic processing of provider and model data. ```bash kimi provider list ``` ```bash kimi provider list --json | jq '.providers | keys' ``` -------------------------------- ### Create Goal in Non-Interactive Prompt Mode Source: https://www.kimi.com/code/docs/en/kimi-code-cli/guides/goals.html In non-interactive prompt mode, only goal creation is supported using the 'kimi -p "/goal ..."' command. The prompt mode exits with specific codes based on the goal's outcome. ```shell kimi -p "/goal Fix the failing checkout test" ``` -------------------------------- ### Configure Anthropic Provider with Model Alias Source: https://www.kimi.com/code/docs/en/kimi-code-cli/configuration/providers.html Configure the Anthropic provider for Claude API access. This example also shows how to define a specific model alias with custom context size. ```toml [providers.anthropic] type = "anthropic" api_key = "sk-ant-xxxxx" [models."claude-opus-4-7"] provider = "anthropic" model = "claude-opus-4-7" max_context_size = 200000 # max_output_size = 32000 # optional; omit to use the model-inferred default ``` -------------------------------- ### Configure One-off Test API Key Source: https://www.kimi.com/code/docs/en/kimi-code-cli/configuration/overrides.html Write a test API key into the environment sub-table of the configuration file for provider-specific testing. ```toml [providers.kimi.env] KIMI_API_KEY = "sk-test" ``` -------------------------------- ### Add Provider from Catalog Source: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html Imports a provider directly from the catalog using its ID. Requires an API key and optionally allows setting a default model. ```bash kimi provider catalog list anthropic # Browse available models first ``` ```bash kimi provider catalog add anthropic --api-key sk-ant-... --default-model claude-opus-4-7 ``` -------------------------------- ### Define Permission Rules in config.toml Source: https://www.kimi.com/code/docs/en/kimi-code-cli/configuration/config-files.html Configure automatic permission loading for agent tool calls. Rules are matched in order, and the first match determines the action. Use `allow`, `deny`, or `ask` for decisions, and specify scopes like `turn-override` or `session-runtime`. ```toml [[permission.rules]] decision = "allow" pattern = "Read" [[permission.rules]] decision = "allow" pattern = "Grep" [[permission.rules]] decision = "deny" pattern = "Bash(rm -rf*)" [[permission.rules]] decision = "ask" pattern = "Bash" ```