timander/copilot-instructions-starter-kit/refactor

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Apply the refactoring catalog (Fowler, Beck Tidy First, Feathers legacy techniques) to existing code. Use when the user wants to improve a specific piece of code without changing its behavior.

Install

npx vskill@latest install timander/copilot-instructions-starter-kit/refactor

SKILL.md

Refactor

Before Touching Anything

  • Tests exist? If yes, run them green first. If no, write characterization tests before changing structure.
  • One change at a time. Never combine behavior change with structural change in the same step.
  • Commit between moves. Small, reversible steps; each commit compiles and passes tests.

The Move Catalog

Reach for the smallest move that fits. Tidy First moves (Beck) are smaller and often applied during the green-refactor step. Refactoring Catalog moves (Fowler) are larger and applied to address named smells. If a Tidy First move would do, take that instead.
Tidy First (Beck) — small, frequent
MoveWhen
Guard clausesNested conditionals hide the happy path
Slide statementsRelated code is scattered
Split phaseOne function does two distinct things in sequence
Extract helperBlock deserves a name
RenameName lies, hedges, or is generic
Refactoring Catalog (Fowler) — larger, smell-driven

Pick the move that matches the smell. Always name it and say why it improves the design.

MoveWhen to apply
Extract MethodLong method or block that does one nameable thing
Extract ClassOne class has multiple reasons to change
Extract InterfaceConcrete dependency blocks testability or substitution
Replace Conditional with Polymorphismswitch / chain of if over a type code
Introduce Parameter ObjectThe same parameter cluster recurs
Replace Constructor with Factory MethodConstruction needs a name or selection logic
Move Method / Move FieldFeature envy: method touches another class's data more than its own
Replace Inheritance with DelegationFragile hierarchy; "is-a" was wishful
Inline Method / Inline ClassIndirection adds nothing
RenameName doesn't reveal intent

Reference: Beck, Tidy First?; Fowler, Refactoring (Ch. 6–12); Kerievsky, Refactoring to Patterns.

Working with Legacy Code (Feathers)

Legacy = code without tests. Goal: make it safe to change.

Get it under test first
  • Characterization tests: document current behavior, even if wrong. "What does it do?" not "What should it do?"
  • Find seams: places behavior can change without editing the existing code — object seams, preprocessing seams, link seams.
  • Break dependencies safely: Extract Interface, Parameterize Constructor, Adapt Parameter.
Add behavior safely
  • Sprout Method / Sprout Class: new logic in a new, tested unit; call it from the legacy caller.
  • Wrap Method / Wrap Class: preserve existing behavior, add new behavior alongside.
  • Strangler pattern: route new paths through clean code; let the old code shrink.
Principles
  • Never rewrite from scratch. Incrementally expand the tested surface.
  • Legacy code is code we don't understand yet. Add understanding through tests before changing it.
  • Each step leaves the code in a working state.

Reference: Feathers, Working Effectively with Legacy Code (Ch. 4 seams, Ch. 8 sprout/wrap, Ch. 25 dependency-breaking).

Output Discipline

  • For each move: name it, show the before/after diff, state the smell it addresses, and confirm tests still pass.
  • Stop when the next change is easy.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/timander/copilot-instructions-starter-kit/refactor/badge)](https://verified-skill.com/skills/timander/copilot-instructions-starter-kit/refactor)

Something wrong with this skill or its page? Tell us.