Skip to content
Back to skills

Refactoring

ASecurity

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).

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgotestingrefactoring

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add vectora-os/kit --skill refactoring --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactoring?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactoring
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectora-os-refactoring/badge)](https://www.skillsdirectory.com/skills/vectora-os-refactoring)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.