Safely improve code quality through test-driven refactoring with automatic validation and rollback. Use during quality review to reduce technical debt while preserving behavior.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
The command stays on one line. Scroll horizontally to inspect it before copying.
Prefer a local copy? Download the files currently available to SkillsMP.
File Explorer
6 files
Showing SKILL.md
SKILL.md
Source instructions · Read-only preview
name
refactor-code
description
Safely improve code quality through test-driven refactoring with automatic validation and rollback. Use during quality review to reduce technical debt while preserving behavior.
acceptance
[{"config_validated":"Configuration allows refactoring and prerequisites verified"},{"opportunities_identified":"Refactoring opportunities identified and prioritized by risk"},{"refactorings_applied":"Selected refactorings applied incrementally with test validation"},{"log_created":"Refactoring log documenting all changes with rationale"},{"tests_passing":"All tests passing after refactoring with no behavioral changes"}]
inputs
{"task_file":{"type":"string","required":true,"description":"Path to task specification with quality findings"},"aggressiveness":{"type":"enum","required":false,"description":"Refactoring scope: conservative, moderate, aggressive","default":"moderate"},"allow_refactoring":{"type":"boolean","required":false,"description":"Override config to allow/disallow refactoring"}}
outputs
{"refactorings_applied":{"type":"number","description":"Number of refactorings successfully applied"},"refactorings_failed":{"type":"number","description":"Number of refactorings that failed and were rolled back"},"files_modified":{"type":"array","description":"List of files modified during refactoring"},"quality_impact":{"type":"object","description":"Before/after quality metrics showing improvements"}}
Safely improve code quality through automated refactoring while maintaining behavioral correctness. This skill identifies refactoring opportunities from quality findings and applies them incrementally with continuous test validation.
Core Capabilities:
Test-driven refactoring (run tests after each change)
Refactoring opportunities identified and prioritized
Selected refactorings applied incrementally
All tests passing after refactoring
Refactoring log created with full documentation
Task file updated with summary
Quality metrics improved or maintained
User notified with actionable next steps
Safety Guarantees
Behavioral preservation (no functionality changes) | Test validation (after each change) | Automatic rollback (on failures) | Full traceability (logged) | Incremental (one at a time) | User control (choose scope)
Integration with Quality Review
Runs after nfr-assess, before quality-gate in quality workflow. Optional - only if user opts in and tests exist/pass. Improvements reflected in final gate decision.