.github/copilot-instructions.mdGitHub Copilot custom instructions:存放位置及工具读取方式
GitHub Copilot 会读取一个仓库级文件 .github/copilot-instructions.md,以及按路径生效的 .instructions.md 文件。它也会遵循 AGENTS.md,或根目录下单独的 CLAUDE.md 或 GEMINI.md。
存放位置
- .github/copilot-instructions.md,对整个仓库生效。
- .github/instructions/**/NAME.instructions.md,对 applyTo 匹配的文件生效。
- 仓库任意位置的 AGENTS.md;优先使用距离最近的文件。
- 根目录下单独的 CLAUDE.md 或 GEMINI.md,二者任选其一。
格式
使用 Markdown;指令之间的空白会被忽略。只有 .instructions.md 文件支持 frontmatter:applyTo 用于填写以逗号分隔的 glob 模式,excludeAgent 可设为 "code-review" 或 "cloud-agent"。代码审查的 4,000 字符限制已于 2026-06-12 取消,GitHub 建议每个文件控制在约 1,000 行以内。
# Copilot instructions
This is a Rails app with a React front end in app/javascript/.
## Build and test
- Install: `bundle install && yarn install`
- Test: `bin/rails test`
- Lint: `bin/rubocop`
## Conventions
- Put business logic in app/services/, not in controllers.
- Every migration must be reversible.
- Never commit credentials or edit config/master.key.
优先级与合并
依次应用个人、仓库和组织指令,并发送所有相关指令集。路径专用文件与仓库级文件都匹配时,Copilot 会同时使用二者。代码审查会读取 pull request 的 head 分支中的指令。
提示
- 在 github.com 上,路径专用的 .instructions.md 文件仅适用于 Copilot cloud agent 和 Copilot code review。
- 添加 excludeAgent: "code-review",即可让代码审查忽略该文件,同时仍供 cloud agent 使用。
- Copilot cloud agent 可以为你起草 copilot-instructions.md;文件控制在约两页,并避免针对单一任务编写。
通过一个表单,为五种工具生成 AGENTS.md 和对应的规则文件。 打开 AGENTS.md 生成器 →
其他指令文件
AGENTS.mdCLAUDE.mdGEMINI.md.cursor/rules/*.mdc.devin/rules/*.md.clinerules/~/.openclaw/workspace/AGENTS.md