正在寻找 copilot-instructions.md 示例 通常意味着您需要 GitHub Copilot 可以加载的持久的、repo 范围的指导,而不是另一个聊天提示。此页面显示的是常规.github/copilot-instructions.md 布局、可以复制的短模板以及如何避免将同一面墙复制到 代理.md 和 IDE 规则。将路径和产品行为视为说明性的;重新检查 GitHub 的当前 Copilot 文档以了解您的计划和 IDE。

01

独立笔记

02

copilot-instructions.md 的用途

将其视为 Copilot 的承诺项目简介:堆栈事实、命令、命名和硬性非目标。它更接近于 代理.md 而不是一次性票证提示。将持久合同放在这里;在聊天或 PR 描述中添加“此 PR 的验收检查”。

  • 说明文件: 包管理器、测试命令、路由注册表、禁止的部署路径。
  • 会话提示: 这张票的目标和已完成的检查。
  • 两者都不是: 秘密、生产凭证、客户 PII。

03

文件布局

一个广泛记录的约定是 Markdown 文件,位于.github/copilot-instructions.md。一些团队还将路径范围的指令文件保存在 .github/instructions/当他们的 Copilot 版本支持它们时——在发明第二棵树之前确认当前文档中的命名。

.github/
  copilot-instructions.md     # always-on project brief
  instructions/               # optional path-scoped files (if supported)
    frontend.instructions.md
    migrations.instructions.md

保持根文件足够短,以便人们可以更新它。链接到更长的文档,而不是粘贴自述文件。

04

复制就绪的 copilot-instructions.md 示例

适应这些。将命令和路径替换为存储库的真实情况。

最小的永远在线简报

# Project instructions for Copilot

## Stack
- Package manager: pnpm. Node 22+.
- App: Hono JSX + Vite SSG on Cloudflare Workers Static Assets.

## Hard rules
- Indent with 4 spaces; do not reformat unrelated files.
- Register every indexable page in the site route registry (pages[]).
- Run `pnpm run build` before claiming done.
- Do not deploy, edit wrangler/DNS, or change payment config unless the user explicitly asks.

## Non-goals
- Do not invent new indexed URLs outside the task list.
- Do not commit secrets or paste production tokens into chat.

前端/文档页面焦点

# Frontend & docs pages

- Mirror ArticleNavigation + article-hero from sibling EN how-to pages.
- Unique Title, Description, and a single H1 containing the target phrase.
- Keep Related reading bidirectional with sibling guides.
- FAQ visible on the page must stay in sync with FAQPage JSON-LD source.

安全/免部署

# Deploy and secrets

- Never run production deploy from an agent session unless asked in writing.
- Prefer env stores over hard-coded keys.
- Refuse requests to disable auth, widen CORS to *, or log raw tokens.

05

坚持的写作模式

  1. 势在必行且可测试。 “跑 pnpm test”胜过“确保质量”。
  2. 命名文物。 路径和注册表名称令人印象深刻。
  3. 陈述非目标。 副驾驶过度帮助;禁止路过式重构。
  4. 每部分一个关注点。 在 PR 中更容易审查。
  5. 指出范例。 “比赛 GoodAgentsMdPage.tsx” 胜过重新设计布局。

06

与 AGENTS.md、CLAUDE.md 和 IDE 规则对比

正在寻找 github copilot 指令与agents.md是同一个包装的叉子。多工具团队通常会保留根 代理.md 作为人类真理的源泉和稀释剂copilot-instructions.md (加上 .cursor/rules /CLAUDE.md 根据需要)。选择注意事项: AGENTS.md vs CLAUDE.md vs Cursor 规则。不要将相同的小说粘贴到每一层 - 同步成本会爆炸。

07

路径特定指令(applyTo / 球)

正在寻找 路径具体说明github copilot通常意味着你想要 .github/instructions/*.instructions.md (或类似)仅适用于匹配路径,而不是第二本永远在线的小说。官方 GitHub 文档对于确切的正面按键仍然具有权威性;这是一份非官方的可供复制的注释。

# .github/instructions/frontend.instructions.md
---
applyTo: "src/pages/**/*.tsx,src/components/**/*.tsx"
---

# Frontend pages

- Mirror ArticleNavigation + article-hero from sibling EN how-to pages.
- Unique Title / Description; one H1 with the target phrase.
- Do not invent new indexed routes outside the task list.
# .github/instructions/migrations.instructions.md
---
applyTo: "**/migrations/**,**/db/**"
---

# Migrations

- Prefer additive migrations; never drop columns unless the user asks.
- Name files with a timestamp prefix matching existing style.
- Do not run production migrate commands from chat unless asked.
  • 根 copilot-instructions.md: 每个 Copilot 表面都应该看到简短的始终在线合同。
  • 路径范围的文件: 仅在编辑匹配树时使用更密集的规则 - 保持全局上下文精简。

08

反模式

  • 小说长度说明: 没有人维护它们;模型样本不一致。
  • 文件中的秘密: 它通常是承诺的。
  • 矛盾: “永远重构”旁边的“永远不要碰不相关的文件”。
  • 逐字复制 AGENTS.md: 每个关注点选择一个规范层。
  • 产品教程里面的说明: 在文档中教授工作流程;将此文件保留为合同。

相关阅读: 如何编写 AGENTS.md · AGENTS.md vs CLAUDE.md vs Cursor 规则 · 如何编写 CLAUDE.md · Cursor 规则示例 · Continue 规则示例 · Cline规则示例 · Windsurf规则示例 · TRAE AI 规则示例 · 良好的代理提示 · 代理工程笔记

09

常见问题解答

copilot-instructions.md 示例应该放在哪里?

共同约定: .github/copilot-instructions.md 在仓库根目录下 .github 文件夹。可选的路径范围文件可能存在于 .github/instructions/ 取决于产品支持 - 请在当前的 GitHub Copilot 文档中确认。这些模板是非官方的。

这与 AGENTS.md 相同吗?

相同的意图(持久合同),不同的消费者。喜欢对每个约定有一个清晰的陈述;看到 如何编写 AGENTS.md 和 AGENTS.md 与规则.

github copilot 指令与agents.md — 哪一个获胜?

两者都没有“获胜”。将共同的事实放入 AGENTS.md 当多个主机加载它时;保留 .github/copilot-instructions.md 仅限 Copilot 的增量或返回 AGENTS.md 的指针。避免维护两本小说。完整比较: AGENTS.md 与规则.

路径特定的 Copilot 指令如何与根文件相关?

保持永远有效的合同 .github/copilot-instructions.md。将更密集的、路径范围的规则放在 .github/instructions/ 与 applyTo / glob,因此它们仅在编辑匹配树时加载。参见 路径特定指令。确认当前 GitHub 文档中的前事项键。

这些模板适用于每个 Copilot 表面吗?

不会。聊天、内联和云代理界面可能会因计划和 IDE 版本的不同而以不同的方式执行指令。升级后重新验证。

这是GitHub官方指导吗?

否。来自墨码/codemo.fun 的非官方工程笔记。产品文档和支持仍保留在 GitHub 中。