Inside Kimi Code CLI: How Its System Prompts Shape an AI Agent's Soul
Source: zhichai.net forum analysis of the open-source project MoonshotAI/kimi-cli
Key points
- Identity definition (
src/kimi_cli/agents/default/system.md): The 130-line core prompt opens with: "You are Kimi Code CLI, an interactive general AI agent running on a user's computer. Its primary goal is to answer questions and/or finish tasks safely and efficiently." Four keywords frame the identity: *Interactive, General, Safely, Efficiently*. - Tool-use philosophy: The prompt highly recommends parallel tool calls when they don't interfere, and explicitly forbids explanations around tool calls — "the tool calls themselves should be self-explanatory" — to keep interactions clean.
- Layered coding guidance: Greenfield work requires clarifying requirements, designing architecture first, and writing modular code. Maintenance work requires understanding the codebase first, focusing on error logs and tests for bug fixes, minimizing intrusion for new features, and touching only interface-related errors during refactors.
- Safety emphasis: "The operating environment is not in a sandbox. Any actions you do will immediately affect the user's system. So you MUST be extremely cautious." Combined with restrictions on accessing files outside the working directory.
- AGENTS.md meta-awareness: The prompt explains that
README.mdfiles are for humans, whileAGENTS.mdcarries the extra context coding agents need — acknowledging that humans and AI require different documentation. - Character baseline: The prompt closes with six traits — HELPFUL and POLITE, CONCISE and ACCURATE, PATIENT and THOROUGH.
- Subagent hierarchy (
sub.yaml): Sub-agents inherit the main config viaextend: ./agent.yamlbut receive additional role instructions: the main agent cannot see their context, only their final message, so they must provide a comprehensive summary. Recursive spawning is blocked by excluding theTask,CreateSubagent, andSendDMailtools. - Context compression (
compact.md): A priority scheme for preserving information during long conversations: (1) current task state, (2) errors and solutions, (3) final working code versions, (4) system/project context, (5) design decisions, (6) TODO items. Output is structured with XML-like tags (<current_focus>,<environment>,<completed_tasks>). - Self-documentation (
init.md): A meta-prompt instructing the agent to explore a project directory and generate an accurate AGENTS.md covering architecture, tech stack, build process, conventions, testing, and deployment — written in the project's primary natural language. - Skill system: Skills are described as "onboarding guides for specific domains or tasks," using progressive disclosure: metadata (~100 words) always loaded; SKILL.md body (<5k words) on trigger; bundled resources (scripts, references, assets) on demand. Key principles: "Concise is key" (the context window is a public good) and setting appropriate degrees of freedom — from free-form text guidance to rigid scripts depending on how fragile the operation is.
Design philosophy takeaways
The author distills five lessons for agent builders:
1. Layered modularity — core soul (system.md), role extension (sub.yaml), pluggable capabilities (skills), and meta-capabilities (init.md). 2. Constraints as freedom — defining safety, efficiency, quality, and collaboration boundaries lets the agent be creative within them. 3. User-centered design — separate docs for humans vs. agents; no redundant output; safety warnings for non-sandboxed environments. 4. Information efficiency — progressive disclosure and on-demand loading. 5. Self-evolution — the agent can learn projects, record knowledge to AGENTS.md, and be extended via Skills.
The article concludes that system prompts are not mere instruction lists but a carefully designed "behavioral operating system" balancing capability vs. safety, generality vs. specialization, efficiency vs. quality, and individual vs. collaborative work.
Reference: https://github.com/MoonshotAI/kimi-cli