From spear
Finalize a SPEAR task — optional behavior-preserving refactor, full suite green, flip tasks.md to [x], and clear state to idle.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spear:refineThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
`spear:refine` is the final step of the SPEAR cycle. It enters from `arch-done` and exits to `idle`, completing one full red-green-refactor loop for exactly one task. Scope is intentionally narrow; this is a worker-friendly (Sonnet) skill. For bulk refactors spanning multiple REQ-IDs, defer to `superpowers:executing-plans` instead.
spear:refine is the final step of the SPEAR cycle. It enters from arch-done and exits to idle, completing one full red-green-refactor loop for exactly one task. Scope is intentionally narrow; this is a worker-friendly (Sonnet) skill. For bulk refactors spanning multiple REQ-IDs, defer to superpowers:executing-plans instead.
Shell out to ${CLAUDE_PLUGIN_ROOT}/hooks/lib/state.sh state_assert_phase arch-done.
If the command exits non-zero it will print:
spear requires phase=arch-done; current phase=<actual>
Stop immediately and surface that message. Do NOT proceed.
refineShell out to ${CLAUDE_PLUGIN_ROOT}/hooks/lib/state.sh state_set_phase refine.
Read .claude/spear-state.json and recover currentTaskId. This identifies which task entry in docs/tasks.md will be flipped to [x].
Perform a behavior-preserving cleanup of code introduced during the engine phase. Rules:
Execute the project's full test suite. If any test is red:
phase=refine. Do NOT advance state.failureReason in .claude/spear-state.json.Do NOT proceed until the full suite is green.
In docs/tasks.md, locate the entry for currentTaskId and flip its checkbox:
[~] → [x][ ] → [x]If new sources (libraries, docs, APIs) were consulted during the refactor that are not already cited, append a one-line Evidence entry to the task block.
Shell out to ${CLAUDE_PLUGIN_ROOT}/hooks/lib/state.sh state_clear.
This resets phase to idle and clears currentTaskId, reqId, testFile, testName, testStatus, and evidenceCited from .claude/spear-state.json.
Stage the refactored files and the docs/tasks.md update as a single commit following the project commit convention. The task is now complete.
arch-done → [spear:refine] → idle (cycle complete)
Enters from arch-done. On any test failure stays in phase=refine. On success exits to idle.
docs/requirements.md REQ-048docs/implementation.md §3.6 state helpers, §4.2 TDD cycleplugins/spear/hooks/lib/state.shnpx claudepluginhub badgersmc/spear-plugin --plugin spearCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.