Review the condition of an "AI rules" file (CLAUDE.md, AGENTS.md, .cursor/rules/*.mdc, .github/copilot-instructions.md, .windsurfrules, nested per-area rule files, or any other rule-for-AI markdown) and produce a 5-point scorecard with concrete, actionable fixes. Use when the user invokes /shape-rule-review with a path to a rules file, or asks to "review AI rules", "audit AGENTS.md", "check my CLAUDE.md", "score my agent instructions", "is this rules file healthy", or similar. The skill is agnostic to which tool the rules file targets — it scores the file as a rule-for-AI artifact, not as a project document.
Ships in product-shaping. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Score an AI rules file on five axes and return concrete fixes. The file under review is whatever rule-for-AI markdown the user passes in — this skill does not assume CLAUDE.md, AGENTS.md, or any specific tool.
The skill never edits the file. It produces a scorecard. The user decides what to act on.
$ARGUMENTS should be a path to a single markdown file (absolute, repo-relative, or @-prefixed). Examples:
@CLAUDE.mdAGENTS.md.cursor/rules/api.mdcsrc/api/AGENTS.md.github/copilot-instructions.md~/.claude/CLAUDE.mdIf $ARGUMENTS is empty, ask the user once for the path. Do not guess.
If the path resolves to a directory, ask which file to review. If it resolves to multiple files (e.g. **/AGENTS.md), score them one at a time and report each scorecard separately — do not merge.
If the file does not exist, stop and report the path. Do not invent content.
.mdc, .windsurfrules, custom names — all treated as "a rules-for-AI file".CONTEXT_ROOT and exclude context/ from gitBefore reading or writing anything under context/, apply the context-root protocol documented in ../shape-init/references/context-root-protocol.md (or invoke /shape-init via the Skill tool, which runs the same protocol as its Step 0). The protocol does two things in one block:
CONTEXT_ROOT — the directory context/ lives in. Inside a git repo, that's the parent of git rev-parse --git-common-dir (the main working tree of the repo, even when invoked from a worktree). Outside a git repo, it's the cwd. Anywhere this skill's instructions say context/foo/bar.md, treat it as $CONTEXT_ROOT/context/foo/bar.md.context/ from git — appends one line to <git-common-dir>/info/exclude (repo-local, untracked, never committed, shared by every worktree of the same repo). Idempotent: skipped if context/ is already excluded.Why this skill cares about the worktree case: if the user has a layout like ~/Projects/kibana (main) plus ~/Projects/kibana.worktrees/feature-a, ~/Projects/kibana.worktrees/feature-b, etc., they don't want to re-init each worktree. The protocol resolves CONTEXT_ROOT to ~/Projects/kibana from any of those locations — so /shape-prd writes the same prd.md regardless of which worktree it ran from, and the git-exclude line is set once for the whole repo.
Why this skill cares about the exclude case: when the user is running this command from inside a shared repository they don't own (kibana, an upstream monorepo), the artifact this skill writes under context/ is a personal working note. It must never be staged, committed, or pushed by accident. The exclusion lives only in the user's clone (in info/exclude, never in .gitignore) and cannot leak upstream.
The protocol is idempotent and safe — if context/ is already excluded, this is a no-op. If you are not inside a git repo at all, CONTEXT_ROOT is just the cwd and there is no exclude to write. Surface a one-line git-exclude: <state> in this skill's final summary, plus a context-root: <path> line when CONTEXT_ROOT differs from cwd (so the user knows their notes are in the shared, worktree-spanning location).
Do not edit .gitignore. /shape-init mode=gitignore is the only path that touches the tracked .gitignore, and only when the user explicitly opted in.
Read once; if it's > 2000 lines, read in chunks until complete).AskUserQuestion → 5e atomic-change reminder). The reorder edit, if any, happens here and only with explicit user approval.Count non-empty lines (ignore blank lines and pure separator lines like ---).
| Lines | Verdict | Symbol |
|---|---|---|
| 0–200 | fine | OK |
| 201–500 | watch out | WARN |
| 501+ | warn | FAIL |
Why it matters: long rule files crowd out the user's prompt in the context window, and middle-of-file rules get the weakest attention from the model. Length is a proxy for "you're paying context for things the agent doesn't need every session."
For WARN/FAIL, suggest:
src/api/AGENTS.md).@-references to the canonical file.Scan for fenced code blocks (```) and inline code blocks longer than ~3 lines.
Flag any block that looks like:
tsconfig.json, eslintrc, package.json, wrangler.toml).Do not flag:
npm run dev, git rebase, etc.).For each flagged block, suggest:
@-reference, e.g. @src/features/users/user.service.ts, @docs/api-errors.md.Verdict: OK if 0 flagged blocks · WARN if 1–2 · FAIL if 3+.
Scan for vague intent that cannot be checked against a diff. Common offenders:
For every match, always propose at least one concrete, testable alternative grounded in this project's context. Never suggest "just delete it" — the author put the line there for a reason; your job is to translate the intent into something a reviewer can check against a diff.
To ground the suggestion, pull signal from:
package.json, tsconfig.json, framework choice, lint config, sibling rule files).If the project context truly doesn't suggest anything specific, propose a sensible default for the detected stack and label it (assumed) so the author knows to confirm.
Examples (note how each replacement borrows project-specific names/conventions, not generic advice):
| Vague phrase in file | Project context signal | Grounded testable replacement |
|---|---|---|
| "Write clean code" | TypeScript + ESLint mentioned in same file | "Avoid any. Functions over 40 lines must be split. Run pnpm lint before committing." |
| "Handle errors properly" | Hard rule earlier: API returns { error: {...} } shape | "API handlers must return { error: { code, message, context } } per the shape defined above. Never throw raw." |
| "Be consistent with naming" | File mentions feature.handler.ts elsewhere | "Use <feature>.handler.ts (matching the existing handlers in src/api/), not featureHandler.ts." |
| "Use modern patterns" | Project uses native JS, no lodash in package.json | "Use native Array/Object methods. Do not add lodash — it's not in package.json and we keep it that way." |
| "Make components readable" | React + Tailwind project | "Components over 150 lines must be split. Tailwind classes go through cn() for conditionals (assumed — confirm if a different helper is used)." |
| "Keep things simple" | Python FastAPI service | "Prefer one Pydantic model per request/response. No nested decorators beyond @router.post + @requires_auth." |
Verdict: OK if 0 vague phrases · WARN if 1–3 · FAIL if 4+.
Verdict: OK if 0 vague phrases · WARN if 1–3 · FAIL if 4+.
You are the actor agent reviewing this file. Read it the way you'd read it at the start of a session and ask one question after each paragraph:
"Did I already know this before I opened the file?"
If the answer is "yes, this is in my training data" or "yes, this is the framework's documented default" or "yes, the README/lint config already says this" — flag it. The author paid context for something you didn't need explained.
Use these self-checks while scanning:
useEffect cleanup", "FastAPI uses Pydantic for validation", "PostgreSQL supports JSONB")? If yes — redundant. The tool will catch the violation; the prose won't add anything.Decimal")? You know these. Flag and delete.README.md, package.json scripts, the project layout, or .eslintrc settings? If yes — replace with @README.md / @package.json / @.eslintrc.json. A reference doesn't drift; copied prose does.What is not redundant (don't flag):
useEffect only for non-data side effects").events table is partitioned by month — bulk inserts to the wrong partition fail silently").<verb>_<noun>.posting.ts").For each flagged paragraph, suggest one of:
@-reference — @README.md, @tsconfig.json, @docs/....Verdict: OK if 0 redundant paragraphs · WARN if 1–3 · FAIL if 4+.
Models pay more attention to the start and end of long contexts ("U-shaped attention"). Critical rules buried in the middle of a long file are statistically less likely to be followed. This check has its own multi-step flow because reordering a file is a meaningful edit, not a one-line fix.
Run the steps in order. The result of this check goes into the scorecard and may trigger an interactive reorder.
Walk the file and print the current top-level structure as a numbered list. Use H1/H2 headings (and H3s only if there are no H2s). Include the line number of each heading. Do not comment yet — just lay out what's there.
Example:
Current order:
1. # Welcome to OrderFlow (line 1)
2. ## About the team (line 5)
3. ## Project mission (line 9)
4. ## Our values (line 13)
5. ## Tech stack (line 22)
6. ## Setup (line 36)
7. ## TypeScript (line 78)
...
N. ## Project conventions (line 312)
If the file has no headings, say so explicitly: "No section headings — file is one undifferentiated block."
Now annotate the list. For each section, give it a short tag and a one-line note. Use these tags:
@-syntax (cheap, fine anywhere).Then state the structural problem in one paragraph. Examples:
"Critical security and tenancy rules are at the bottom (line 312). The first 35 lines are INTRO/values/marketing, which the model will weight heavily but which contain no actionable rules. Risk: the agent reads the bloat fully and skims past the rules that actually matter."
"Order is roughly correct — hard rules at top, conventions in the middle, references at the bottom. One INTRO paragraph at line 1 could be tightened, but no structural reshuffle needed."
If the comment in 5b identified a real problem, propose a target order. Frame it as "sections moved to top / kept / moved to bottom / removed", not as a full rewrite of every line.
Example:
Proposed order:
1. ## Hard rules (was: line 312) ← moved to top
2. ## Project conventions (was: line 312, split) ← moved up
3. ## Tech stack (was: line 22) ← kept
4. ## Setup (was: line 36) ← kept, replace with @README.md if possible
5. ## Failure modes (new section) ← collect incident-driven rules here
— ## About the team / Mission / Values ← remove (Check 3/4 already flagged these)
If 5b found no problem, skip 5c entirely — say "Order is sound; no reshuffle needed."
If 5c produced a proposal, ask the user via AskUserQuestion before touching the file. Phrase the question concretely. Example options:
If the user picks an editing option, apply it with care: preserve every byte of rule content (only headings and section blocks move), and write a single edit. If the user picks "leave the suggestion", do nothing.
Always end Check 5 with this reminder, regardless of whether a reorder happened:
Test each change in your next agent session. Reordering a rules file is a context-shape change — its effect on agent behavior only shows up the next time you run a real task. Apply changes one at a time (atomic): reorder, then run a representative task, then move on to the next change (split, dedupe, rewrite). Bundling multiple structural changes makes it impossible to attribute a behavior shift to a specific edit.
Score the file before any reorder happens, based on the original order:
Print exactly this, in this order. Use Polish or English matching the user's prompt language. Reference path:line for every concrete finding so the user can jump straight to it.
# Rule Review — <path>
**Overall:** <one-line summary, e.g. "Healthy file with two redundancy hotspots" or "Long, vague, and bottom-heavy — needs a split">
## Scorecard
| # | Check | Verdict | Score |
|---|----------------------|---------|-------|
| 1 | Length | OK/WARN/FAIL | <n> non-blank lines |
| 2 | Direct snippets | OK/WARN/FAIL | <n> flagged blocks |
| 3 | Precise language | OK/WARN/FAIL | <n> vague phrases |
| 4 | Redundant knowledge | OK/WARN/FAIL | <n> redundant rules |
| 5 | Rule ordering | OK/WARN/FAIL | <one-line reason> |
## Findings
### 1. Length — <verdict>
- <n> non-blank lines.
- <suggestion if WARN/FAIL, otherwise omit>
### 2. Direct snippets — <verdict>
- `path:line-range` — <what kind of snippet> → suggest `@<file>` reference.
- ...
### 3. Precise language — <verdict>
- `path:line` — "<vague phrase>" → "<testable rewrite>"
- ...
### 4. Redundant knowledge — <verdict>
- `path:line` — <what's redundant> → <delete | replace with @reference | keep only if backed by an incident>
- ...
### 5. Rule ordering — <verdict>
- <structural observation, e.g. "Critical security rule at line 287, intro fluff lines 1–42">
- <suggestion>
## Top 3 actions
1. <highest-leverage fix>
2. <second>
3. <third>
If a check is OK, still list it in the table but skip the "Findings" subsection (write ### N. <name> — OK and one short line, nothing more).
The "Top 3 actions" must be ordered by leverage, not by check number. Pick from across all five checks.
@…) and few inline rules: that's a good sign for Checks 2 and 4. Don't penalize it..mdc with frontmatter (globs:, alwaysApply:): count rule lines from after the frontmatter. The frontmatter itself is configuration, not rule content./init and untouched: still review it. Often Check 4 (redundant) will dominate — that's the signal to clean it.AGENTS.md and a nested one).What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/product-shaping:shape-rule-reviewfrom product-shaping
npx claudepluginhub patrykkopycinski/patryks-treadmill-claude-plugins --plugin product-shaping30 skills in this plugin
/shape-agents-mdGenerate an AGENTS.md onboarding document for AI coding agents working in this repository. Inspects the repo (package manifest, README, scripts, lint/test config, layout, commit history) and writes a concise contributor guide titled "Repository Guidelines". Use when the user invokes /shape-agents-md, asks to "create AGENTS.md", "write an agent onboarding doc", "generate contributor guide for agents", or similar. The output is optimized to be small, precise, reference-heavy, and ordered with critical rules at the top — so a future agent reads it once and stays unblocked.
/shape-archiveArchive a completed change by moving its folder into context/archive/ and stamping change.md with archived status/shape-auto-implementAutonomously implement technical plans from context/changes/<change-id>/plan.md under Codex's /goal — no human interaction at any point. Sibling of /shape-implement for unattended runs, in an interactive /goal session or headless via Codex -p. Flips the plan's Automated Progress rows, verifies each phase through an automatic quality-gate stack (plan success criteria, deliberate-break check, full suite), commits each phase on green with Conventional Commits, and surfaces pending Manual rows as a closing human checklist. Use when the user wants autonomous or unattended plan execution, pairs /goal with a plan, asks to "run the plan under /goal", or needs headless implementation.
/shape-bootstrapScaffold a project into the current working directory after the tech stack has been picked. Reads context/foundation/tech-stack.md (the hand-off written by /shape-tech-stack), looks up the chosen card in the starter registry, and runs its CLI through one of three cwd strategies (subdir-then-move, native-cwd, git-clone) with a strict conflict policy that always preserves context/. Two verification slots flank the scaffold: a light pre-scaffold recency check and a deeper post-scaffold audit. Writes a verification log to context/changes/bootstrap-verification/verification.md. Use when the user says "bootstrap the project", "scaffold the app", "set up the codebase", "let's start the project", or naturally follows /shape-tech-stack. Use AFTER /shape-tech-stack.
/shape-cli-guideInvoke this skill when the user asks how to USE the product-shaping plugin day-to-day — which /shape-* command to run next, where artifacts land, how to switch between greenfield and brownfield workflows, troubleshooting errors, or working on a specific OS (Windows, Linux, macOS). Covers all /shape-* slash commands, artifact locations, pipeline stages, common errors, and platform-specific tips. Excludes: first-time installation (use shape-cli-setup instead), developing or contributing to the plugin source code, and general programming help.
/shape-cli-setupInvoke this skill when the user asks how to INSTALL or SET UP the product-shaping plugin for the first time — adding skills to Claude Code, Cursor, GitHub Copilot, Codex CLI, or another AI tool. Covers first-time installation, updating skills, verifying the setup, and configuring for the user's specific tool. Excludes: daily usage questions (use shape-cli-guide instead), writing product artifacts, and general programming help.