safe-refactoring

Official

Refactor code confidently, prevent regressions.

AuthorLorenFrankLab
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Refactoring code is essential for maintainability but often introduces unintended bugs or changes in behavior, leading to costly regressions. This Skill provides a strict, zero-tolerance process to ensure that structural code changes never alter functionality, allowing you to improve code quality with complete confidence.

Core Features & Use Cases

  • Behavioral Baseline: Establish a comprehensive baseline of test results, snapshot outputs, and code coverage before any changes.
  • Zero-Tolerance Verification: Rigorously compare post-refactoring results against the baseline, immediately flagging any deviation.
  • Quality Checks: Integrate linting and formatting to ensure refactoring also improves code quality standards.
  • Numerical Equivalence: For mathematical code, verify that refactoring introduces no numerical differences beyond floating-point noise.
  • Use Case: You need to reorganize a large, monolithic Python module into smaller, more focused files to improve readability and maintainability. Use this Skill to perform the refactoring, guaranteeing that all existing functionality remains perfectly intact and no new bugs are introduced.

Quick Start

Follow the safe refactoring checklist:

1. Run full test suite (establish baseline)

2. Run snapshot tests (establish baseline)

3. Capture coverage report

4. Perform refactoring (small, incremental changes)

5. Run full test suite (must match baseline exactly)

6. Run snapshot tests (must match baseline exactly)

7. Compare coverage (should stay same or improve)

8. Run quality checks (ruff + black)

9. Verify no numerical differences (for mathematical code)

10. Commit refactoring

Dependency Matrix

Required Modules

pytestruffblack

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: safe-refactoring
Download link: https://github.com/LorenFrankLab/non_local_detector/archive/main.zip#safe-refactoring

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.