skills/spec-remediate/SKILL.md
This skill should be used when the user asks to "remediate the audit findings", "fix the spec violations", "close the audit findings", "fix conformance violations", or "spec remediate". Reads a spec-audit report, drives one smart subagent per VIOLATION to converge the code back to the frozen spec, and re-audits until clean. Edits production code; never rewrites the spec.
npx skillsauth add ryan-mahoney/ryan-llm-skills spec-remediateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Close the conformance loop. spec-audit reports VIOLATIONs but never edits code; this skill consumes that report and fixes the findings, then re-audits until the report is clean or a cap is reached.
Every fix converges the code back to the frozen spec — it never re-designs, re-scopes, or "improves." The audit finding is the brief and the spec is the target; remediation is a constrained search toward an existing answer, not a design task. The report/remediate split mirrors the compile/audit firewall: the skill that judges does not patch, and the skill that patches does not re-judge its own work — spec-audit re-runs as the independent oracle.
Resolve the spec target in this order:
$ARGUMENTS is a path to a markdown file, use that file.$ARGUMENTS names a folder under .specs/, use .specs/<feature-slug>/spec.md.$ARGUMENTS is a GitHub issue number and the current repository is hosted on GitHub, read the issue with gh issue view <issue-number> --json body --jq .body, extract its Spec folder: .specs/<feature-slug>/ footer, and use the local .specs/<feature-slug>/spec.md. If the local file is missing but the issue body has a valid footer, create the folder and write the issue body to spec.md..specs/*/spec.md.Then locate the audit report from local artifacts. Phase is a checklist/report identity only; a worktree does not need to know it is "phase N." Use this order:
spec.md footer or body contains a phase marker such as (phase N) or Phase N of M, use .specs/<feature-slug>/audit/phase-<n>.md..specs/<feature-slug>/audit.md exists, use it..specs/<feature-slug>/audit/phase-*.md file exists, use that file.audit/phase-*.md files exist and no phase marker was resolved, stop and ask the user to pass the phase-specific audit path or add a phase marker to the local spec.md. Do not infer the phase from the branch name.If no audit report exists, stop and instruct the user to run spec-audit first. Do not audit inline: this skill remediates a report produced by an independent audit pass; judging and patching in one context defeats that independence.
Also read, when present, the matching .specs/<feature-slug>/criteria/phase-<n>.md (or criteria.md) and .specs/<feature-slug>/invariants.md. The criteria give each finding its Source: spec quote and ownership context; the ledger names cross-phase invariants a fix must not re-break.
Read the audit report's verdict table and finding blocks. Act only on entries the report marks VIOLATION. Then classify each:
UNVERIFIABLE entries are not remediation targets — they are criteria-quality gaps. Collect them for escalation to spec-criteria; never "fix the code" to satisfy a check that could not be executed. pre-existing findings are out of scope for this branch unless the user explicitly asks to address them.
If there are zero VIOLATION entries, report that the audit is already clean and stop. Nothing to remediate is a success state, not an error.
Announce the remediation plan: which findings will be fixed here, which are escalated, in finding order.
Fix one finding per subagent. Each finding is independent; do not bundle. Use a capable general-purpose subagent — remediation needs to understand structure and perform relocations/refactors, so do not down-tier the model for it.
Preferred generic invocation for Codex, Claude, OpenCode, and harnesses with a generic subagent facility:
Agent(
subagent_type: "general-purpose",
description: "Remediate <feature-slug> finding <criterion-id>",
prompt: "<REMEDIATION_PROMPT>"
)
Augment CLI adapter: use the spec-step-implementer subagent when it is configured under ~/.augment/agents/ or ./.augment/agents/, asking it to remediate exactly one finding with the prompt below. If subagents are unavailable in the current client, remediate directly and report that subagent execution was unavailable.
You are remediating a single spec-conformance violation. Your goal is to make the
code conform to the frozen spec — not to redesign, re-scope, or improve anything.
Spec file (the frozen target): <absolute path to .specs/<feature-slug>/spec.md>
Audit finding:
Criterion: <criterion id and title>
Spec quote (the rule that was violated): <Source quote from the finding/criteria>
Evidence: <file:line excerpts the audit cited>
What conforming code looks like: <the finding's conforming-shape paragraph>
Cross-phase invariants this fix must not re-break: <relevant invariants.md entries, or "none">
Before editing, read:
1. The cited evidence locations and the surrounding code.
2. The named spec quote in context in the spec file.
3. The precedent or owner the spec points to (e.g. the store, a shared module),
so the relocated logic matches what already exists there.
Rules:
- Fix ONLY this finding. Do not touch unrelated code or other findings.
- Converge to the spec quote. If the spec says a responsibility is owned by module
X, move it to X and delete the violating copy — do not leave both.
- Prefer deletion and relocation over addition. Most conformance fixes remove
duplicated or misplaced code; they rarely add new structure.
- Do NOT edit the spec, the criteria, or the audit report. If you conclude the
spec itself is wrong (conforming would break the system, or the rule contradicts
another part of the spec), STOP and report "spec defect" with your reasoning
instead of changing code.
- Keep changes surgical, explicit, and fail-fast. No speculative abstractions.
- Follow existing project patterns at the destination.
- Adjust tests only where this fix changes behavior or moves code under test.
- Do not run the entire test suite; run only targeted tests for the changed code.
Output requirements:
1. Summary of what changed and why it now conforms to the spec quote.
2. Exact files modified.
3. Targeted verification run and outcomes.
4. Whether you believe this finding is fully closed, plus any spec-defect concern.
Verification is mechanical: scope, conformance, tests. Do not re-open the design.
Check: command from the criteria file, or read the cited location to confirm the violating pattern is gone. This is a fast local confirmation, not a substitute for the full re-audit below.fix(<scope>): <criterion-id> <short description>.(#<issue-number>) when a GitHub issue is known.One commit per finding, so each remediation is independently reviewable and revertable.
After every code-drift finding has been addressed (fixed or escalated), re-run the audit as the independent oracle:
spec-audit for this spec by following ~/.agents/skills/spec-audit/SKILL.md. It regenerates audit/phase-<n>.md against the new code.Do not silently re-run past the cap. Surfacing "did not converge in N rounds" is the correct outcome; hand it back.
Remediation edits code; it never rewrites intent. Route the other failure shapes to the skill that owns them, and report them clearly instead of forcing a code fix:
spec-review to edit spec.md, then spec-criteria to recompile the checklist, then re-audit. Record each in .specs/<feature-slug>/blockers.md with the finding id and the reasoning.UNVERIFIABLE entries): escalate to spec-criteria to tighten the compiled check. These are not code problems..specs/<feature-slug>/blockers.md.When a GitHub issue mirror is available, also post escalations as an issue comment with gh issue comment <issue-number> --body "...".
spec-audit, not by self-assessment. The judge stays independent of the patcher.After the loop converges or hits the cap, report:
blockers.md entries.Do not add Co-Authored-By trailers, "Generated with" footers, or any AI model attribution.
documentation
This skill should be used when the user asks to "write a spec", "create a spec", "spec this out", "plan this feature", or "write an implementation plan" for a feature or change. Creates a structured implementation spec in .specs/<slug>/spec.md and mirrors it to GitHub only when the current repository is hosted on GitHub.
data-ai
This skill should be used when the user asks to "execute the spec", "run the plan", "implement the spec", "implement the issue", "run all steps", or "run spec". Implements all steps from .specs/<slug>/spec.md, using a subagent per step when the harness supports subagents.
testing
This skill should be used when the user asks to "review a spec", "review an issue", "check the plan", "review the implementation plan", "find gaps in the spec", or "review spec". Reviews .specs/<slug>/spec.md for gaps and viability, edits it when needed, and mirrors changes to GitHub only when a GitHub mirror exists.
development
This skill should be used when the user asks to "compile review criteria", "generate spec criteria", "compile the conformance checklist", "build guardrails from the spec", or "spec criteria". Compiles a frozen spec's normative prose into an executable conformance checklist at .specs/<slug>/criteria/, blind to any implementation of that spec, and accumulates cross-phase ownership invariants in .specs/<slug>/invariants.md.