跳到正文
Skillpedia
智能体41k · #6813

editing-agents-md

它能做什么

本技能帮助你选择哪些内容应写入 AI 编程工具在每次会话开始时读取的说明文件。适合维护这些文件,并希望文件简短而实用的人。

适用场景

  • ✓当你想在 AGENTS.md 或 CLAUDE.md 中添加一条新规则时。
  • ✓当某条规则总是被打破,有人建议把它写下来的时候。
  • ✓当说明文件变得很长,需要精简的时候。

技能链接

https://github.com/PostHog/posthog/blob/master/.agents/skills/editing-agents-md/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/PostHog/posthog/blob/master/.agents/skills/editing-agents-md/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我判断这条规则是否应写入我的 CLAUDE.md,并改写一下,让 AI 能够遵守。”

每周 5 个新技能,1 分钟读完。

工作原理

它首先询问,是否有代码检查工具或测试等其他机制可以执行这条规则。只有在没有更合适的方式时,才把规则保留在文件中,并改写得更清楚。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Editing AGENTS.md

The root AGENTS.md loads in full at the start of every session, in every tool that reads it. A line you add is paid for by every task in the repo, forever, whether or not that task touches the subject. So the question is never "is this true?" — it is "is this worth loading into every session?"

Two findings set the frame:

  • Adding a context file raises inference cost by over 20% on average, and does not reliably raise task success (2602.11988). A second study measured the opposite sign on runtime and tokens (2601.20404). The evidence is mixed, which argues for a small sharp file rather than no file.
  • File size, instruction position, file architecture, and contradictions between adjacent files each produced no detectable effect on whether an agent follows a rule, across 1,650 sessions (2605.10039).

Read the second one carefully, because it kills a whole class of proposals. Moving a section higher "so the agent sees it" is churn against a null result. Do not reorder for attention. Reorder only when a heading makes a rule easier for a human to find or cite.

1. Does this belong in the file at all?

Work down this ladder and stop at the first rung that fits. It is the same ladder AGENTS.md states for itself.

Rung Mechanism Use when
1 Linter — ruff, oxlint, semgrep (.semgrep/rules/devex/) The violation is a code pattern a matcher can see
2 lint-staged / pre-commit It needs the file list or the working tree, not the AST
3 Skill (.agents/skills/) It applies to one kind of task, not every task
4 A rule in AGENTS.md None of the above can carry it

Rung 4 is the last resort, not the default. A convention that a semgrep rule could catch belongs in .semgrep/rules/devex/ — read its README for the severity choice and the WARNING-to-ERROR ratchet. Put the migration playbook in the rule's message: field, because that is what an author actually reads when it fires.

Rung 3 is the one people skip most. If a rule only matters while merging a PR, writing a migration, or building a workflow, it belongs in that skill, where it loads on demand and can be ten times longer.

2. Check the six smells

Measured across 100 popular repositories (2606.15828). Prevalence in brackets.

  • Lint leakage [62%] — the rule restates what a linter already blocks. This is the most common failure by a wide margin. Do not delete the reasoning, but cut it to the reason plus the rule id, and tag it. CI is the check; the prose is only the why.
  • Context bloat [42%] — content that does not apply to most sessions. Environment-specific setup, product documentation, anything a docs/ page should hold. Target is under 200 lines.
  • Skill leakage [35%] — task-specific instructions sitting in the always-loaded file instead of a skill.
  • Conflicting instructions [28%] — two rules that disagree, often because one aged. Grep for the other statement before you add yours.
  • Init fossilization [24%] — text nobody has reviewed since it was generated. If you are editing near a stale rule, verify it still holds and fix it in the same diff.
  • Blind references [16%] — a link with no statement of what it holds and when to read it. Every link needs a "read this when …" clause, or an agent has no basis to spend a tool call on it.

3. Write the rule as an invariant, not an instruction

The file is read by authors and reviewers alike. An invariant serves both; an instruction has to be translated.

  • Say what must be true: "Every tenant-data model must have team_id."
  • Not what to do: "Remember to add team_id when you make a model."

Be specific and imperative. A vague preference changes nothing. "Use uv pip, never pip" works. "We prefer uv" does not. Name the trigger the rule fires on, so a reader scanning a diff knows when it applies.

Keep to the repo's prose conventions: ASD-STE100 Simplified Technical English, active voice, one

常见问题

为什么不把所有规则都写进文件?

每一行都会在每次会话中加载,因此文件越长,成本越高,也不一定能帮助 AI 遵守规则。简短、精准的文件效果更好。

这同样适用于 CLAUDE.md 吗?

是的。AGENTS.md 和 CLAUDE.md 都会在每次会话开始时加载,因此同样的建议适用于两者。

我应该把规则移到文件靠前的位置,让 AI 更容易看到吗?

通常不需要。本技能所依据的研究发现,位置并不能可靠地改变智能体是否遵守某条规则,因此调整顺序只为方便人们找到相应章节。

详情

作者的原始描述

Decide whether a rule belongs in an AGENTS.md / CLAUDE.md file, and write it so it holds. Use before adding, editing, or removing any instruction in a root or nested AGENTS.md, when a convention keeps getting broken and someone proposes documenting it, when reviewing a diff that touches one, or when a file has grown and needs a trim. Carries the enforcement-tag convention (`[lint: <id>]` / `[review]`), the six configuration smells to check against, and the size budget. Trigger terms: AGENTS.md, CLAUDE.md, agent instructions, context file, add a rule, document this convention, the file is too l

repo: PostHog/posthog

热度

GitHub 星标
41k
排名
#6813
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能