write-agents-md
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWrite AGENTS.md
编写 AGENTS.md
Produce a small, durable instruction file for the agents that automatically receive it. This skill authors guidance; it does not implement the application or perform its QA.
为自动接收该文件的 Agent 生成一份小而持久有效的说明文件。本 skill 负责编写指引;不实现应用,也不执行其 QA。
Admission rule
收录规则
A statement belongs in AGENTS.md only when it passes all three tests:
- Audience: every agent entering this directory must know it, regardless of its task. Root means the whole repository; nested means that entire subtree.
- Value: it changes a decision the agent could otherwise get wrong. It is not standard tooling knowledge, an obvious layout, or something immediately discoverable in manifests/source.
- Stability: it is an enduring convention or invariant, not a session observation, changing version, task status, temporary workaround, or machine fact.
A statement failing audience goes in a task-specific skill. Detailed explanations/evidence go in documentation; execution state goes in the project tracker. A stable documentation entry point can stay in AGENTS.md; a task-by-task document/skill catalog cannot. Do not invent skill names or create additional skills without authorization.
TDD, verification, commit policy, and honest completion are standing obligations for every contributor. They may distinguish runtime from documentation work without becoming scenario runbooks. Keep those obligations; put commands, fixture recipes, particular flows and recovery procedures in skills.
只有同时通过以下三项测试的陈述,才应放入 AGENTS.md:
- **受众:**进入此目录的每个 Agent 都必须知道该内容,无论其任务为何。根级意味着整个仓库;嵌套级意味着整个子树。
- **价值:**它会改变 Agent 可能原本判断错误的决策。它不应是标准工具知识、显而易见的目录结构,或可从 manifests/source 中立即发现的信息。
- **稳定性:**它是长期有效的约定或不变量,而不是某次会话的观察、不断变化的版本、任务状态、临时变通方案或机器事实。
未通过“受众”测试的陈述应放入针对特定任务的 skill。详细解释和证据应放在文档中;执行状态应放在项目跟踪器中。稳定的文档入口可以保留在 AGENTS.md 中;按任务逐一列出的文档/skill 目录则不可以。未经授权,不要虚构 skill 名称或创建额外 skill。
TDD、验证、提交策略和如实完成工作是每位贡献者都必须遵守的长期义务。它们可以区分运行时工作与文档工作的要求,而不应演变成场景运行手册。保留这些义务;将命令、fixture 配方、特定流程和恢复步骤放入 skill 中。
Select the relevant workflow
选择相关工作流
- Web: read the web workflow; copy the web template.
- Desktop: read the desktop workflow; copy the desktop template.
These are the two canonical templates. They preserve the user's TDD and commit wording; project/client/brand details, technology and human-language choices are generalized. Do not load the other workflow unless the project has both surfaces. For mixed projects use one minimal shared root and surface-specific nested guidance only where distinct enduring rules justify it. Do not force CLI/library-only projects into graphical-app workflows; clarify that boundary.
- **Web:**阅读 Web 工作流;复制 Web 模板。
- **Desktop:**阅读 Desktop 工作流;复制 Desktop 模板。
以上是两份规范模板。它们保留用户确定的 TDD 和提交措辞;项目、客户、品牌细节、技术选择和自然语言选择均作通用化处理。除非项目同时包含两种界面,否则不要加载另一工作流。对于混合项目,使用一份精简的共享根级文件,并且仅在存在不同且长期有效的规则时,才添加面向各界面的嵌套指引。不要将仅含 CLI/library 的项目强行套用图形应用工作流;应明确这一边界。
Copy first, adapt second
先复制,再调整
- Inspect existing instructions, user requirements, the documentation entry point and only the metadata needed to establish non-obvious constraints. Preserve human decisions. Do not request a full source audit merely to write instructions.
- Choose web/desktop and root/nested scope. Copy the chosen asset byte-for-byte before any adaptation. Never reconstruct, paraphrase or draft the starting file from memory.
- Use the bundled helper (Python 3.9+, standard library only):
It always stages AGENTS.md.candidate, refuses overwrite and out-of-project targets, verifies bytes and prints a SHA-256 receipt. The explicit --candidate flag is retained for compatibility; omitting it is equally safe. The receipt is execution evidence, not text for AGENTS.md.sh
python <skill-directory>/scripts/copy_template.py --workflow web --project-root <project-root> --candidate python <skill-directory>/scripts/copy_template.py --workflow desktop --project-root <project-root> --scope <existing-relative-subfolder> --candidate - Always use , for new and existing root/nested files. Adapt
--candidatewhile active guidance stays absent or unchanged. After reviewing the diff and validating that no placeholders remain, publish new guidance with a filesystem operation that refuses overwrite, or reconcile existing guidance in a reviewed edit preserving human instructions. An interrupted adaptation leaves only the candidate; report it rather than loading/publishing it. Remove your candidate after successful publication; do not commit candidates or receipts.AGENTS.md.candidate - If the helper cannot run, use an available filesystem copy and compare bytes/hashes before editing. If the template cannot be read/copied, report the blocker; do not invent an approximation.
- Apply the workflow and admission rule. Fill verified placeholders; remove optional blocks rather than inventing facts. Read scope and adaptation for fields and nested rules.
- Compare the final diff with both the template and prior guidance. Check scope, preserved mandatory quality gates, Markdown/links, no unresolved placeholders and no duplicated ancestors. Describe important removals/relocations.
- 检查现有说明、用户要求、文档入口,以及仅用于明确不明显约束所必需的元数据。保留人工决策。不要仅为了编写说明而要求对整个源代码进行审计。
- 选择 Web/Desktop 工作流和根级/嵌套级作用域。在任何调整之前,逐字节复制所选模板。绝不能凭记忆重建、改写或起草起始文件。
- 使用随附的辅助工具(Python 3.9+,仅使用标准库):
它始终将文件暂存为 AGENTS.md.candidate,拒绝覆盖现有文件或写入项目外目标,验证字节并打印 SHA-256 校验回执。显式的 --candidate 参数为兼容性而保留;省略它同样安全。该回执属于执行证据,不是 AGENTS.md 的正文。sh
python <skill-directory>/scripts/copy_template.py --workflow web --project-root <project-root> --candidate python <skill-directory>/scripts/copy_template.py --workflow desktop --project-root <project-root> --scope <existing-relative-subfolder> --candidate - **对于新建和现有的根级/嵌套级文件,始终使用 --candidate。**在有效指引尚不存在或保持不变期间调整 AGENTS.md.candidate。审查差异并确认没有遗留占位符后,使用拒绝覆盖的文件系统操作发布新指引;或者通过经过审查的编辑来协调现有指引,并保留人工决定。如果调整过程中被中断,文件只会留下 candidate;应报告中断情况,而不是加载或发布它。成功发布后移除 candidate;不要提交 candidate 或校验回执。
- 如果辅助工具无法运行,则使用可用的文件系统复制功能,并在编辑前比较字节或哈希。如果模板无法读取或复制,应报告阻塞原因;不要虚构近似版本。
- 应用相应工作流和收录规则。填写已验证的占位符;删除可选内容块,而不是虚构事实。阅读作用域与调整,了解相关字段和嵌套规则。
- 将最终差异同时与模板和原有指引进行比较。检查作用域、必须保留的质量门禁、Markdown 和链接、未解决的占位符以及重复的祖先指引。说明重要的删除或迁移。
Non-negotiable testing policy
不可妥协的测试策略
Preserve the seven TDD steps and test-layer definitions. E2E and Manual QA use the fully working application with zero mocks, including real LLM calls, supporting services and persisted results. Unit/integration tests may isolate dependencies when useful. Before each creation/refresh of an endpoint mock, make a fresh real endpoint/database query and save the complete response verbatim to a file; derive the mock from that file, never documentation or invented objects. Use synthetic authorized test data; never commit private responses or credentials. Read the endpoint mock policy when adapting that contract. Missing access/budget blocks required real checks, not permission to fake a pass.
保留七个 TDD 步骤和测试层级定义。E2E 和 Manual QA 必须使用完全可运行且无任何 mock 的应用,包括真实的 LLM 调用、配套服务和持久化结果。Unit/integration 测试可以在有帮助时隔离依赖。每次创建或刷新端点 mock 前,都要发起一次新的真实端点或数据库查询,并将完整响应原样保存到文件中;mock 必须从该文件派生,绝不能依据文档或虚构对象生成。使用经过授权的合成测试数据;绝不提交私有响应或凭据。调整该契约时,请阅读端点 mock 策略。缺少访问权限或预算会阻止必需的真实检查,而不是允许伪造通过结果。
Size and scope
大小和作用域
Aim for 200–400 words at root and 40–120 words nested, smaller when fewer invariants exist. These are review targets, not permission to weaken requirements or add filler.
Keep root to purpose/scope, agreed language policy, non-obvious universal constraints, one documentation entry point, and shared quality/commit/completion gates. Nested files need distinct folder-wide rules; do not create one for every standard source/test/resources directory.
Adapt nested copies by removing root/project sections and ancestor quality gates already in force. Retain the subtree purpose and unique invariant instructions. Do not repeat parents, explain automatic instruction loading, or link other AGENTS.md files. Do not promote folder-only rules to root.
根级文件以 200–400 词为目标,嵌套级文件以 40–120 词为目标;如果需要遵守的不变量更少,则应进一步精简。这些是审查目标,不是削弱要求或添加填充内容的许可。
根级文件只保留目的与作用域、约定的语言策略、不明显的通用约束、一个文档入口,以及共享的质量、提交和完成门禁。嵌套文件需要该文件夹范围内有别于其他目录的规则;不要为每个标准的 source/test/resources 目录都创建一个嵌套文件。
调整嵌套副本时,移除根级或项目级章节,以及已经由祖先文件生效的质量门禁。保留子树用途及其特有的不变量说明。不要重复父级内容、解释说明的自动加载机制,也不要链接其他 AGENTS.md 文件。不要将仅适用于某个文件夹的规则提升到根级。
Exclude by default
默认排除
- Exact dependency/tool versions, source counts, dates, branches, commits, host paths/usernames, local sandbox errors and tool availability.
- Standard layout, package tours, manifest dependency lists, basic Git/tool tutorials, instruction-loading explanations, or generic competence advice.
- Feature/protocol migration plans, incident fixes, conditional test recipes, platform setup and long document-trigger catalogs.
- Unrequested PRD/ADR files, fabricated commands, environment variables, branding, supported-OS lists, or unverified installed skills/tools.
An internal framework, hidden compatibility boundary, or nonstandard root can qualify when every agent in scope needs it. Enforced versions belong in manifests/documentation; refer to a stable compatibility policy only when necessary.
- 精确的依赖或工具版本、源代码数量、日期、分支、提交记录、主机路径或用户名、本地沙箱错误以及工具可用性情况。
- 标准目录结构、包结构导览、manifest 依赖列表、基础 Git 或工具教程、说明加载机制解释,以及泛泛的能力建议。
- 功能或协议迁移计划、故障修复、特定条件下的测试配方、平台设置以及冗长的文档触发条件目录。
- 未经请求的 PRD/ADR 文件、虚构的命令、环境变量、品牌信息、受支持 OS 列表,以及未经验证已安装的 skills 或 tools。
当作用域内的每个 Agent 都需要时,内部框架、隐藏的兼容性边界或非标准根目录也可以收录。强制执行的版本应放在 manifests 或文档中;仅在必要时引用稳定的兼容性策略。
Completion
完成
Treat as an internal draft, not the delivered result. Complete adaptation, validation and publication/reconciliation as within the same authoring task, before presenting final files or opening a PR. Commit the finished only; remove your candidate. If interrupted, report the task as incomplete.
AGENTS.md.candidateAGENTS.mdAGENTS.mdShow files actually changed, template copied, adaptations/relocations and checks. Leave application code untouched unless authorized. Preserve unrelated work and tool-specific instructions. Create a CLAUDE.md import only when requested or established; do not duplicate guidance or overwrite tool-specific content.
Require affected instructions and documentation to be updated in the same logical change when enduring facts/policies change. Do not claim enforcement against an agent ignoring the skill: the helper proves the starting copy; final scope and meaning require review.
将 AGENTS.md.candidate 视为内部草稿,而不是交付结果。在同一编写任务中完成调整和验证,并在展示最终文件或创建 PR 之前,将其作为 AGENTS.md 发布或完成协调。只提交最终的 AGENTS.md;移除 candidate。如果被中断,应将任务报告为未完成。
展示实际变更的文件、已复制的模板、调整与迁移情况以及检查结果。除非获得授权,否则不要改动应用代码。保留无关工作和工具特定说明。仅在用户提出要求或已有既定约定时创建 CLAUDE.md 导入;不要重复指引或覆盖工具特定内容。
当长期有效的事实或策略发生变化时,必须在同一逻辑变更中更新受影响的说明和文档。不要声称能够强制 Agent 遵守本 skill:辅助工具只能证明起始文件已被正确复制;最终作用域和含义仍需经过审查。