### Start Development Server Source: https://github.com/moonshotai/kimi-code/blob/main/docs/AGENTS.md Starts a local development server to preview documentation changes in real-time. ```bash npm run dev ``` -------------------------------- ### Install Kimi Code CLI Source: https://github.com/moonshotai/kimi-code/blob/main/docs/AGENTS.md Use this command to install the Kimi Code CLI. Ensure Node.js 24.15.0 or later and pnpm are installed first. ```bash pnpm install -g kimi-code ``` -------------------------------- ### Minimum Usage of ACP Adapter Source: https://github.com/moonshotai/kimi-code/blob/main/packages/acp-adapter/README.md This snippet demonstrates the basic setup for running the ACP server with the Kimi Code harness. It imports necessary functions and starts the server, which listens for JSON-RPC messages on stdin and writes responses to stdout. ```typescript import { createKimiHarness } from '@moonshot-ai/kimi-code-sdk'; import { runAcpServer } from '@moonshot-ai/acp-adapter'; const harness = await createKimiHarness(); await runAcpServer(harness); ``` -------------------------------- ### Install Dependencies Source: https://github.com/moonshotai/kimi-code/blob/main/docs/AGENTS.md Installs the necessary Node.js dependencies for the documentation build process. ```bash npm install ``` -------------------------------- ### Preview Built Documentation Source: https://github.com/moonshotai/kimi-code/blob/main/docs/AGENTS.md Starts a local server to preview the built static documentation. ```bash npm run preview ``` -------------------------------- ### Plugin Manifest Example Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/customization/plugins.md This is a basic example of a plugin manifest file (kimi.plugin.json). It defines the plugin's name, version, description, and points to its skills directory. ```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" } } ``` -------------------------------- ### Start Kimi Code CLI Interactive UI Source: https://github.com/moonshotai/kimi-code/blob/main/apps/kimi-code/README.md Navigate to your project directory and run this command to start the interactive UI. You will need to log in on first launch. ```sh kimi ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/moonshotai/kimi-code/blob/main/CONTRIBUTING.md Clone the Kimi Code repository and install project dependencies using pnpm. Ensure you have Node.js >= 24.15.0 and pnpm 10.33.0 installed. ```shell git clone https://github.com/MoonshotAI/kimi-code.git cd kimi-code pnpm install ``` -------------------------------- ### Install Kimi Code CLI using pnpm Source: https://github.com/moonshotai/kimi-code/blob/main/apps/kimi-code/README.md Alternatively, install Kimi Code CLI globally using pnpm. Requires Node.js 22.19.0 or later. ```sh pnpm add -g @moonshot-ai/kimi-code ``` -------------------------------- ### Install Kimi Code CLI using npm Source: https://github.com/moonshotai/kimi-code/blob/main/apps/kimi-code/README.md If you prefer npm, install Kimi Code CLI globally using this command. Requires Node.js 22.19.0 or later. ```sh npm install -g @moonshot-ai/kimi-code ``` -------------------------------- ### Verify Kimi Code CLI Installation Source: https://github.com/moonshotai/kimi-code/blob/main/apps/kimi-code/README.md After installation, run this command in a new terminal session to verify the installation and check the version. ```sh kimi --version ``` -------------------------------- ### Complete Kimi Code Configuration Example Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/config-files.md A comprehensive TOML configuration file example for Kimi Code CLI. It includes settings for default model, API providers, model specifics, thinking mode, loop control, background tasks, permissions, and hooks. Adjust these fields to customize your CLI behavior. ```toml default_model = "kimi-code/kimi-for-coding" default_thinking = true 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] mode = "auto" [loop_control] max_retries_per_step = 3 reserved_context_size = 50000 [background] max_running_tasks = 4 keep_alive_on_exit = false [experimental] micro_compaction = true [[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 Kimi Code CLI Interactive UI Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/getting-started.md Navigate to your project directory and run this command to start the Kimi Code CLI interactive terminal user interface. ```sh cd your-project kimi ``` -------------------------------- ### Start a Goal with a Simple Objective Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md Initiate a goal by stating the objective after the /goal command. Kimi Code saves this objective and enters goal mode. ```sh /goal Fix bugs listed in the issue tracker. ``` -------------------------------- ### MCP Server Configuration Example Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/customization/mcp.md Defines MCP servers in mcp.json. Use 'command' for stdio servers and 'url' for HTTP servers. ```json { "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"] }, "linear": { "url": "https://mcp.linear.app/mcp" } } } ``` -------------------------------- ### Install Kimi Code CLI via Homebrew Source: https://github.com/moonshotai/kimi-code/blob/main/README.md Install Kimi Code CLI on macOS or Linux using the Homebrew package manager. ```sh brew install kimi-code ``` -------------------------------- ### Install Kimi Code CLI on Windows (PowerShell) Source: https://github.com/moonshotai/kimi-code/blob/main/apps/kimi-code/README.md Use this command to install Kimi Code CLI on Windows systems using PowerShell. ```powershell irm https://code.kimi.com/kimi-code/install.ps1 | iex ``` -------------------------------- ### Install Kimi Code CLI on macOS/Linux Source: https://github.com/moonshotai/kimi-code/blob/main/apps/kimi-code/README.md Use this command to install Kimi Code CLI on macOS or Linux systems using curl. ```sh curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash ``` -------------------------------- ### Configure Google Gemini Provider Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/providers.md Example TOML configuration for the `google-genai` provider. Requires your Google API key. ```toml [providers.gemini] type = "google-genai" api_key = "xxxxx" ``` -------------------------------- ### Start a Goal with Verifiable Evidence Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md Use goals for tasks with a clear finish line and verifiable evidence, such as fixing tests and ensuring they pass. ```sh /goal Fix every failing checkout test and run the checkout test suite successfully. ``` -------------------------------- ### Start a Goal in Non-Interactive Prompt Mode Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md In non-interactive prompt mode, you can initiate a goal directly using the `kimi -p` command. This mode supports only goal creation and has specific exit codes for completion, blocking, or pausing. ```shell kimi -p "/goal Fix the failing checkout test" ``` -------------------------------- ### Research Project Architecture Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/use-cases.md Use this prompt to get an overview of a repository's architecture, including entry points, module dependencies, and configuration loading. It can also generate a module dependency diagram. ```prompt 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. ``` -------------------------------- ### Start Kimi ACP Mode Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/kimi-acp.md Run this command to switch the Kimi Code CLI to ACP mode. It immediately waits for an `initialize` request from an ACP client. ```sh kimi acp ``` -------------------------------- ### Skill File Format Example Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/customization/skills.md Illustrates the structure of a Skill Markdown file, including YAML frontmatter and the Markdown body. This format is used for defining custom agent capabilities. ```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 ``` -------------------------------- ### Initiate Login Flow in Kimi Code CLI Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/getting-started.md In the interactive UI, type `/login` to start the process of authenticating with an API source, such as Kimi Code OAuth or an API key. ```sh /login ``` -------------------------------- ### Extra Skill Directories Configuration Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/customization/skills.md Example TOML configuration for specifying additional directories where Kimi Code CLI should scan for skills. This allows for shared or team-specific skill sets. ```toml extra_skill_dirs = ["~/team-skills", ".agents/team-skills"] ``` -------------------------------- ### Example Proposed Sub-skill Output Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/sub-skill/review/SKILL.md Illustrates the expected format for reporting proposed sub-skill consolidations, including parent skill, child skills, directory alignment, and rationale. ```text Proposed sub-skill: web-research - Parent: web-research (has-sub-skill: true) - Children: - web-search → move under web-research/search - fetch-url → move under web-research/fetch - Documentation alignment: move each child's references/examples/assets with that child. - Rationale: Both deal with online information retrieval and are often chained together. ``` -------------------------------- ### Check for Updates Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/kimi-command.md Run `kimi upgrade` to immediately check for the latest version and be prompted to update. This command is suitable for most installation types. ```sh kimi upgrade ``` -------------------------------- ### Enter Plan Mode Temporarily Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/overrides.md Temporarily start Kimi Code in Plan mode using the --plan flag. For permanent activation, configure default_plan_mode in the config file. ```sh kimi --plan ``` -------------------------------- ### Start a Goal with Specific Finish Line and Evidence Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md Define a goal with a clear finish line and the evidence required for completion. This helps the agent understand success criteria. ```sh /goal Fix every bug labeled checkout-regression, add or update tests for each fix, and run the checkout test suite ``` -------------------------------- ### Configure Vertex AI Provider Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/providers.md Example TOML configuration for the `vertexai` provider. Authentication uses Google Cloud ADC, and project/region must be set in the `env` sub-table. ```toml [providers.vertexai] type = "vertexai" [providers.vertexai.env] GOOGLE_CLOUD_PROJECT = "my-gcp-project" GOOGLE_CLOUD_LOCATION = "us-central1" ``` -------------------------------- ### Configure OpenAI Responses Provider Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/providers.md Example TOML configuration for the `openai_responses` provider. Ensure you have the correct `base_url` and `api_key`. ```toml [providers.openai-responses] type = "openai_responses" base_url = "https://api.openai.com/v1" api_key = "sk-xxxxx" ``` -------------------------------- ### Start a Goal for Ordered Work Without Further Prompts Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md Define goals for sequential tasks that should proceed without additional user prompts, ensuring necessary checks or artifacts are in place. ```sh /goal Update the feature implementation, add docs, run tests, and summarize the changed files. ``` -------------------------------- ### Start a Goal for Multi-Turn Investigation and Repair Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md Employ goals for tasks that may require several turns of investigation and repair, like diagnosing and fixing a failing build. ```sh /goal Find why the release build fails, fix the root cause, and verify the build passes. ``` -------------------------------- ### Implement New Feature with Retry Utility Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/use-cases.md Define requirements for a new feature, including function signatures, options, and error handling. This example specifically adds a retry utility. ```prompt 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 ``` -------------------------------- ### Start or Manage Autonomous Goal Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/slash-commands.md Initiates or manages a persistent objective for Kimi Code. Refer to the Goals guide for detailed usage and examples. ```sh /goal Update the checkout docs, run docs build, and stop if still blocked after 20 turns ``` -------------------------------- ### Update Documentation Based on Code Changes Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/use-cases.md Instruct the agent to update documentation, including JSDoc, README examples, and guide paragraphs, after interface signature changes. ```text I just changed the interface signature in src/auth/login.ts. Please update the corresponding JSDoc, the example code in README, and any paragraphs in docs/en/guides that mention this interface. ``` -------------------------------- ### Build Documentation Source: https://github.com/moonshotai/kimi-code/blob/main/docs/AGENTS.md Builds the static documentation files for deployment. ```bash npm run build ``` -------------------------------- ### Initialize Kimi Vis Theme Source: https://github.com/moonshotai/kimi-code/blob/main/apps/vis/web/index.html Applies the Kimi Vis theme by checking local storage for 'vis.theme'. Falls back to system preference or 'dark'. ```javascript kimi vis (function () { try { var v = localStorage.getItem('vis.theme'); var t = v === 'light' || v === 'dark' ? v : window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'; document.documentElement.setAttribute('data-theme', t); } catch (_) { document.documentElement.setAttribute('data-theme', 'dark'); } })(); ``` -------------------------------- ### Display Help and Available Commands Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/slash-commands.md Shows keyboard shortcuts and a list of all available commands in the Kimi Code CLI. ```sh /help ``` -------------------------------- ### Conventional Commits Example Source: https://github.com/moonshotai/kimi-code/blob/main/CONTRIBUTING.md Examples of commit messages following the Conventional Commits specification for various types of changes. ```markdown feat: A new feature feat(agent-core): add tool dedup fix: A bug fix fix(tui): correct status bar alignment docs: Documentation only docs: clarify install instructions chore: Tooling / housekeeping chore: bump dependencies refactor: Internal refactor without behavior change refactor(kosong): extract retry helper test: Adding or improving tests test(agent-core): cover skill resolver ci: CI / build pipeline changes ci: cache pnpm store build: Build system / artifact changes build(native): add win32-arm64 target perf: Performance improvement perf(session): batch event flushes style: Formatting only (no logic) style: apply oxlint --fix ``` -------------------------------- ### Configure Services Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/config-files.md Set up base URLs and API keys for built-in services like web search and fetch. Custom headers can also be included. ```toml [services.moonshot_search] base_url = "https://api.moonshot.cn/v1/search" api_key = "sk-xxx" [services.moonshot_fetch] base_url = "https://api.moonshot.cn/v1/fetch" api_key = "sk-xxx" ``` -------------------------------- ### Check Node.js Version Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/getting-started.md Verify that your Node.js installation meets the minimum version requirement (22.19.0 or later) before installing Kimi Code CLI via npm. ```sh node --version ``` -------------------------------- ### Fetch Official Configuration Documentation Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/update-config.md Fetches the official configuration documentation for kimi-code. This URL serves as the authoritative reference for configuration fields, including key names, types, allowed values, and owning sections. Always use this before modifying any configuration. ```text https://moonshotai.github.io/kimi-code/en/configuration/config-files.html ``` -------------------------------- ### Creating a Minimal Skeleton File Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/update-config.md If the target configuration file does not exist, use the 'Write' tool to create a minimal skeleton file. This is an alternative to copying when no original file is present. ```shell # /config.toml ``` -------------------------------- ### Queue Upcoming Goal Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/slash-commands.md Queues a new goal to be started after the current one completes, or starts it immediately if no goal is active. The agent cannot see queued goals until the current one finishes. ```sh /goal next -- manage the release checklist ``` -------------------------------- ### One-shot task example Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/tools/cron/cron-create.md Use for one-time reminders or tasks. Set recurring to false. ```markdown remind me at 2:30pm today to check the deploy → cron: "30 14 *", recurring: false tomorrow morning, run the smoke test → cron: "57 8 *", recurring: false ``` -------------------------------- ### Recurring job examples Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/tools/cron/cron-create.md Use for periodic tasks like polling or scheduled reports. recurring defaults to true. ```markdown */5 * * * * (every 5 min), 0 * * * * (hourly), 0 9 * * 1-5 (weekdays at 9am local) ``` -------------------------------- ### Backing Up and Overwriting Configuration Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/update-config.md After validation, back up the original configuration file with a timestamped name using Bash, then overwrite the original with the validated candidate file using `mv`. ```bash cp config.toml "config.toml.$(date +%Y%m%d-%H%M%S).bak" ``` ```bash cp tui.toml "tui.toml.$(date +%Y%m%d-%H%M%S).bak" ``` ```bash mv config-new.toml config.toml ``` -------------------------------- ### Load custom Skills directories with `kimi` Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/kimi-command.md Specify custom Skills directories using the `--skills-dir` flag. This flag replaces automatically discovered directories for the current launch and can be repeated to stack multiple paths. ```sh kimi --skills-dir /path/to/team-skills --skills-dir ./local-skills ``` -------------------------------- ### Creating a New Minimal Theme Skeleton Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/custom-theme.md If a custom theme does not exist, use the 'Write' command to create a minimal skeleton file for the new theme. ```bash Write /themes/.json.new ``` -------------------------------- ### Upgrade Kimi Code CLI Source: https://github.com/moonshotai/kimi-code/blob/main/docs/AGENTS.md Execute this command to update your Kimi Code CLI installation to the latest available version. ```bash pnpm update -g kimi-code ``` -------------------------------- ### Get Current Goal Status Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/goals.md Check the status and progress of the current goal using the /goal or /goal status command. ```sh /goal status ``` -------------------------------- ### Copying Configuration File (Bash) Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/update-config.md Use Bash to create a copy of the target configuration file with a '-new' suffix. This is the first step in the update process, ensuring the original file is not modified directly. ```bash cp config.toml config-new.toml ``` ```bash cp tui.toml tui-new.toml ``` -------------------------------- ### Uninstall Kimi Code CLI via npm Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/getting-started.md If Kimi Code CLI was installed using npm, use this command to remove it from your system. ```sh npm uninstall -g @moonshot-ai/kimi-code ``` -------------------------------- ### Partial Custom Theme JSON Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/customization/themes.md Example of a partial theme that only overrides 'primary' and 'roleUser' colors. Other color tokens will inherit from the base palette. ```json { "name": "just-blue", "colors": { "primary": "#3B82F6", "roleUser": "#3B82F6" } } ``` -------------------------------- ### Applying Theme via Command Line Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/custom-theme.md Users can apply a custom theme by running the '/theme' command and selecting 'Custom: ' from the list. This command re-scans the themes directory, so no application restart is needed. ```bash /theme ``` -------------------------------- ### Upgrade Kimi Code CLI via npm Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/getting-started.md If you installed Kimi Code CLI using npm, you can upgrade to the latest version using this command. ```sh npm install -g @moonshot-ai/kimi-code@latest ``` -------------------------------- ### Applying Theme via Configuration File Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/custom-theme.md Alternatively, themes can be set directly in the 'tui.toml' configuration file by specifying the theme name. ```toml theme = "" ``` -------------------------------- ### Backing Up and Overwriting Theme File Source: https://github.com/moonshotai/kimi-code/blob/main/packages/agent-core/src/skill/builtin/custom-theme.md Before overwriting an existing theme, create a timestamped backup of the current file. Then, move the new candidate file to replace the original. ```bash cp .json ".json.$(date +%Y%m%d-%H%M%S).bak" mv .json.new .json ``` -------------------------------- ### Switch to New Session in TUI Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/sessions.md Use the /new or /clear slash command within the Kimi Code CLI TUI to start a fresh session, discarding current context. ```text /new ``` -------------------------------- ### Manually Trigger Context Compression with Prioritization Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/guides/sessions.md Provide a hint to the model when compressing context using the /compact command to prioritize specific discussion points. ```text /compact Keep the discussion about database migrations ``` -------------------------------- ### Configure Kimi Provider Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/configuration/providers.md Connect to Moonshot AI's OpenAI-compatible interface using a Kimi API key and base URL. ```toml [providers.kimi] type = "kimi" base_url = "https://api.moonshot.ai/v1" api_key = "sk-xxxxx" ``` -------------------------------- ### Open Plugin Manager Source: https://github.com/moonshotai/kimi-code/blob/main/docs/en/reference/slash-commands.md Opens the interactive plugin manager for managing Kimi Code plugins. ```sh /plugins ```