/spwf:simplifyfrom spwf
Phase 4 — Simplify + Self-Review. Two-pass cleanup of the current branch before PR. Pass 1 (mechanical) reviews changed files through three lenses — mechanical removals, DRY/reuse (rule of three; reuse existing helpers), and deslop (AI over-engineering: defensive bloat, `as any`, YAGNI) — applying safe unambiguous changes and flagging judgment calls, with a restraint guardrail (explicit > compact); never touches test files. Pass 2 (judgment) dispatches the `reviewer` subagent in local-diff mode against the pinned commit range to catch correctness, security, missing-test, contract, and reuse/DRY issues while amend is still cheap. Produces a simplify report and a {branch}-self-review.md.
Ships in spwf. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Two passes on the current branch before opening a PR:
reviewer subagent against the pinned commit range for a deeper read (correctness, security, missing tests, contract drift). The subagent gets the openspec proposal + tasks as the intent baseline. Adapted from obra/superpowers — requesting-code-review — "review early, review often."The two passes share the same input (the diff) but answer different questions: the mechanical pass asks "is this clean?", the judgment pass asks "is this right?". Both are pre-PR — by the time a human reviewer sees the request, the diff should already be tight and self-vetted.
git diff --name-only main...HEAD
Exclude test files (any file matching *.test.*, *_test.*, tests/, __tests__/, spec/).
If no files remain after exclusion, report "No non-test files changed." Skip to Pass 2 — there may still be test-only changes worth reviewing.
Read each file through three lenses. For the reuse lens, also read the shared util / helper modules adjacent to the change. Apply only unambiguously-safe changes directly; flag everything that needs judgment.
print(, console.log(, debugger, pprint(Clarity smells — flag, don't apply: unclear names (suggest a rename), functions doing more than one thing (flag for splitting), magic numbers/strings (suggest a named constant), nesting > 3 deep (flag for flattening), dead / unreachable function or class (flag, don't delete).
Remove duplication and reuse what already exists — without manufacturing the wrong abstraction (see Restraint).
grep the adjacent */utils, */shared, */lib, and same-directory modules; if a helper exists, flag "call {existing} instead of the new inline copy."Agent-written diffs accumulate defensive bloat. Flag these (apply only when the fix is trivial and local):
try/catch abnormal for that area — especially on trusted, already-validated codepaths.as any / type-escape casts that paper over a real type — fix the type, don't cast.Simplify for clarity and maintainability, not line count. Leave it alone when:
This restraint is what stops the DRY and deslop lenses from over-firing.
Use the Edit tool for each safe removal identified in Step 2.
Make each edit minimal — remove the exact line or block, nothing more.
## Simplify Report
### Applied
- {file}:{line range}: {what was removed}
### Flagged (judgment needed)
- {file}:{line}: [{clarity | DRY | deslop}] {issue} — {suggested fix}
### Clean
- {file}: No changes needed
If nothing was applied and nothing was flagged, note "Pass 1: no mechanical simplifications found."
If the changed-file list from Step 1 contains any of .tsx, .jsx, .vue, .svelte, .css, or .scss, append a single advisory line to the simplify report:
### Frontend follow-up (optional)
The diff touches frontend files. For design polish / a11y / anti-pattern detection
beyond mechanical cleanup, consider `/impeccable polish` (or `/impeccable audit`,
`/impeccable critique`).
If `impeccable` is not installed:
/plugin marketplace add pbakaus/impeccable
/plugin install impeccable@impeccable
Do not invoke /impeccable polish — it is a separate plugin owned by the user, run on their schedule. This step is informational only. If the diff has no frontend files, omit the section entirely.
If any changes were applied in Step 3, show git diff --stat and propose a commit:
refactor: simplify {change-id} — {brief description of what was removed}
{list the most significant removals — one line each}
{if any judgment-call flag is worth noting in git history: "flagged {X} in {file} for human review"}
{if a removal revealed something unexpected: note it here}
Ask: "Ready to commit? Confirm with 'yes' or edit the message first."
After confirming:
git add {changed files}
git commit -m "{confirmed message}"
If nothing was applied (report showed only flags), skip the commit and continue to Pass 2.
After mechanical cleanup, dispatch the reviewer agent in local-diff mode for a deeper read. The point is to catch correctness / security / missing-test / contract issues now, while amend is cheap, instead of after the PR is open.
The reviewer must see exactly what was reviewed. Capture SHAs after the Pass 1 commit (if any) so the report covers the simplified state.
BRANCH=$(git branch --show-current)
BASE=${1:-main}
HEAD_SHA=$(git rev-parse HEAD)
BASE_SHA=$(git merge-base "$BASE" HEAD)
RANGE="$BASE_SHA..$HEAD_SHA"
ADDS=$(git diff --shortstat "$RANGE" | grep -oE '[0-9]+ insertion' | grep -oE '[0-9]+' || echo 0)
DELS=$(git diff --shortstat "$RANGE" | grep -oE '[0-9]+ deletion' | grep -oE '[0-9]+' || echo 0)
FILES=$(git diff --name-only "$RANGE" | wc -l)
Triviality short-circuit: if ADDS + DELS < 10 AND FILES <= 2, skip the subagent dispatch and report:
Pass 2 skipped: diff is trivial (+{ADDS} -{DELS} across {FILES} file(s)).
Proceed to /spwf:pr-create — the human reviewer can eyeball this.
Read each of these. Note which are absent (do not fabricate):
openspec/changes/*/proposal.md — stated intentopenspec/changes/*/tasks.md — what was supposed to be doneopenspec/changes/*/design.md — decisions madegit log $RANGE --oneline — commit summaryIf there is no openspec change in flight (hotfix branch, scratch work), record "no openspec change; intent derived from commit messages" and proceed.
Use the Task tool with subagent_type=reviewer. Compose the prompt from this template (fill every {placeholder}):
Mode: local-diff (pre-PR self-review)
Review the local branch before PR creation. Do not call
glab mr vieworgh pr view— there is no open request yet.Branch:
{BRANCH}→{BASE}Commit range:{BASE_SHA}..{HEAD_SHA}Size: +{ADDS} -{DELS} across {FILES} filesStated intent (from
openspec/changes/{change-id}/proposal.md, or "no openspec change"):{paste proposal summary verbatim, or the "no openspec change" note}Tasks completed (from
openspec/changes/{change-id}/tasks.md):{paste the task list}How to read the diff: run
git diff {BASE_SHA}..{HEAD_SHA}and read the unified output. Also rungit log {BASE_SHA}..{HEAD_SHA} --onelinefor commit-by-commit shape.What to flag (use these exact severities — they are required):
- 🔴 Critical — must fix before opening PR (bugs, security holes, broken contracts, lost data paths)
- 🟡 Important — should fix before opening PR (missing tests, missing error handling, unclear logic at trust boundaries, public API drift not in spec)
- 🟢 Minor — nice to have, can defer (naming, micro-perf, comment quality)
Also weigh reuse, DRY, and over-engineering (Important if they add real maintenance cost, else Minor) — these complement Pass 1's mechanical sweep:
- Reuse: new code re-implementing an existing repo helper — name the helper to call instead.
- DRY: the same logic duplicated 3+ times (rule of three) — name where the single helper should live. (Do NOT flag duplication that appears only twice, or abstractions that would couple unrelated cases — a little duplication beats the wrong abstraction.)
- Over-engineering (deslop): defensive checks /
try/catchon trusted codepaths,as anycasts papering over a real type, single-caller abstractions or unused config (YAGNI).Do not flag:
- Formatting / style — linters handle this
- Existing code outside the diff — out of scope
- Mechanical cleanup already done in Pass 1 (debug prints, dead imports, commented-out code)
- Speculative refactors that aren't tied to a concrete duplication or defect
- "What about X?" hypotheticals without a codebase-grounded example
- DRY consolidation that would create a premature/forced abstraction (explicit > compact)
Output: write the report to
{BRANCH}-self-review.mdin the current directory using the standard pr-review report format. Include the pinned SHAs ({BASE_SHA}..{HEAD_SHA}) in the header so it's unambiguous what was reviewed. The Verdict line should be one of:✅ Ready for PR,🔄 Fix Critical/Important before PR, or💬 Minor only — proceed at discretion.
After the subagent returns, read {BRANCH}-self-review.md and surface:
✓ Simplify complete.
Pass 1 (mechanical): {N_applied} applied, {N_flagged} flagged
Pass 2 (reviewer): {N_critical} 🔴 Critical, {N_important} 🟡 Important, {N_minor} 🟢 Minor
Range: {BASE_SHA}..{HEAD_SHA} (+{ADDS} -{DELS} / {FILES} files)
Reports:
- simplify report (above)
- {BRANCH}-self-review.md
Verdict: {agent's verdict line}
Then recommend (pick one — the conditions are mutually exclusive):
Fix Critical findings before /spwf:pr-create.
Run: /spwf:address-review {BRANCH}-self-review.md
No blockers. You can proceed to /spwf:pr-create, but consider:
/spwf:address-review {BRANCH}-self-review.md
Clean. Proceed: /spwf:pr-create
glab mr view/gh pr view. The "Mode: local-diff" line and the explicit "do not call" instruction in the prompt are load-bearing — do not omit them. If the subagent returns an error about a missing PR ref, you forgot the mode line.openspec/changes/. Say so explicitly in the prompt ("no openspec change; intent from commit messages") rather than fabricating a proposal./spwf:address-review to act on Pass 2 findings.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
38 skills in this plugin
/address-reviewPhase 6.5 — Address Review. Turn review feedback into action. Sources feedback from either a local report file (e.g. {branch}-review.md from /spwf:pr-review or {branch}-self-review.md from /spwf:simplify) or fetched human comments on an open PR/MR. For each item runs READ → VERIFY → EVALUATE → implement-or-push-back, in priority order (blocking → important → nit). Forbids performative agreement ("you're absolutely right"). Use after pr-review, or whenever a reviewer leaves comments./agent-optimiseCross-cutting — Audit both the project .claude/ and personal ~/.claude/ for quality issues. Covers CLAUDE.md scope and length, agent descriptions, skill frontmatter, and settings.json conflicts. Always audits both scopes. Produces a prioritised P1/P2/P3 fix list./npx claudepluginhub simon-potter/spwf --plugin spwf