-
Notifications
You must be signed in to change notification settings - Fork 876
docs: 新增 AGENTS.md 专题页、安全边界说明和首页导览 || docs: Added AGENTS.md special page, security boundary description and home page navigation #1718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # AGENTS.md project guide | ||
|
|
||
| `AGENTS.md` is a Markdown file placed in the project root, written specifically for AI coding agents. Kimi Code CLI automatically reads it when starting a session and injects its content into the system prompt, so the agent understands the project's background, conventions, and constraints from the very first turn. | ||
|
|
||
| ## How it differs from README.md | ||
|
|
||
| `README.md` is for human readers — it describes the project's purpose, installation steps, and usage examples. `AGENTS.md` is for AI agents — it tells the agent how to work correctly within the project. The two serve different purposes: | ||
|
|
||
| | | `README.md` | `AGENTS.md` | | ||
| |---|---|---| | ||
| | Audience | Human developers and users | AI coding agents | | ||
| | Purpose | Introduce the project, guide onboarding | Provide project context and working constraints | | ||
| | Typical content | Feature overview, install steps, screenshots | Build commands, code style, directory layout, test instructions | | ||
|
|
||
| A project can have both files without conflict. | ||
|
|
||
| ## Why you need AGENTS.md | ||
|
|
||
| When an AI agent enters an unfamiliar project, it knows nothing about the project structure, tech stack, or team conventions. Without `AGENTS.md`, the agent either spends many turns exploring on its own or makes assumptions that don't match the project's norms. A good `AGENTS.md` can: | ||
|
|
||
| - Reduce exploration overhead so the agent gets productive faster | ||
| - Prevent the agent from violating team code style or directory conventions | ||
| - Make common commands for building, testing, and linting immediately clear | ||
| - Inform the agent about special project restrictions (e.g., "do not modify the `generated/` directory") | ||
|
|
||
| ## How Kimi Code CLI loads AGENTS.md | ||
|
|
||
| When creating a session, Kimi Code CLI looks for the following files in the current working directory, in order: | ||
|
|
||
| 1. `AGENTS.md` (uppercase) | ||
| 2. `agents.md` (lowercase) | ||
|
|
||
| It reads the first file found and injects the full content into the agent's system prompt via the `${KIMI_AGENTS_MD}` variable. If neither file exists, the variable is an empty string — the agent starts normally but without project context. | ||
|
|
||
| ::: warning Note | ||
| Kimi Code CLI only looks for `AGENTS.md` in the working directory. It does not traverse parent directories or load from the user's home directory. If your project has nested subdirectories, make sure the file is in the directory where you launch `kimi`. | ||
| ::: | ||
|
|
||
| ## Generating AGENTS.md with /init | ||
|
|
||
| Run the `/init` slash command in a Kimi Code CLI session, and the agent will automatically explore the current project directory, analyze the project structure, tech stack, build configuration, and code organization, then write the results to an `AGENTS.md` file in the working directory. | ||
|
|
||
| How `/init` works: | ||
|
|
||
| 1. Creates a temporary isolated context to avoid polluting the current session | ||
| 2. Lets the agent explore the project and generate `AGENTS.md` in that temporary context | ||
| 3. Loads the generated file content back into the current session | ||
|
|
||
| If an `AGENTS.md` already exists in the working directory, `/init` will reference its existing content when overwriting. After generation, you should review the file and make corrections or additions as needed. | ||
|
|
||
| ## Recommended content | ||
|
|
||
| A practical `AGENTS.md` typically includes the following (include what's relevant — you don't need to cover everything): | ||
|
|
||
| **Project overview** — One or two paragraphs explaining what the project is, what tech stack it uses, and what scenarios it targets. Assume the reader knows nothing about the project. | ||
|
|
||
| **Build and test commands** — List the most common commands for daily development, for example: | ||
|
|
||
| ```sh | ||
| # Install dependencies | ||
| npm install | ||
|
|
||
| # Run tests | ||
| npm test | ||
|
|
||
| # Build the project | ||
| npm run build | ||
|
|
||
| # Lint check | ||
| npm run lint | ||
| ``` | ||
|
|
||
| **Code style** — Describe the coding conventions the project follows, such as indentation style, naming conventions, import ordering rules, and whether specific linter configurations are used. | ||
|
|
||
| **Directory layout** — Briefly describe the purpose of main directories, such as `src/` for source code, `tests/` for tests, `docs/` for documentation, etc. For large projects, helping the agent quickly locate where code lives is valuable. | ||
|
|
||
| **Common workflows** — Describe the team's development habits, such as branching strategy, commit message format, and PR process. | ||
|
|
||
| **Constraints and restrictions** — Explicitly tell the agent what it should not do, for example: | ||
|
|
||
| - Do not modify auto-generated files | ||
| - Do not commit directly to the `main` branch | ||
| - Tests must run in a specific environment | ||
|
|
||
| ## When to update AGENTS.md | ||
|
|
||
| `AGENTS.md` is not a write-once-and-forget file. Consider updating it when: | ||
|
|
||
| - The project's tech stack or build system changes | ||
| - Important directories or modules are added | ||
| - Code conventions are adjusted (e.g., switching linter tools or style configurations) | ||
| - Team conventions change (e.g., branching strategy, commit format) | ||
| - You notice the agent repeatedly making a specific mistake — document the correct approach | ||
|
|
||
| You can rerun `/init` at any time to let the agent regenerate the content, or edit the file manually. Keeping `AGENTS.md` in sync with the actual project state is key to the agent working effectively over time. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,3 +162,46 @@ When YOLO mode is enabled, a yellow YOLO badge appears in the status bar at the | |
| ::: warning Note | ||
| YOLO mode skips all confirmations. Make sure you understand the potential risks. It's recommended to only use this in controlled environments. | ||
| ::: | ||
|
|
||
| ## Security boundaries | ||
|
|
||
| Kimi Code CLI runs directly in your terminal with no sandbox isolation. Shell commands, file operations, and MCP tool calls executed by the agent take effect in your real operating system environment — no different from running commands manually in your terminal. Understanding these boundaries helps you use Kimi Code CLI safely. | ||
|
|
||
| ### Workspace scope | ||
|
|
||
| The agent's file operations are centered around the working directory. Read-only tools like `ReadFile`, `Glob`, and `Grep` can access files within the working directory using relative paths, or read files outside it using absolute paths. `WriteFile` and `StrReplaceFile` work the same way, but all write and edit operations require user approval. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new security-boundary text says Useful? React with 👍 / 👎. |
||
|
|
||
| Using the `--add-dir` startup flag or the `/add-dir` command during a session, you can add extra directories to the workspace. Once added, these directories have equal standing with the main working directory — the agent can freely read and write files in them (writes still require approval). Information about additional directories is passed to the system prompt via the `${KIMI_ADDITIONAL_DIRS_INFO}` variable. | ||
|
|
||
| ### What operations require approval | ||
|
|
||
| In the default mode, the following operations request your confirmation before each execution: | ||
|
|
||
| | Operation | Approval granularity | | ||
| |-----------|---------------------| | ||
| | `Shell` command execution | Each command | | ||
| | `WriteFile` file writes | Each write | | ||
| | `StrReplaceFile` file edits | Each edit | | ||
| | MCP tool calls | Each call | | ||
|
|
||
| Read-only tools (`ReadFile`, `ReadMediaFile`, `Glob`, `Grep`, `SearchWeb`, `FetchURL`) do not require approval. | ||
|
|
||
| You can select "Allow for this session" to automatically approve similar operations for the current session. This decision is persisted with the session state and automatically restored when resuming. | ||
|
|
||
| ### Risks of YOLO mode | ||
|
|
||
| When YOLO mode is enabled (`kimi --yolo` or `/yolo`), all approval requests are automatically granted. The agent can execute arbitrary shell commands and file modifications without confirmation. This means: | ||
|
|
||
| - The agent can delete files, overwrite code, and perform destructive git operations | ||
| - If the agent misunderstands the task, it may make irreversible changes | ||
| - If the project has MCP tools configured, those tools are also automatically approved | ||
|
|
||
| Use YOLO mode only when: the project has solid version control, you are running in a recoverable environment such as a container or VM, or you are performing a well-defined low-risk task. | ||
|
|
||
| ### MCP tool risk boundaries | ||
|
|
||
| MCP tools are provided by external MCP servers, and their behavior is not controlled by Kimi Code CLI. Each MCP tool call requires user approval by default, but is automatically approved in YOLO mode. When using MCP tools, keep in mind: | ||
|
|
||
| - MCP servers may access the network, databases, or other external resources | ||
| - MCP tool inputs and outputs pass through the agent, which may take further actions based on the results | ||
| - Make sure you trust the MCP servers you have configured and understand the scope of their tools | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # AGENTS.md 项目指南 | ||
|
|
||
| `AGENTS.md` 是放在项目根目录的 Markdown 文件,专门写给 AI 编程 Agent 阅读。Kimi Code CLI 每次启动会话时会自动读取它,并将内容注入系统提示词,让 Agent 从第一轮对话开始就了解项目的背景、规范和约束。 | ||
|
|
||
| ## 和 README.md 的区别 | ||
|
|
||
| `README.md` 面向人类读者——介绍项目用途、安装步骤、使用示例等。`AGENTS.md` 面向 AI Agent——告诉它如何在这个项目中正确地工作。两者的侧重点不同: | ||
|
|
||
| | | `README.md` | `AGENTS.md` | | ||
| |---|---|---| | ||
| | 读者 | 人类开发者、用户 | AI 编程 Agent | | ||
| | 目的 | 介绍项目、引导上手 | 提供项目上下文和工作约束 | | ||
| | 典型内容 | 功能说明、安装步骤、截图 | 构建命令、代码风格、目录说明、测试指令 | | ||
|
|
||
| 一个项目可以同时拥有两个文件,互不冲突。 | ||
|
|
||
| ## 为什么需要 AGENTS.md | ||
|
|
||
| AI Agent 在进入一个陌生项目时,对项目结构、技术栈和团队约定一无所知。如果没有 `AGENTS.md`,Agent 要么花大量轮次自行探索,要么做出与项目规范不符的假设。一份好的 `AGENTS.md` 可以: | ||
|
|
||
| - 减少 Agent 的探索成本,让它更快进入工作状态 | ||
| - 避免 Agent 违反团队的代码风格或目录约定 | ||
| - 让构建、测试、lint 等常用命令一目了然 | ||
| - 告知 Agent 项目的特殊限制(例如 "不要修改 `generated/` 目录") | ||
|
|
||
| ## Kimi Code CLI 如何加载 AGENTS.md | ||
|
|
||
| Kimi Code CLI 在创建会话时,会在当前工作目录下依次查找以下文件: | ||
|
|
||
| 1. `AGENTS.md`(大写) | ||
| 2. `agents.md`(小写) | ||
|
|
||
| 找到第一个存在的文件后读取其全部内容,通过 `${KIMI_AGENTS_MD}` 变量注入 Agent 的系统提示词。如果两个文件都不存在,该变量为空字符串,Agent 正常启动但不会获得项目上下文。 | ||
|
|
||
| ::: warning 注意 | ||
| Kimi Code CLI 只在工作目录下查找 `AGENTS.md`,不会向上遍历父目录,也不会从用户主目录加载。如果你的项目有多级子目录,请确保在你启动 `kimi` 的目录下放置文件。 | ||
| ::: | ||
|
|
||
| ## 用 /init 生成 AGENTS.md | ||
|
|
||
| 在 Kimi Code CLI 会话中运行 `/init` 斜杠命令,Agent 会自动探索当前项目目录,分析项目结构、技术栈、构建配置和代码组织方式,然后将结果写入工作目录下的 `AGENTS.md` 文件。 | ||
|
|
||
| `/init` 的工作方式: | ||
|
|
||
| 1. 创建一个临时的独立上下文,避免污染当前会话 | ||
| 2. 在临时上下文中让 Agent 探索项目并生成 `AGENTS.md` | ||
| 3. 将生成的文件内容加载回当前会话 | ||
|
|
||
| 如果工作目录下已存在 `AGENTS.md`,`/init` 会参考已有内容进行更新覆写。生成后你应当检查文件内容,根据实际情况进行修正和补充。 | ||
|
|
||
| ## 推荐写哪些内容 | ||
|
|
||
| 一份实用的 `AGENTS.md` 通常包含以下内容(按需取舍,不必面面俱到): | ||
|
|
||
| **项目概览**——用一两段话说明项目是什么、使用什么技术栈、面向什么场景。假设读者对项目一无所知。 | ||
|
|
||
| **构建与测试命令**——列出日常开发中最常用的命令,例如: | ||
|
|
||
| ```sh | ||
| # 安装依赖 | ||
| npm install | ||
|
|
||
| # 运行测试 | ||
| npm test | ||
|
|
||
| # 构建项目 | ||
| npm run build | ||
|
|
||
| # lint 检查 | ||
| npm run lint | ||
| ``` | ||
|
|
||
| **代码风格**——说明项目遵循的代码规范,例如缩进风格、命名约定、导入排序规则、是否使用特定的 linter 配置等。 | ||
|
|
||
| **目录说明**——简要描述主要目录的用途,例如 `src/` 存放源代码、`tests/` 存放测试、`docs/` 存放文档等。对于大型项目,帮助 Agent 快速定位代码所在位置很有价值。 | ||
|
|
||
| **常见工作流**——描述团队的开发习惯,例如分支策略、提交信息格式、PR 流程等。 | ||
|
|
||
| **约束与限制**——明确告知 Agent 不应该做的事情,例如: | ||
|
|
||
| - 不要修改自动生成的文件 | ||
| - 不要直接提交到 `main` 分支 | ||
| - 测试必须在某个特定环境下运行 | ||
|
|
||
| ## 什么时候需要更新 AGENTS.md | ||
|
|
||
| `AGENTS.md` 不是写一次就永远不变的文件。以下情况下建议同步更新: | ||
|
|
||
| - 项目的技术栈或构建系统发生变化 | ||
| - 新增了重要目录或模块 | ||
| - 代码规范有调整(如切换了 linter 工具或风格配置) | ||
| - 团队约定发生变化(如分支策略、提交格式) | ||
| - 发现 Agent 反复犯某个错误——把正确做法写进去 | ||
|
|
||
| 你可以随时重新运行 `/init` 让 Agent 重新生成内容,也可以手动编辑。保持 `AGENTS.md` 与项目实际状态一致,是让 Agent 持续高效工作的关键。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 English H1 title doesn't match sidebar label, violating naming convention
The H1
# AGENTS.md project guideindocs/en/customization/agents-md.md:1uses sentence case, but the sidebar label defined indocs/.vitepress/config.ts:136isAGENTS.md Project Guide(title case). Thedocs/AGENTS.mdnaming convention rule states: "Use consistent section labels that match the sidebar titles." Every other English page in the repo has its H1 matching the sidebar label exactly (e.g.,# Agents and Subagents= sidebarAgents and Subagents,# Model Context Protocol= sidebarModel Context Protocol). This mismatch also causes inconsistent link text across pages:docs/en/customization/agents.md:5uses[AGENTS.md project guide](matching the H1), whiledocs/en/index.md:22uses[AGENTS.md Project Guide](matching the sidebar).Was this helpful? React with 👍 or 👎 to provide feedback.