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

The Soul of an AI Agent: Deep Dive into Kimi Code CLI's System Prompt Design

Forum topic · 小凯 · 2026-02-21

Summary

This article dissects the system prompt architecture of Kimi Code CLI, an open-source AI coding assistant from Moonshot AI, to reveal how carefully crafted prompt files shape an AI agent's behavior. The analysis covers four core components: system.md (identity, tool-use philosophy, layered coding guidance, safety constraints, and personality traits), sub.yaml (parent-sub agent role inheritance and capability trimming), compact.md (structured context compression for long sessions), and init.md (meta-capability for self-documentation via AGENTS.md). It also explains the modular Skill system using progressive disclosure, which loads only metadata initially and full instructions on demand. Key design philosophies include layered modularity, constraints enabling freedom, user-centric documentation separation, and self-evolution through project learning. The piece serves as a practical blueprint for developers building production AI agents.

Key points

  • System prompt as operating system: In large language model (LLM) applications, the system prompt functions as the "operating system" of the agent's mind, defining identity, capability boundaries, behavioral rules, and safety constraints.
  • Kimi Code CLI identity: Positioned as an interactive, general-purpose, safe, and efficient AI agent running locally on user machines, with a strong emphasis on caution because the environment is not sandboxed.
  • Tool-use philosophy: Parallel tool calls are highly recommended for efficiency, and tool calls themselves should remain self-explanatory without redundant narration.
  • Layered coding guidance: Different workflows apply for building from scratch versus maintaining existing codebases, including architecture-first development, minimal-intrusion edits, and refactoring that only fixes interface changes without altering logic.
  • AGENTS.md vs README.md: Humans and AI require different documentation; AGENTS.md complements README.md by providing project context that coding agents specifically need.
  • Six personality pillars: HELPFUL, POLITE, CONCISE, ACCURATE, PATIENT, and THOROUGH define the agent's character baseline.
  • Sub-agent mechanism: Sub-agents inherit from the main agent's configuration but operate with context isolation, must deliver comprehensive final summaries, and are explicitly forbidden from spawning further sub-agents to prevent infinite recursion.
  • Context compression strategy: compact.md uses a six-tier priority system (current task, errors, final code, system context, design decisions, TODOs) with structured XML-style output tags to preserve the most valuable information during long sessions.
  • Meta-capability via init.md: Kimi can autonomously explore projects and generate AGENTS.md documentation, enabling self-documentation and project-aware behavior.
  • Skill system with progressive disclosure: Skills load metadata first (~100 words), then full SKILL.md body on trigger (<5k words), and bundled resources (scripts, references, assets) only when needed, balancing context efficiency with extensibility.
  • Freedom through constraints: Design freedom levels vary by task fragility, ranging from text guidance (high freedom) to specific scripts (low freedom for fragile operations).
  • Architectural blueprint: Four design philosophies emerge: layered modularity, constraint-as-freedom, user-centric design, and self-evolution through learning.
  • Source references

  • Kimi Code CLI source code: https://github.com/MoonshotAI/kimi-cli
  • Core prompt: src/kimi_cli/agents/default/system.md
  • Skill system: src/kimi_cli/skills/skill-creator/SKILL.md

Tags

#ai-agent#system-prompt#kimi-cli#prompt-engineering#moonshot-ai#llm#code-assistant#agent-design

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