Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Refactoring?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-refactoring)
---
name: refactoring
description: Behaviour-preserving refactoring — code smells, characterization tests, small safe steps (extract, inline, move, rename), seams for testing, parallel change, separating refactor and feature commits, measuring complexity. Use to improve structure without changing behaviour (refactoring, code smells, extract method, characterization tests).
metadata:
category: engineering-excellence
---
# Refactoring
## Purpose
Improve structure in steps that provably keep behaviour.
**Use when:** before or after features in messy code.
**Not for:** behaviour changes.
## Inputs
- Code, tests, smells.
## Outputs
- Refactoring commits with green tests, metrics.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "refactoring"` for prior decisions, patterns and anti-patterns.
## Steps
1. **Pin.** Characterization tests for current behaviour.
Done when behaviour pinned.
2. **Step.** One refactoring per commit; tests green after each.
Done when every commit green.
3. **Seams.** Introduce seams for dependencies.
Done when code testable.
4. **Measure.** Complexity before/after.
Done when improvement shown.
## Best practices
- Use IDE automated refactorings.
- Parallel change for public interfaces.
## Common mistakes
- Mixing refactor with behaviour change.
- Refactoring without tests.
## Example
Extracted pricing and tax modules in 6 commits; complexity 48 → 12.
## Reusable prompt
```text
Apply the Refactoring skill (.agents/skills/refactoring/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Pin behaviour with tests, then refactor in small green steps and report complexity before/after.
Return: Refactoring commits with green tests, metrics..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```