safe-refactoring

Plan and execute isolated refactorings that preserve external behavior.

Updated Dec 28, 2025
One-click install
npx skills add https://github.com/I2olanD/dotfiles --skill safe-refactoring-i2oland
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safe-refactoring
Source: https://github.com/I2olanD/dotfiles/tree/main/.config/opencode/skill/safe-refactoring
Command: npx skills add https://github.com/I2olanD/dotfiles --skill safe-refactoring-i2oland

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables safe, behavior-preserving code refactoring across projects, reducing risk and ensuring external functionality remains unchanged.

Core Features & Use Cases

  • Identify code smells and opportunities for improvement using a structured catalog.
  • Plan refactoring sequences with clear risk assessment and dependency awareness.
  • Execute isolated, smallest-change refactorings, validating each step against the baseline test suite.

Quick Start

Activate this skill when you need to safely restructure code. Steps:

  1. Establish a baseline by running the full test suite and documenting current behavior.
  2. Inspect the codebase for smells using the refactoring catalog in reference.md.
  3. Create an execution plan that applies one change at a time and re-runs tests after each change.

Frequently Asked Questions about safe-refactoring

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

FAQPage Schema
How do I safely refactor code without breaking existing behavior?

Safe refactoring requires a baseline test suite to verify behavior. You identify code smells, plan isolated single changes, and re-run tests after each modification to ensure external functionality remains unchanged.

What's the best way to plan a refactoring sequence for a critical module?

Plan refactoring sequences by defining a clear scope and assessing dependencies before execution. Apply plan-driven, isolated changes one at a time to critical modules, validating each step against the baseline test suite.

Do I need a test suite before starting a code refactoring?

A baseline test suite is required before refactoring. You must run the full test suite and document current behavior initially to validate that each isolated code change preserves external functionality.

How do I identify code smells during a refactoring project?

Identify code smells using a structured refactoring catalog. Inspect the codebase against this reference to find opportunities for improvement, ensuring behavior-preserving changes are made systematically.

Why should I apply one change at a time when restructuring code?

Applying one change at a time during refactoring ensures isolated, smallest-change execution. This disciplined approach allows you to verify post-change behavior against the baseline immediately, reducing risk.

When should I not use plan-driven refactoring for code quality improvements?

Avoid plan-driven refactoring when lacking a baseline test suite to verify behavior. Without tests to validate each isolated change, executing structural modifications risks breaking external functionality.