AGENTS.md 中文模板:让 Codex 遵守项目规则
AGENTS.md 适合存放长期有效的仓库规则,例如项目命令、目录说明、测试要求和禁止事项。它能减少你每次重复交代上下文的成本。
推荐结构
# Project guide
## Project structure
- src/: application code
- tests/: automated tests
## Commands
- Install: npm install
- Test: npm test
- Lint: npm run lint
## Coding rules
- Keep public APIs backward compatible.
- Prefer existing helper functions and project patterns.
- Add tests for bug fixes.
## Safety
- Do not edit generated files.
- Do not commit secrets or production data.
- Ask before destructive data operations.
写 AGENTS.md 的原则
- 写命令,不写模糊偏好。
- 写边界,不把所有事情交给模型判断。
- 写验证方式,让 Codex 知道完成标准。
- 越靠近具体子目录的规则越适合写细节。
常见错误
不要把 AGENTS.md 写成百科全书。它应该是工程协作规则,而不是完整产品说明书。
直接使用工具页可以生成一份初稿,然后再按你的项目补细节。