.claude/skills/speckit-workflows-refactor/SKILL.md
Create a refactoring workflow with metrics tracking and behavior preservation validation.
npx skillsauth add pradeepmouli/lspeasy speckit-workflows-refactorInstall 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.
The user input to you can be provided directly by the agent or as a command argument - you MUST consider it before proceeding with the prompt (if not empty).
User input:
$ARGUMENTS
The text the user typed after /speckit.workflows.refactor (or /speckit.refactor) in the triggering message is the refactoring description. Assume you always have it available in this conversation even if $ARGUMENTS appears literally below. Do not ask the user to repeat it unless they provided an empty command.
Given that refactoring description, do this:
Run the script .specify/extensions/workflows/scripts/bash/create-refactor.sh --json "$ARGUMENTS" from repo root and parse its JSON output for REFACTOR_ID, BRANCH_NAME, REFACTOR_SPEC_FILE, TESTING_GAPS, METRICS_BEFORE, BEHAVIORAL_SNAPSHOT. All file paths must be absolute.
IMPORTANT You must only ever run this script once. The JSON is provided in the terminal as output - always refer to it to get the actual content you're looking for.
Load .specify/extensions/workflows/templates/refactor/refactor-template.md to understand required sections.
Write the refactor spec to REFACTOR_SPEC_FILE using the template structure:
Update TESTING_GAPS file with initial testing gap assessment:
Update BEHAVIORAL_SNAPSHOT file with key behaviors to preserve:
Report completion with Next Steps:
Refactor workflow initialized
**Refactor ID**: [REFACTOR_ID]
**Branch**: [BRANCH_NAME]
**Refactor Spec**: [REFACTOR_SPEC_FILE]
**Testing Gaps**: [TESTING_GAPS]
**Behavioral Snapshot**: [BEHAVIORAL_SNAPSHOT]
**Next Steps:**
1. **CRITICAL FIRST STEP**: Complete testing gap assessment in [TESTING_GAPS]
- Identify all code that will be modified
- Assess test coverage for affected areas
- Add tests for critical gaps BEFORE capturing baseline
2. Review refactoring goals and behaviors to preserve
3. Once testing gaps are addressed, baseline metrics have been automatically captured
4. Run `/speckit.plan` to create refactoring plan
5. Run `/speckit.tasks` to break down into tasks
6. Run `/speckit.implement` to execute refactoring
**Reminder**: Behavior must not change - all tests must still pass
**NEW**: Testing gap assessment ensures adequate coverage exists to validate behavior preservation
Note: The script creates and checks out the new branch before writing files. Refactoring MUST follow test-first approach - all existing tests must pass before and after. NEW: Testing gaps must be assessed and critical gaps filled BEFORE baseline capture. Baseline metrics are automatically captured during workflow creation but should only be trusted after testing gaps are addressed.
tools
Use for ANY rename, file-move, or move-symbol refactor — especially rename-heavy work across multiple files. Claude Code's built-in LSP tool is READ-ONLY (find references, but no rename / file-move / move-symbol). Hand-editing those refactors silently misses re-exports, aliased imports, type-only imports, and {@link} doc references. This skill drives a real language server via the `lspeasy` CLI to apply a correct WorkspaceEdit that catches every reference. Trigger when the user asks to rename a function/class/variable/type project-wide, move a file and fix its importers, or pull a symbol out into another module.
tools
Documentation site for lspeasy Use when: You are building a browser-based LSP client, a WebSocket-backed language....
tools
Documentation site for lspeasy Use when: You are implementing a custom client layer and need the same validation....
tools
Use when working with lspeasy (client, core, server). Covers: lsp, language-server-protocol, lsp-client, language-client, jsonrpc, transport, lsp-server, language-server.