Introduction
Kimi CLI is a command-line AI assistant built by Moonshot AI that connects local files and cloud intelligence. Its power comes from an agent system: an agent defines the AI's behavior through a system prompt, a set of available tools, and sub-agents. Agents are selected with --agent (e.g., kimi --agent okabe) or loaded from YAML files with --agent-file /path/to/my-agent.yaml.
Built-in Agents
- default: enables Task, SetTodoList, Shell, ReadFile, ReadMediaFile, Glob, Grep, WriteFile, StrReplaceFile, SearchWeb, and FetchURL — covering task management, file operations, and web search.
- okabe (experimental): everything in default plus SendDMail, used to send delayed messages to checkpoint IDs for rollback-style workflows. It is experimental to encourage testing new prompts and tool combinations.
name(optional when inheriting)system_prompt_path— path to a Markdown template filesystem_prompt_args— custom template parameterstools— list inmodule:ClassNameformat, e.g.,kimi_cli.tools.shell:Shellexclude_tools— remove inherited tools (e.g., SearchWeb, FetchURL)subagents— sub-agent definitionsextend— inherit fromdefault,okabe, or another YAML file via relative path, mergingsystem_prompt_argswhile overriding other fields- Task: dispatch a sub-agent; the prompt must contain all needed information since the sub-agent cannot see the main context.
- SetTodoList: track todos with titles and pending/in_progress/done status.
- Shell: execute commands (bash/zsh or PowerShell per OS); requires approval;
timeoutdefaults to 60s, max 300s. - ReadFile: read text files, capped at 1000 lines / 2000 characters; absolute paths required outside the working directory.
- ReadMediaFile: read images/video up to 100MB, only if the model supports it.
- Glob: pattern matching (e.g.,
*.py), max 1000 items; patterns cannot start with. - Grep: regex content search with path/glob/type filters, output modes (
files_with_matches), context flags (-B/-A/-C), -n, -i, multiline, and head_limit. - WriteFile: write files (absolute path; overwrite or append mode); requires approval.
- StrReplaceFile: string-replacement edits (old, new, replace_all); requires approval.
- SearchWeb: web search;
limitdefaults to 5, max 20; optionalinclude_content. - FetchURL: fetch a URL and return the main text.
- Think: record reasoning for complex tasks.
- SendDMail: send a delayed message to a checkpoint (id >= 0).
- CreateSubagent**: define new sub-agent types at runtime.
Custom Agents in YAML
A custom agent file uses version: 1 and an agent block with:
System Prompt Templates
Prompt files are Markdown templates using ${VAR} syntax. Built-in variables include ${KIMI_NOW} (current time, ISO), ${KIMI_WORK_DIR} (working directory), ${KIMI_WORK_DIR_LS} (directory listing), ${KIMI_AGENTS_MD} (AGENTS.md contents if present), and ${KIMI_SKILLS} (loaded skills). Custom args defined in system_prompt_args (e.g., MY_VAR: "value") can be referenced as ${MY_VAR}.
Sub-agents
Static sub-agents are declared in the subagents block with path (relative) and description (e.g., a coder and a reviewer). Sub-agent files typically extend the main agent, add role descriptions via system_prompt_args, and exclude the Task tool to avoid nested loops. The main agent launches them via the Task tool with description, subagent_name, and prompt. Each sub-agent runs in an isolated context (its own conversation history), returns results when done, and enables parallel task handling.
The CreateSubagent tool (not enabled by default; add to tools manually) lets the AI define new sub-agent types at runtime with a unique name and a system_prompt describing its role and boundaries.
Built-in Tools
Safety Boundaries
Tool operations are constrained to the working directory (absolute paths required outside). Writes, edits, Shell execution, and MCP calls require per-action user approval — a safety valve preventing unintended actions. Limits on glob patterns, file sizes, and line counts prevent resource abuse, balancing capability with safety.
Conclusion
Kimi CLI's agent system evolves from built-in defaults to fully custom YAML configurations, from static sub-agent declarations to runtime creation — an ecosystem where agents, tools, and safety boundaries work together to make a reliable local AI assistant.
---
*Translated and edited from a Chinese forum post on zhichai.net, based on the Kimi CLI official documentation (Moonshot AI).*