用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill rule-review命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | rule-review |
| description | > Use when this capability is needed. |
This skill reads an agent-rules file (any common format) and emits a structured audit across seven dimensions. Each finding cites concrete evidence: a line number, a file path, a ~/.claude/rules/ reference, a grep result, or a contradicting file. By default it's read-only — it diagnoses but doesn't change anything. With --fix, it applies safe rewrites.
Built on findings from Lulla et al. (well-used AGENTS.md → −28% time / −16% tokens) and Gloaguen et al. (redundant or LLM-generated rule files → +20–23% cost). The dimensions exist because each one is a documented failure mode in those evaluations.
Use when:
AGENTS.md / CLAUDE.md and want a sanity check before committing..github/copilot-instructions.md).Skip when:
CLAUDE.md containing only @AGENTS.md). Review the canonical file it points to instead./agents-md first; come back here for the audit after.AGENTS.md)./agents-md — upstream. Authors the file this skill audits. Steps 4–5 of /agents-md already apply the test-of-inclusion and size budget; this skill verifies the result against the broader dimension list.~/.claude/rules/*.md — read-only reference. Findings cite specific rules from this layer when flagging redundancy.docs/reference/lessons.md — read-only reference. Findings citing "no Why:" propose deriving the reason from a matching lessons entry.The audit report and any --fix rewrites to the target file are written in English, regardless of the user's chat language. This matches the global policy in ~/.claude/CLAUDE.md §13. Interactive prompts during the audit may use the user's working language; the persisted findings and fixed file content are always English.
... blocks longer than ~10 lines, or full config snippets pasted in. These belong in referenced files, not rules.~/.claude/rules/*.md (when ai-devkit's rules layer is installed) or in publicly trained model knowledge. Each redundant rule cites the source that already covers it.AGENTS.md + CLAUDE.md + .github/copilot-instructions.md + .cursor/rules/*.mdc), check that they don't contradict. Drift creates a coin-flip for the agent.When invoked:
/rule-review AGENTS.md): jump to Step 1.Which file to audit?
- AGENTS.md (root, 187 lines)
- CLAUDE.md (root, 1 line, imports AGENTS.md)
- src/api/AGENTS.md (nested, 42 lines)
- .cursor/rules/api.mdc (Cursor)
- .github/copilot-instructions.md (Copilot)
Pass: /rule-review <path>
Then STOP.
Read the target file FULLY. Strip the YAML frontmatter (if any). Split into:
#, ##, ###) — used for the order check (Dimension 5).Print summary: Parsed: <N> headings, <M> rules, <K> code blocks, total <L> lines.
wc -l <file>
| Lines | Verdict | Note |
|---|---|---|
| ≤ 150 | OK | |
| 151–200 | WARN | At the recommended ceiling. Consider splitting area-specific content. |
| 201–300 | FAIL | Over guidance. Recommend split. List the largest sections. |
| > 300 | FAIL (critical) | Strongly over. Middle of file is in low-attention zone. |
For each fenced code block, measure lines.
| Block size | Verdict | Action |
|---|---|---|
| 1–10 lines | OK if it's an inline example | Keep. |
| 11–25 lines | WARN | Extract to a referenced file, leave a pointer (> See: docs/reference/<file>). |
| > 25 lines | FAIL | Definitely extract. Inline blob is a context tax. |
Cite line ranges for each finding.
Run regex / heuristic over each rule line:
| Pattern | Flag |
|---|---|
| `\b(consider | try to |
| `\b(clean | good |
| `\b(always | never |
| Sentence with no verb in present tense | Likely descriptive, not prescriptive — rewrite. |
For each flagged line, emit a finding with verdict: WARN and a one-line rewrite suggestion.
If ~/.claude/rules/*.md exists, read each. Build a topic index (typescript.md → ["unknown over any", "Zod validation", ...]).
For each rule line in the target file, attempt match:
| Match | Verdict |
|---|---|
| Exact or near-exact ai-devkit coverage | FAIL — cite ~/.claude/rules/<file>.md line. Rule should be removed. |
| Partial overlap | WARN — cite, ask user to decide. |
| No match in auto-active layer, but it's a mainstream framework idiom (e.g. "use React hooks not class components") | WARN — model knowledge probably covers it; ask if it's local-specific. |
Local-specific (anchored in docs/, lessons.md, an incident) | OK. |
If ~/.claude/rules/ is missing, the redundancy check is skipped with a note: "ai-devkit rules layer not installed at ~/.claude/rules/ — Dimension 4 partial."
U-shaped attention: top and bottom of long contexts are best attended; middle is weakest. If the file is > 100 lines, the critical rules should be in the top third.
Heuristic for "critical": rules tagged by the user with **critical**, **must**, (critical), or appearing under a ## Critical heading. If no explicit tagging, infer from content (e.g. access-control, destructive-operation gates, irreversible-action rules).
| Order | Verdict |
|---|---|
| Critical rules all in top third | OK |
| Critical rules in middle third | WARN — propose reorder. |
| Critical rules in bottom third or scattered | FAIL — propose reorder. Print suggested section sequence. |
Check sibling files for the same scope:
# at the same directory level as target
ls AGENTS.md CLAUDE.md .github/copilot-instructions.md .cursor/rules/*.mdc 2>/dev/null
For each pair of files present:
| Pair | Allowed shape | Drift check |
|---|---|---|
AGENTS.md + CLAUDE.md (shim) | CLAUDE.md is one-line @AGENTS.md import OR symlink | If CLAUDE.md has its own rules → FLAG; either consolidate into AGENTS.md or split scopes explicitly. |
AGENTS.md + .github/copilot-instructions.md | Copilot shim points to / mirrors AGENTS.md | If Copilot file has rules diverging from AGENTS.md, list the differences. |
AGENTS.md + .cursor/rules/*.mdc | Cursor rules are area / glob-scoped, AGENTS.md is repo-wide | If Cursor rule restates a repo-wide AGENTS.md rule, flag redundancy. |
For each drift finding, print the conflicting lines side by side:
DRIFT — error response shape
AGENTS.md:42 "Errors return { error: { code, message, context } }."
copilot-instructions:18 "Errors return { error: string }."
Suggested fix: align both to AGENTS.md (the canonical one), or split scopes.
For each rule that targets a code pattern, attempt a grep:
| Rule pattern | Grep |
|---|---|
"Use absolute imports @/..." | grep -rEn "from ['\"]@/" --include='*.ts' --include='*.tsx' |
"All migrations live in db/migrations/" | test -d db/migrations && ls db/migrations |
"Use the formatDate() helper, not new Date().toISOString()" | grep -rEn "new Date\\(\\)\\.toISOString" --include='*.ts' (occurrences = signal that the rule is being violated, not that it's dead) |
| "Class components are prohibited" | grep -rEn "class \\w+ extends (React\\.)?Component" --include='*.tsx' (zero hits across a year-old repo ⇒ probably no longer relevant) |
| Grep result | Verdict |
|---|---|
| Pattern is referenced widely in code | OK (rule is alive) |
| Pattern is rare but present | OK |
| Pattern is absent from the entire codebase | WARN — possibly obsolete. Ask the user. |
| Pattern is forbidden + still present (rule is failing!) | FAIL — surface the violating files. |
Skip rules that are not pattern-grep-able (workflow rules, business decisions). Note them in the report as "not grep-checkable".
Print a single audit report:
# Rule audit — <path>
Audited: <YYYY-MM-DD> Total lines: <N> Rules parsed: <M>
## Verdict summary
| Dimension | Verdict | Findings |
|---|---|---|
| 1. Length | OK / WARN / FAIL | … |
| 2. Embedded blocks | OK / WARN / FAIL | … |
| 3. Language precision | OK / WARN / FAIL | <N> lines flagged |
| 4. Redundancy | OK / WARN / FAIL | <N> redundant w/ ai-devkit |
| 5. Order | OK / WARN / FAIL | … |
| 6. Cross-tool drift | OK / WARN / FAIL | <N> divergences |
| 7. Dead rules | OK / WARN / FAIL | <N> patterns absent |
## Findings
<one entry per finding, with: dimension, line range, verdict, evidence, suggested rewrite>
If invoked with --fix, jump to Step 9. Otherwise, STOP after the report and offer:
Actions you can take:
- Re-author from scratch: /agents-md <scope>
- Apply safe auto-fixes only: /rule-review <file> --fix
- Edit manually and re-audit
Apply only safe rewrites — never destructive:
| Finding type | Auto-fixable? | Action |
|---|---|---|
Redundant with ~/.claude/rules/ (FAIL) | YES | Remove the rule, leave a <!-- removed: covered by ~/.claude/rules/<file>.md --> marker. |
| Oversized code block (FAIL) | NO | Print the extraction path that should be created; do not auto-extract. |
| Wrong order (critical in middle) | YES | Reorder sections: critical → conventions → workflow → references. |
| Vague verb (WARN) | NO | Print suggested rewrite; user applies. |
| Drift between files (FAIL) | NO | Print diff; user resolves. |
| Dead rule (WARN) | NO | Mark with <!-- candidate: obsolete, no codebase matches as of <date> -->. |
Backup the original to <path>.bak-YYYYMMDD-HHMMSS before applying changes. Print the diff after applying.
Re-emit the audit report against the fixed file. Verify dimensions improved before declaring done.
/agents-md to author one..cursor/rules/*.mdc with non-markdown body): apply only dimensions 1, 5, 6 (length, order, cross-tool). Skip the rest with a note./rule-review AGENTS.md CLAUDE.md): audit each in turn, then run Dimension 6 across all of them as a single pass.~/.claude/rules/ is gigantic and dimension-4 matching is slow: tolerate; cache the topic index in memory for the session.Source: bpawlakj/ai-devkit — distributed by TomeVault.