engineer/skills/refine/SKILL.md
Use after a feature's code is implemented and passing, to clean up the changed code before verification. Triggers — "/engineer.refine", "refine this code", "clean up the feature", "refactor what we built".
npx skillsauth add swingerman/atdd refineInstall 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.
Charter-bound clean-up of a feature's changed code — Checkpoint 6. Modeled on Claude Code's stock /simplify (a three-subagent parallel review) with two layers the stock skill lacks: charter validation of every proposal, and graceful breaking changes.
The behavior contract (ACs + specs) is sacred — a refactor that breaks it is a category error. New shapes are introduced alongside old, never instead of.
Checkpoint 6, after atdd:atdd-team produces passing code, before crap-analyzer (Checkpoint 7).
Verification independence: if manifest.verification.apply_to_checkpoints includes 6, refine must run on a non-implementer agent. The three review subagents (Step 2) are fresh regardless, so independence is satisfied by construction.
Not for: changing behavior (feature-edit); risk analysis (crap-analyzer); code that isn't implemented/green yet.
Step 0 — Entry gate. Before starting, verify the prior checkpoint is complete: run ${CLAUDE_PLUGIN_ROOT}/scripts/dae_handoff.py <feature-dir> --through 5. On a non-zero exit, stop and surface the gap to the human — do not proceed.
Verify branch hygiene: run ${CLAUDE_PLUGIN_ROOT}/scripts/dae_branch.py <feature-dir>.
On a non-zero exit, stop and surface the message to the human — switch
branches and re-invoke. The check honors the git.manual: true manifest
opt-out.
After the gate passes, show the pipeline breadcrumb: run
${CLAUDE_PLUGIN_ROOT}/scripts/dae_progress.py <feature-dir> and present its
output to the human — it shows where this checkpoint sits in the DAE pipeline.
The breadcrumb is advisory: a non-zero exit or a missing progress.md never
blocks the skill. Then create one TodoWrite todo per workflow step below. See
${CLAUDE_PLUGIN_ROOT}/references/progress-indicator.md.
${CLAUDE_PLUGIN_ROOT}/scripts/dae_resolve.py (see references/resolving.md); locate the feature. Scope = the feature branch's changed code (git diff against the branch point). Load feature.md, acs.md, spec.md, CHARTER.md.superpowers:dispatching-parallel-agents), each over the same changed code. Before dispatching, run ${CLAUDE_PLUGIN_ROOT}/scripts/dae_dup.py <methodology-root> to get deterministic project-wide duplicate findings; pass the JSON result into the Reuse subagent's context as a tool input (the subagent treats it as one signal alongside its own LLM judgment, and produces a unified set of findings — not a separate list). If dae_dup.py returns anything other than status: ok — status: unavailable (the backend tool isn't installed), status: skipped (manifest duplication.skip: true), status: unsupported (the configured backend isn't implemented in this version), or status: error (scan failed) — surface that status in the Reuse subagent's prompt and proceed with its existing LLM-only judgment.
dae_dup.py findings), reinvented wheels, dead code, missed existing utilities. LSP-first lookup — at dispatch time, check whether an LSP MCP capability is available; pass that detection result and the LSP-first preference into the Reuse subagent's prompt so it uses find-references / workspace-symbols when available, with graceful fallback to grep + Read. See ${CLAUDE_PLUGIN_ROOT}/references/code-lookup.md.CHARTER.md (architecture, conventions, methodology, the ACs+specs contract). Charter-violating proposals are rejected internally — never shown. This filter is the DAE-specific layer the stock skill lacks.manifest.yml's infra: section, then call ${CLAUDE_PLUGIN_ROOT}/scripts/dae_infra.py ensure <names> for each declared dependency the tests need. On a start-failed structured failure → stop and surface the diagnosis. On a missing manifest declaration for required infra → stop with the "declare in manifest" message. Any failure → revert that proposal and report.If a charter rule itself blocks a genuinely better design, surface it in the handoff (→ feature-edit / charter amendment). refine does not amend the charter.
Emit per ${CLAUDE_PLUGIN_ROOT}/references/handoff-summary.md. agent_id must differ from the implementer if checkpoint 6 is independence-gated. checkpoint: 6; recommended_next: "crap-analyzer for Light Verify".
The handoff MUST include the exit_criteria block asserting each of Checkpoint 6's exit criteria (Foundation Design Section 8) with verified_by, met, and evidence. For verified_by: tool criteria, the evidence MUST be the tool's actual output. The checkpoint is marked done only when every criterion is met.
Before stopping, apply the dispatch rule — see ${CLAUDE_PLUGIN_ROOT}/references/handoff-dispatch.md. CP7 verify needs a fresh agent (charter §6); a subagent dispatched via the Agent tool satisfies that. Do not ask the human "want me to dispatch?" — auto-dispatch at autonomy medium/high; confirm-then-dispatch at low. If verify needs resources you can't reach (live emulators, prod creds), write the exact dispatch command in the handoff and stop.
superpowers:dispatching-parallel-agents — the Step 2 dispatch pattern${CLAUDE_PLUGIN_ROOT}/references/handoff-dispatch.md — when to dispatch vs stopengineer/references/handoff-dispatch.md — infra-ensure-before-stop ruledata-ai
Use immediately after a PR is merged to clean up the local feature branch and resync main. Triggers — "/engineer.post-merge", "did we merge", "did we push", "PR merged", "post-merge cleanup", or right after a `gh pr merge` succeeds in the same session.
data-ai
Use to drive a bug fix from first report through close, with a "why didn't we catch it?" loop at the end. Triggers — "/engineer.fix", "a bug came in", "this is broken", "a user reported X", "there's a defect", "we have a regression", "this needs a fix", "another report", "more issues", "still failing", "validation failed again", "another bug", "next defect", "more fixes".
testing
Use mid-task when the working thread is lost — after a context compaction, a long agent run, or coming back to a feature unsure of the role, the current checkpoint, or the next action. Triggers — "/engineer.reorient", "reorient", "re-anchor", "what should I be doing right now", "I lost track", "where was I".
development
Use to check a feature's code against the charter's architecture rules — dependency layering, cycles, forbidden patterns, file naming, file size. Triggers — "/engineer.arch-check", "architecture check", "check architecture fitness", "does this follow the charter", "check layering".