首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >AGENTS.md:统一编码助手指令文件的新标准

AGENTS.md:统一编码助手指令文件的新标准

作者头像
乱世不浮生
发布2026-06-18 08:47:54
发布2026-06-18 08:47:54
90
举报

TL;DR

从此刻起,你的项目中除了 README.md 文件外,可能还会包含另一个 markdown 文件:AGENTS.md

  • README.md:为人类设计,通常提供如项目介绍、安装指南、使用示例等信息。
  • AGENTS.md:为 Coding Agents 设计,提供额外的详细信息,如环境搭建、构建步骤、测试方法、代码规范、安全注意事项等。

背景

如果你经常在多种编程助手间来回切换,肯定会我将要说的问题深有体会。通常如果想要编程助手更好的工作、输出更高质量的代码,我们需要在项目中为其提供 instructions(指令 - 系统提示词)文件。比如 .cursor/rules.clinerules.github/copilot-instructions.mdclaude.mdgemini.md。这些文件的内容通常类似,但各自的文件名和位置不同。即使类似 Cline、Roo Code、Kilo Code 这类同出一脉的编程助手,他们的目录名也各不相同。更不同说不同的编程助手了。

通常我的做法是使用软连接。首先创建一个统一的 instructions 文件,再通过软连接将 .clinerules.cursor/rules.github/copilot-instructions.md 都链接到同一个文件。 你也可以使用 intellectronica/ruler[1],ruler 可以将同一份 instructions 文件 .ruler/ 分发给多个编程助手,并更新 .gitignore 文件。

久而久之,你将会收获一个混乱的项目目录(再加上 MCP 服务器的管理文件),即使用上软链接或者 ruler(只是降低了维护成本)。

image from @shadcn[2]

AGENTS.md

天下大事,分久必合。合久必分。

Google、OpenAI、Factory、Sourcegraph 和 Cursor 等公司联合推出了 AGENTS.md[3],一个简单开放的标准,旨在为编码代理提供一种可预测的方式来理解和操作软件项目。

说人话就是,项目目录不会再混乱了。

它的内容类似于 README.md,但更注重于编程助手的使用和配置。通常包含:

  • 项目概述
  • 构建和测试命令
  • 代码风格指南
  • 测试说明
  • 安全注意事项

目前主流的编程助手均都支持 AGENTS.md。

如何使用

非常简单,在项目的根目录创建 AGENTS.md 文件即可,内容使用标准 Markdown 格式。

示例:

代码语言:javascript
复制
# Sample AGENTS.md file

## Dev environment tips
- Use `pnpm dlx turbo run where <project_name>` to jump to a package instead of scanning with `ls`.
- Run `pnpm install --filter <project_name>` to add the package to your workspace so Vite, ESLint, and TypeScript can see it.
- Use `pnpm create vite@latest <project_name> -- --template react-ts` to spin up a new React + Vite package with TypeScript checks ready.
- Check the name field inside each package's package.json to confirm the right name—skip the top-level one.

## Testing instructions
- Find the CI plan in the .github/workflows folder.
- Run `pnpm turbo run test --filter <project_name>` to run every check defined for that package.
- From the package root you can just call `pnpm test`. The commit should pass all tests before you merge.
- To focus on one step, add the Vitest pattern: `pnpm vitest run -t "<test name>"`.
- Fix any test or type errors until the whole suite is green.
- After moving files or changing imports, run `pnpm lint --filter <project_name>` to be sure ESLint and TypeScript rules still pass.
- Add or update tests for the code you change, even if nobody asked.

## PR instructions
- Title format: [<project_name>] <Title>
- Always run `pnpm lint` and `pnpm test` before committing.

如何迁移

将已有的编程助手指令文件重命名为 AGENTS.md 即可。如果你在使用 intellectronica/ruler,将 ruler.toml 中对应的 output_path 改为 AGENTS.md

即使所有的编程助手都支持 AGENTS.md,intellectronica/ruler 还是有其价值,因为它还可以进行 mcp 配置的分发。除非...

参考资料

[1]

intellectronica/ruler: https://github.com/intellectronica/ruler

[2]

@shadcn: https://x.com/shadcn/status/1955254151807635602

[3]

AGENTS.md: https://agents.md/

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-08-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 乱世不浮生 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • TL;DR
  • 背景
  • AGENTS.md
    • 如何使用
    • 如何迁移
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档