refactor-workflow

Refactor interface abstractions while preserving observable behavior through test-gated workflows.

2|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/grimlor/universal-dev-skills --skill refactor-workflow-grimlor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-workflow
Source: https://github.com/grimlor/universal-dev-skills/tree/main/skills/refactor-workflow
Command: npx skills add https://github.com/grimlor/universal-dev-skills --skill refactor-workflow-grimlor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Refactor-workflow prevents accidental behavior changes by forcing a structured, test-gated process that preserves observable behavior while restructuring code.

Core Features & Use Cases

  • Caller-first scoping: Enumerates every caller of the target interface to define the real blast radius before any design changes.
  • Behavior-preserving gates: Builds a BDD spec of existing behavior (spec gate) and then adapts tests and production code without extending capability (test gate + implementation gate).
  • Design before modification: Produces a documented adapter map and key architectural decisions so implementation can’t silently invent structure.
  • Use case: Extracting ports/adapters, converting inheritance to protocol-style abstractions, changing interface shapes for callers, or adapting components to new interfaces while guaranteeing the original behavior remains equivalent.

Quick Start

Tell your AI to refactor an existing interface using refactor-workflow by enumerating callers, documenting the current and target interfaces with an adapter map, producing/using a BDD spec gate, adapting tests, and then adapting each caller while ensuring the full existing suite remains green after each caller.

Frequently Asked Questions about refactor-workflow

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor an interface without breaking existing callers?

To refactor an interface without breaking callers, enumerate every caller to define the blast radius, document an adapter map for the new boundary, and adapt each caller while keeping the full existing test suite green. This ensures observable behavior is preserved.

What is the best way to convert inheritance to a protocol while preserving behavior?

Converting inheritance to protocol abstractions safely requires building a BDD spec of the existing behavior first, then adapting tests and production code to the new protocol boundary without extending capability, ensuring the regression suite passes after each caller adaptation.

How does a BDD spec gate protect code during refactoring?

A BDD spec gate protects refactoring by capturing the existing observable behavior before any design changes are made. It serves as a regression safety checkpoint, ensuring the restructured abstractions and adapted callers do not alter the original capability.

Can I use call graph analysis to find the blast radius of an interface change?

Yes, caller-first scoping uses call graph analysis to enumerate every caller of the target interface. This defines the real blast radius before any design modifications, ensuring the adapter map covers all affected components and preventing accidental behavior changes.

When should I use an adapter map during code restructuring?

Use an adapter map during code restructuring when interface shapes change across callers, such as extracting ports and adapters. It documents key architectural decisions and the mapping between current and target interfaces so implementation cannot silently invent structure.

Does refactor-workflow support adding new capabilities during interface adaptation?

No, this refactor-workflow does not support adding new capabilities or handling bug-fix intent. It strictly restructures abstractions and adapts callers to new boundaries while enforcing test gates to guarantee the original observable behavior remains equivalent.