Skip to content
Back to skills

Refactoring

ASecurity

Change code structure without changing observable behavior — analysis, invariants, strategy, incremental refactoring, testing, completion.

  • 5 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added October 23, 2026
ai-agentsgotestingrefactoring

Security analysis

A100/100

Pro scans all 16 files and shows the line behind each finding

Scanned October 23, 2026

npx -y skills add vantu1998/universal-ai-starter --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/vantu1998-refactoring-universal-ai-starter/badge)](https://www.skillsdirectory.com/skills/vantu1998-refactoring-universal-ai-starter)

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: Change code structure without changing observable behavior — analysis, invariants, strategy, incremental refactoring, testing, completion.
---

# Refactoring

## Objective

Improve the internal structure of existing code without changing what it does.

The goal is not to make the code "better" by taste. The goal is a change that preserves every
observable behavior while making the code easier to work with, verified by tests that existed
before the refactor still passing.

---

# Workflow

## Phase 1 — Workflow overview

Read [`references/workflow.md`](references/workflow.md) once per refactor to confirm which
phases below actually apply — a rename and a cross-module extraction don't need the same depth.

## Phase 2 — Analysis

Understand what the code currently does and why it needs to change structurally.

Read: [`references/analysis.md`](references/analysis.md)

## Phase 3 — Invariants

State exactly what must stay the same — the contract the refactor is not allowed to break.

Read: [`references/invariants.md`](references/invariants.md)

## Phase 4 — Strategy

Decide the refactoring approach and its order of steps.

Read: [`references/strategy.md`](references/strategy.md)

Draft with: [`templates/refactor-plan.md`](templates/refactor-plan.md)

## Phase 5 — Risk analysis

Identify what could break and how confident the invariants in Phase 3 actually are.

Read: [`references/risk-analysis.md`](references/risk-analysis.md)

Draft with: [`templates/impact-analysis.md`](templates/impact-analysis.md)

## Phase 6 — Incremental refactoring

Apply the change in small, independently-verifiable steps.

Read: [`references/incremental-refactoring.md`](references/incremental-refactoring.md)

## Phase 7 — Testing

Confirm behavior is unchanged.

Read: [`references/testing.md`](references/testing.md)

## Phase 8 — Completion

Confirm the refactor is actually done and the invariants held throughout.

Read: [`references/completion.md`](references/completion.md)

Draft with: [`templates/refactor-checklist.md`](templates/refactor-checklist.md)

---

# Examples

- [`examples/extract-method.md`](examples/extract-method.md) — small, single-file, low-risk.
- [`examples/extract-class.md`](examples/extract-class.md) — splitting responsibilities within a
  module.
- [`examples/simplify-service.md`](examples/simplify-service.md) — removing accumulated
  complexity from one service.
- [`examples/dependency-refactor.md`](examples/dependency-refactor.md) — changing how modules
  depend on each other; highest risk tier.

# Boundaries

- Never change observable behavior — see `.ai/rules/refactor/safety.md`. If the request actually
  needs a behavior change, it's a feature, not a refactor — use `feature-development` instead.
- Don't refactor beyond what was requested — see `.ai/rules/refactor/scope.md`.
- Match existing conventions in the surrounding code; don't use the refactor as a vehicle for
  unrelated style opinions — see `.ai/rules/refactor/quality.md`.

Files in this skill

  • SKILL.md3 KB
  • examples/dependency-refactor.md1.6 KB
  • examples/extract-class.md1.3 KB
  • examples/extract-method.md1 KB
  • examples/simplify-service.md1.3 KB
  • references/analysis.md949 B
  • references/completion.md764 B
  • references/incremental-refactoring.md882 B
  • references/invariants.md989 B
  • references/risk-analysis.md1.1 KB
  • references/strategy.md807 B
  • references/testing.md813 B
  • references/workflow.md894 B
  • templates/impact-analysis.md503 B
  • templates/refactor-checklist.md574 B
  • templates/refactor-plan.md522 B

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.