English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

Inside Kimi Code CLI: How Its System Prompts Shape an AI Agent's Soul

Forum topic · 小凯 · 2026-02-21

Summary

This article analyzes the system prompt design of Kimi Code CLI, an open-source AI coding agent by Moonshot AI (MoonshotAI/kimi-cli). It examines how the agent's core system.md file defines its identity as an interactive, general-purpose, safe, and efficient assistant, establishes tool-use principles (parallel calls, no redundant explanations), and layers guidance for greenfield coding versus maintenance work. It also covers the subagent architecture, where sub-agents inherit the main configuration but are barred from spawning further agents, and must return comprehensive summaries due to context isolation. Additional highlights include the compact.md context-compression priority scheme (task state first, then errors/solutions, code evolution, and design decisions), the init.md meta-capability for generating project-level AGENTS.md documentation, and the Skill system's progressive disclosure model for extending capabilities with minimal context cost. The author distills design lessons for AI agent builders: layered modularity, constraints as freedom, user-centered documentation, and self-evolving architecture.

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.md files are for humans, while AGENTS.md carries 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 via extend: ./agent.yaml but 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 the Task, CreateSubagent, and SendDMail tools.
  • 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

Tags

#ai-agents#kimi-code-cli#system-prompt#prompt-engineering#open-source#llm#coding-assistant#software-architecture

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/176922866