From dev
Generate and execute a phased remediation plan from a code quality audit. Use when the user says "remediate", "fix the audit findings", "code quality fix", "improve the score", "address the audit", or after running a /code-quality audit. Reads the most recent audit file, generates a phased plan with a fixed exit score, and optionally executes via subagent-driven development.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dev:code-quality-remediateThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Takes a code quality audit report and produces a bounded, phased remediation plan.
Takes a code quality audit report and produces a bounded, phased remediation plan. Optionally executes the plan via subagent-driven development.
This skill exists because remediation without structure causes cascade failure. Evidence: 10 plans in one day on a single repo, target moving from 5.0 to 8.5 with no stop condition. The rules below prevent that.
One plan per audit cycle. Never spawn a follow-up plan from within this skill. If more improvement is needed after execution, run a fresh audit first (Step 6), then start a new cycle: audit → triage → plan → execute. The constraint is on plans chaining without re-assessment, not on doing multiple rounds. Each cycle gets a fresh view of what actually changed.
Fixed exit score per cycle. The plan declares a target score upfront (typically +1.5 to +2.0 from current; up to +3.0 if starting below 5.0). Execution stops when the target is reached OR when all phases complete, whichever comes first. No moving goalposts within a cycle.
Plan cap: 1,500 lines. If the plan exceeds this, the audit findings are too broad. Go back and triage the audit — pick the top 3-5 findings by impact, not all of them.
Max 4 phases (6 if starting below 5.0). Each phase must be independently shippable. If you need more than the cap, the scope is wrong.
Two-plan rule. If a domain already has 2 remediation plans within 14 days, the next action is a design review, not a third plan. The architecture is wrong, not the code.
/dev:code-quality-remediate # auto-detect latest audit
/dev:code-quality-remediate --target 7.5 # set explicit exit score
/dev:code-quality-remediate --plan-only # generate plan, don't execute
/dev:code-quality-remediate --audit path.md # use specific audit file
docs/code-quality/ (or use --audit path)If no audit file exists, stop and tell the user to run /code-quality first.
Not all findings are worth fixing. Triage by impact × effort:
| Priority | Criteria | Action |
|---|---|---|
| P1 — Fix now | Critical severity, low effort, blocks other work | Include in Phase 1 |
| P2 — Fix this plan | Important severity, or Critical + high effort | Distribute across phases |
| P3 — Defer | Minor severity, or cosmetic, or requires design decision | Document in plan as explicitly deferred |
| P4 — Won't fix | Accepted tech debt, library limitations, not worth the churn | Document with rationale |
Persistent issues (flagged in 2+ prior audits) get auto-promoted one priority level. If something has been flagged 3 times and never fixed, it's P1 regardless of severity.
P4 re-confirmation: If a "won't fix" item from a prior plan reappears in the current audit, it must be explicitly re-confirmed as P4 with updated rationale — not silently inherited. Agents will otherwise just carry forward the deferral without re-evaluating whether the original reason still holds.
Calculate a realistic exit score:
User can override with --target. Never set a target above 9.0 — that's maintenance, not remediation.
Write the plan to docs/superpowers/plans/YYYY-MM-DD-code-quality-remediation.md.
# Code Quality Remediation Plan
**Audit source:** docs/code-quality/YYYY-MM-DD-audit.md
**Current score:** X.X/10
**Target score:** Y.Y/10
**Exit condition:** Target reached OR all phases complete
## Triage Summary
| Finding | Severity | Priority | Phase |
|---------|----------|----------|-------|
| ... | Critical | P1 | 1 |
## Deferred (P3/P4)
- [finding] — reason for deferral
## Phase 1: [Name] (estimated: N tasks)
**Goal:** [What this phase achieves, measurable]
**Dimension targets:** [Which scores should improve]
### Tasks
1. [Specific, atomic task with file references]
2. ...
## Phase 2: [Name]
...
## Verification
After each phase, re-run the relevant audit checks (not the full audit)
to confirm the dimension scores improved as expected.
as any, v.any(), adding
validators. Why second: this is mechanical, high-impact, and gives the compiler
the information it needs to catch regressions from Phase 3 restructuring.Present the plan to the user for approval. On approval:
Run only the checks relevant to what the phase changed:
| Phase | What to verify | Commands |
|---|---|---|
| 1 — Infrastructure | env centralised, AppError adopted, Zod at boundaries | grep -rn "process\.env\." src/ convex/ | grep -v "lib/env" (should be 0), grep -rn "catch.*: any" src/ (should be 0), tsc --noEmit |
| 2 — Type safety | as any eliminated, v.any() resolved, validators in place | grep -rn "as any" src/ | grep -v node_modules | wc -l, grep -rn "v\.any()" convex/ | wc -l, tsc --noEmit |
| 3 — Structure | no reverse deps, files under 500 lines, clean imports | grep -rn "from.*stores/" src/utils/, find src/ -name "*.ts" -o -name "*.tsx" | xargs wc -l | sort -rn | head -5, tsc --noEmit |
| 4 — Coverage | tests pass, new tests cover changed code | npm test or equivalent, check test file count vs previous |
tsc --noEmit runs after every phase — it's the cheapest regression detector.
If any verification fails, fix before proceeding to the next phase.
After execution (or after plan-only generation):
/code-quality auditProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub mercurial-weasel/bh-ops-claude-plugins --plugin dev