rules-check-drift
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/rules-check-drift — keep your rules file true, not longer
/rules-check-drift — 让规则文件准确无误,而非冗长冗余
Your rules file — or — is a steering document, not documentation: your ground
rules, your conventions, and a current map of where things live. Its only failure mode that matters is being
wrong: a stale rule or a drifted map actively misleads the agent on every future run. This skill checks the
rules file against what just changed and proposes the smallest edit that keeps it true.
CLAUDE.mdAGENTS.mdWrong rules are worse than missing rules. A longer rules file is worse than a lean one. Most changes need no edit at all — adding a wrong or verbose line makes it worse.
你的规则文件—— 或 ——是一份指导文档,而非普通文档:它包含你的基本规则、约定,以及当前的代码位置映射。它唯一关键的失效模式就是不准确:过时的规则或偏离实际的映射会在未来每次运行时误导Agent。本技能会将规则文件与最新变更进行比对,并提出最小化的修改建议,以确保规则文件始终准确。
CLAUDE.mdAGENTS.md错误的规则比缺失规则更糟,冗长的规则文件比精简的更糟。 大多数变更根本不需要修改规则文件——添加错误或冗余的内容只会让情况变得更糟。
Input
输入
- — optional diff range. Default: uncommitted + staged (
$ARGUMENTS); fall back togit diff HEAD.main...HEAD - Scope: the project's rules file(s) — and/or
CLAUDE.md, the root file + any package-level ones. (IfAGENTS.mdis just aCLAUDE.mdimport, check@AGENTS.md.) Ignore README,AGENTS.md, anddocs/agent/command/skill files. This skill exists to keep the rules honest, nothing else..claude/
- — 可选的差异范围。默认值:未提交+已暂存的变更(
$ARGUMENTS);若不存在则回退为git diff HEAD。main...HEAD - 范围:项目的规则文件 — 和/或
CLAUDE.md,包括根目录下的文件以及任何包级别的规则文件。(如果AGENTS.md只是导入了CLAUDE.md,则检查@AGENTS.md。)忽略 README、AGENTS.md目录以及docs/下的Agent/命令/技能文件。本技能仅用于确保规则的准确性,除此之外不处理其他内容。.claude/
Process
流程
1. See what changed
1. 查看变更内容
git diff <range>git status执行 + 。注意:移动/重命名/删除的文件、新模块、变更的约定,以及该变更确立的任何新不变式。
git diff <range>git status2. Read the rules file as it is now
2. 读取当前的规则文件
Load the project's rules file — or (and any package-scoped ones). Hold each claim against the change set.
CLAUDE.mdAGENTS.md加载项目的规则文件—— 或 (以及任何包级别的规则文件)。将文件中的每项声明与变更集进行比对。
CLAUDE.mdAGENTS.md3. Flag ONLY these three things
3. 仅标记以下三类问题
- A stated rule or fact is now false — e.g. "routes live in " but they moved. → fix it.
src/routes/ - The architecture map drifted — a path or "where things live" pointer no longer matches reality. → fix the wrong entry (don't catalog every new file).
- A new durable invariant must hold going forward — the change introduces a rule that must stay true
(e.g. "never call the DB from handlers — go through "). → add it as one line.
repository/
Everything else, leave alone. Do not suggest an edit to record that a feature was added (that's a
changelog — the codebase is the source of truth), to restate what the code already makes obvious, or to add
background/rationale/prose that doesn't steer future work.
- 已声明的规则或事实现已失效——例如:“路由位于 ”但实际已迁移到其他位置。→ 修复该规则。
src/routes/ - 架构映射偏离实际——路径或“代码位置”指针不再符合实际情况。→ 修复错误的条目(无需记录每个新文件)。
- 必须确立新的持久不变式——该变更引入了未来必须遵守的规则(例如:“绝不要从处理器中直接调用数据库——需通过 层”)。→ 将其添加为单行规则。
repository/
其他所有内容均保持不变。不要建议修改以“记录新增功能”(这是变更日志的职责——代码库才是事实来源),也不要重述代码已明确体现的内容,或添加对未来工作无指导意义的背景/理由/散文内容。
4. Write each suggestion the way CLAUDE.md should read
4. 按照CLAUDE.md的规范编写建议
- One bullet, not a paragraph. A rule is a line, not an essay.
- Keep the map current — don't grow it. Fix the wrong path; don't enumerate the new ones.
- State rules in natural language; reference the codebase, never paste code. Copied code goes stale; the
codebase stays true. Good: "follow the error pattern in ." Bad: pasting the class.
src/core/errors/
- 使用单个项目符号,而非段落。规则是一行内容,而非一篇文章。
- 保持映射的时效性——不要扩展它。修复错误的路径;无需枚举新路径。
- 用自然语言表述规则;引用代码库,切勿粘贴代码。复制的代码会过时;而代码库始终是准确的。正确示例:“遵循 中的错误处理模式。”错误示例:粘贴类代码。
src/core/errors/
Output
输出
undefinedundefinedRules-file drift check — range: <range>
规则文件漂移检查 — 范围:<range>
Fix (now false)
修复(已失效内容)
| Where | What's wrong | Minimal fix |
|---|---|---|
| "Architecture" map | routes moved | update the one path |
| 位置 | 问题所在 | 最小化修复方案 |
|---|---|---|
| "架构"映射 | 路由已从 | 更新该路径 |
Add (new invariant only)
添加(仅新不变式)
- <one-line rule> — established by <the change that made it durable>
- <单行规则> — 由<确立该规则的变更>所引入
Checked, still true — no edit
已检查,仍准确无误 — 无需修改
- <areas you verified need no change>
If nothing drifted: **"The rules file is still accurate for these changes — no edits needed."**- <你已验证无需变更的内容>
若未发现漂移:**“规则文件仍与这些变更保持一致——无需修改。”**Rules
规则
- Advisory. Report the drift; only apply/piv-commit edits if the caller explicitly asks.
- Rules file only (/
CLAUDE.md). Not README, not docs.AGENTS.md - Lean by default. When in doubt, suggest nothing.
- Run it before every merge (or as part of ) so your rules never drift behind the code.
/piv-review-changes
- 指导性建议。仅报告漂移情况;仅当调用者明确要求时,才应用/提交修改。
- 仅处理规则文件(/
CLAUDE.md)。不处理README或文档。AGENTS.md - 默认保持精简。存疑时,不建议任何修改。
- 每次合并前运行(或作为 的一部分),确保规则不会落后于代码变更。
/piv-review-changes