/quality-guard:quality-refactor [repository, directory, module, or files]from quality-guard
Refactor code against quality-guard's structural rules. Use for reducing complexity, splitting responsibilities, removing dead code, or a repository quality pass. Records the work as GitHub issue sub-issues and stores diagnostic evidence under `.quality/`.
Ships in quality-guard. 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.
Read when SKILL.md points to them; scripts run unread.
Preserve behavior. Scanner findings are symptoms, not architecture, so treat each one as a lead to check against the code and not as an order.
Scope is a repository-relative scope. With no argument, it is the
repository root. It never widens to another checkout. Resolve <repository>
once and reuse it for every command. Scope and root are separate: scope picks
what to scan, root locates the repository, so always pass --root explicitly.
Findings are advisory evidence ranked high, medium, or low. There is no profile selection. Never rewrite configuration or evidence to improve a score.
Build and tests must pass before you plan. If build, tests, scanning, or
report generation fails, keep the failure visible and repair the owning path
when it is in scope. Create .quality/ if it is absent.
Run the scanner twice, first in readable form and then as units:
node <quality-scan.mjs> . --root=<repository> --top=20
node <quality-scan.mjs> . --root=<repository> --format=units > .quality/units.json
quality-guard report --root=<repository> > .quality/quality-report.json
The scanner path is
${CLAUDE_PLUGIN_ROOT}/skills/quality-refactor/scripts/quality-scan.mjs.
Optional test-quality evidence comes from:
quality-guard test-quality --root=<repository> --evidence=.quality/test-quality.json
Read that evidence against Clean Code T1-T9. It accepts normalized C#, Python, TypeScript, and Rust evidence, and also JavaScript, Go, Java, Kotlin, C, and C++. It needs behavior and boundary IDs with input and expected oracles, linked near-bug evidence, runtime failure signatures, and declared timing environments. Missing provider output, oracles, skip reasons, or timing budgets make the evidence unavailable or invalid. They are never a defect in the code. Coverage is a gap signal, not a percentage gate.
References, read as needed:
reference/rules.md explains each rule. Its matrix is the policy catalog,
and its thresholds are starting points. Consult the dispositions before
adding a syntax-only finding, and do not treat a bare ASSUMPTION comment as
a generic scanner violation.reference/catalog.md lists remediation shapes.reference/dispositions.md lists allowed
outcomes. Dispositions apply to chapter-only outcomes.Evidence files are .quality/units.json, .quality/quality-report.json, and
.quality/responsibility-map.json. Reports and hook output are read-only. They
never accept a commit or merge and never close an issue.
${CLAUDE_PLUGIN_ROOT}/skills/quality-refactor/scripts/quality-scan.mjs
exists and that quality-guard resolves on PATH. If either is missing,
stop and report the resolved path. Do not substitute another scanner, and
do not write the .quality/ evidence files by hand.Inspect definitions, callers, tests, imports, and dependency edges before you choose a change. Group findings by structural outcome, not by scanner row or file.
Record the responsibility map in .quality/responsibility-map.json.
Write one sub-issue per outcome under the selected issue, in tier order:
Work them in dependency order. Each sub-issue states one outcome, its boundary, the behavior it preserves, and a verification command. Each stays open until its commit is pushed. Then add the commit as evidence and close it.
A suggestion is a starting shape, not a recipe. Numeric thresholds are not
universal gates. A C# partial-file split never resolves file-length or
partial-type-length.
Refresh the units and report evidence with these commands:
node <quality-scan.mjs> . --root=<repository> --format=units > .quality/units.json
quality-guard report --root=<repository> > .quality/quality-report.json
Before each commit, refresh the report evidence. Treat it as read-only evidence for the next decision.
No hook runs while you edit; run the scanner or read the pull-request gate report for feedback. Findings and report-provider errors are diagnostic evidence. They make no commit or merge acceptance decision.
Failed or unavailable evidence is never a pass. Rerun the narrowest failed check first.
Stop and report when you meet any of these:
Do not apply an arbitrary elapsed-time kill to a long task. Wait for a terminal state.
For each sub-issue, in order:
.quality/units.json, so it is not the baseline:
node <quality-scan.mjs> <scope> --root=<repository> --format=units > .quality/baseline-units.jsonnode <quality-scan.mjs> <scope> --root=<repository> --format=units > .quality/after-units.json.quality/after-units.json against
.quality/baseline-units.json. Restore each
tracked file you changed with git checkout -- <files> and delete each
file you created, by name. Never run git clean, which can remove
.quality/ evidence. Rework the sub-issue's boundary and keep it open.
Never commit a red or worse state.git status --porcelain, stage only its files by explicit path (see "Never"), then refresh the report evidenceRe-scan after each structural wave, because one change can move or expose others.
git add -A or git add .. Stage explicit paths after git status --porcelain and account for every ?? line..quality/ outputs unless git ls-files .quality shows the repository already tracks them.Run the full build, tests, and a final scanner pass. Concretely: the full build, tests must pass, the final scanner in advisory mode must run, and the report must hold current diagnostic evidence.
node <quality-scan.mjs> . --root=<repository> --format=units > .quality/units.json
quality-guard report --root=<repository> > .quality/quality-report.json
Rules and remediation guidance live in the reference files, and they do not override the issue contract.
Final proof is current diagnostic evidence plus declared ownership and dependency outcomes, not a numeric verdict. Leave the parent issue and the pull request open for human review and merge.
reference/catalog.md (opens in a new tab)reference/dispositions.md (opens in a new tab)reference/rules.md (opens in a new tab)scripts/lib/architecture-csharp-records.mjs (opens in a new tab)scripts/lib/architecture-facts.mjs (opens in a new tab)scripts/lib/architecture-fields.mjs (opens in a new tab)scripts/lib/architecture-imports.mjs (opens in a new tab)scripts/lib/architecture-language.mjs (opens in a new tab)scripts/lib/architecture-members.mjs (opens in a new tab)scripts/lib/architecture-python-types.mjs (opens in a new tab)scripts/lib/architecture-types.mjs (opens in a new tab)scripts/lib/config-path-values.mjs (opens in a new tab)scripts/lib/config-values.mjs (opens in a new tab)scripts/lib/config.mjs (opens in a new tab)scripts/lib/design-smells/configuration-facts.mjs (opens in a new tab)scripts/lib/design-smells/design-facts.mjs (opens in a new tab)scripts/lib/design-smells/navigation-facts.mjs (opens in a new tab)scripts/lib/exclusion-config.mjs (opens in a new tab)scripts/lib/finding-symbol.mjs (opens in a new tab)scripts/lib/formatter-width-chain.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub tychohenzen/dod-guard --plugin quality-guard