/tdd-refactor
[DEPRECATED] Refactor code with test safety net to improve quality. Use when saying \"TDD refactor\", \"refactor with tests\", or \"improve code quality\".
$ npx -y skills add anton-abyzov/specweave --skill tdd-refactor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/tdd-refactor
Context preview
The summary Claude sees to decide when to auto-load this skill.
[DEPRECATED] Refactor code with test safety net to improve quality. Use when saying \"TDD refactor\", \"refactor with tests\", or \"improve code quality\".
SKILL.md
tdd-refactor.SKILL.mddescription: "[DEPRECATED] Refactor code with test safety net to improve quality. Use when saying \"TDD refactor\", \"refactor with tests\", or \"improve code quality\"."
version: 1.0.0
deprecated: true
> ⚠️ DEPRECATED: Use `sw:tdd-cycle --phase refactor` instead. This skill will be removed in v1.3.0.
Migration
This skill has been deprecated as part of the Opus 4.7 framework alignment (increment 0669).
- **Use instead**: `sw:tdd-cycle --phase refactor` runs only the REFACTOR phase (improve code quality with test safety net)
- **Removal**: Scheduled for v1.3.0 (2 minor releases after v1.1.0)
- **Why**: The three TDD phase skills (tdd-red, tdd-green, tdd-refactor) were consolidated into `sw:tdd-cycle` with a `--phase` flag. Alias routing in `marketplace.json` redirects `/sw:tdd-refactor` → `/sw:tdd-cycle --phase refactor` automatically.
For the migration policy, see `.specweave/docs/internal/specs/skill-deprecation-policy.md`.
---
TDD Refactor Phase - Improve Code Quality
Refactor code with confidence using comprehensive test safety net.
Usage
Use Task tool with subagent_type="general-purpose" to perform safe refactoring.
Prompt: "Refactor this code while keeping all tests green: $ARGUMENTS. Apply TDD refactor phase:
1. **Pre-Assessment**: Run tests to establish green baseline, analyze code smells, document current metrics 2. **Code Smell Detection**: Duplicated code, long methods, large classes, long parameter lists, feature envy, dead code 3. **Refactoring Techniques**: Extract Method/Variable/Interface, inline unnecessary indirection, rename for clarity, move to appropriate classes, replace conditionals with polymorphism 4. **Incremental Steps**: Small atomic changes, run tests after each modification, commit after each successful refactoring, keep separate from behavior changes 5. **Safety Verification**: Run full test suite after each change, check for performance regressions, maintain/improve code coverage
Output:
- Refactored code with improvements applied
- Test results (all green)
- Before/after metrics comparison
- Applied refactoring techniques list"
Safety Checklist
Before committing:
- All tests pass (100% green)
- No functionality regression
- Performance metrics acceptable
- Code coverage maintained/improved
Recovery
If tests fail: immediately revert last change, identify breaking refactoring, apply smaller incremental changes.
Code to refactor: $ARGUMENTS
Resources
- [Official Documentation](https://verified-skill.com/docs/reference/skills#tdd-refactor)
Read more
description: "[DEPRECATED] Refactor code with test safety net to improve quality. Use when saying \"TDD refactor\", \"refactor with tests\", or \"improve code quality\"." version: 1.0.0 deprecated: true
> ⚠️ DEPRECATED: Use `sw:tdd-cycle --phase refactor` instead. This skill will be removed in v1.3.0.
Migration
This skill has been deprecated as part of the Opus 4.7 framework alignment (increment 0669).
- **Use instead**: `sw:tdd-cycle --phase refactor` runs only the REFACTOR phase (improve code quality with test safety net)
- **Removal**: Scheduled for v1.3.0 (2 minor releases after v1.1.0)
- **Why**: The three TDD phase skills (tdd-red, tdd-green, tdd-refactor) were consolidated into `sw:tdd-cycle` with a `--phase` flag. Alias routing in `marketplace.json` redirects `/sw:tdd-refactor` → `/sw:tdd-cycle --phase refactor` automatically.
For the migration policy, see `.specweave/docs/internal/specs/skill-deprecation-policy.md`.
---
TDD Refactor Phase - Improve Code Quality
Refactor code with confidence using comprehensive test safety net.
Usage
Use Task tool with subagent_type="general-purpose" to perform safe refactoring.
Prompt: "Refactor this code while keeping all tests green: $ARGUMENTS. Apply TDD refactor phase:
1. **Pre-Assessment**: Run tests to establish green baseline, analyze code smells, document current metrics 2. **Code Smell Detection**: Duplicated code, long methods, large classes, long parameter lists, feature envy, dead code 3. **Refactoring Techniques**: Extract Method/Variable/Interface, inline unnecessary indirection, rename for clarity, move to appropriate classes, replace conditionals with polymorphism 4. **Incremental Steps**: Small atomic changes, run tests after each modification, commit after each successful refactoring, keep separate from behavior changes 5. **Safety Verification**: Run full test suite after each change, check for performance regressions, maintain/improve code coverage
Output:
- Refactored code with improvements applied
- Test results (all green)
- Before/after metrics comparison
- Applied refactoring techniques list"
Safety Checklist
Before committing:
- All tests pass (100% green)
- No functionality regression
- Performance metrics acceptable
- Code coverage maintained/improved
Recovery
If tests fail: immediately revert last change, identify breaking refactoring, apply smaller incremental changes.
Code to refactor: $ARGUMENTS
Resources
- [Official Documentation](https://verified-skill.com/docs/reference/skills#tdd-refactor)
Spec-first AI development: describe a feature → AI creates spec + plan + tasks, builds autonomously, syncs to GitHub/JIRA. Domain-expert skills for PM, Architect, Frontend, QA learn your patterns permanently. Claude Code, Codex, Cursor, Copilot & more.
Repo: anton-abyzov/specweave
Other skills on specweave.
- /ado-mapper
Bidirectional conversion between SpecWeave increments and Azure DevOps work items. Use when exporting increments to ADO epics, importing ADO epics as increments, or resolving sync conflicts. Handles Epic/Feature/User Story/Task hierarchy mapping.
Open skill - /ado-multi-project
[DEPRECATED] Use `sw:multi-project --tool ado` instead. Organizes specs and tasks across multiple Azure DevOps projects. This skill will be removed in SpecWeave v1.3.0.
Open skill - /ado-resource-validator
Validates Azure DevOps projects, area paths, and teams exist with auto-creation of missing resources. Use when setting up ADO integration, configuring .env variables, or troubleshooting missing project errors. Supports project-per-team, area-path-based, and team-based strategies.
Open skill - /ado-sync
[DEPRECATED] Help and guidance for Azure DevOps synchronization with SpecWeave increments. Use when asking how to set up ADO sync, configure credentials, or troubleshoot integration issues. For actual syncing, use sw-ado:push or sw-ado:pull command.
Open skill - /analytics
Analytics and metrics for SpecWeave usage — token consumption, cache efficiency, agent spawn counts.
Open skill - /architect
System architect for scalable technical designs and ADRs. Use for system architecture, microservices, database design, trade-off analysis, component diagrams, tech selection.
Open skill

