refactoring

Refactor codebases across languages using a five-phase measure-transform-verify workflow.

Updated Mar 20, 2026
One-click install
npx skills add https://github.com/dljsjr/sandpiper-ai --skill refactoring-dljsjr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/dljsjr/sandpiper-ai/tree/main/skills/sandpiper/refactoring
Command: npx skills add https://github.com/dljsjr/sandpiper-ai --skill refactoring-dljsjr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides a structured, language-agnostic workflow to improve code health through measured refactoring. It enables systematic measurement, target identification, safe transformations, and verification to reduce complexity and duplication without altering external behavior.

Core Features & Use Cases

  • Five-phase workflow: measure, identify targets, transform, measure again, and verify changes.
  • Language-agnostic guidance with language-specific references to support TypeScript, Python, Go, Java, C++, and more.
  • Targeted refactoring patterns: extraction, consolidation, simplification, and modularization with guardrails and testing.
  • Operational guidance for production workflows: risk assessment, rollback considerations, and compatibility checks across modules.

Quick Start

Begin a refactor by establishing a baseline, then follow the five-phase workflow to safely improve structure without changing behavior.

Frequently Asked Questions about refactoring

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

FAQPage Schema
How do I safely refactor code to reduce complexity without changing behavior?

Safe refactoring requires a structured workflow: measure a baseline, identify target areas, transform the code, measure again, and verify external behavior remains stable. This approach reduces complexity and duplication while maintaining functionality.

What is the best way to measure code health before refactoring?

Measuring code health involves applying static analysis to establish a baseline for complexity and duplication. Identifying targets through these metrics guides safe transformations and ensures maintainability improvements are tracked and verified.

Does this refactoring workflow support multiple programming languages?

Yes, the refactoring guidance is language-agnostic but includes language-specific references for TypeScript, Python, Go, Java, and C++. This ensures safe transformations and verification are applied correctly across different codebases.

How do I identify refactoring targets in a large codebase?

Identifying refactoring targets involves measuring code complexity and duplication to pinpoint high-risk areas. Focusing on these measured metrics guides extraction, consolidation, and simplification patterns for effective debt reduction.

What guardrails exist for production refactoring workflows?

Production refactoring workflows enforce guardrails through risk assessment, rollback considerations, and compatibility checks. The five-phase workflow ensures safe transformations by verifying behavior and measuring complexity before and after changes.

When should I not attempt a large-scale codebase refactor?

Large-scale refactoring should be avoided without a measured baseline and verification steps. If static analysis cannot establish complexity metrics or behavior stability cannot be guaranteed, the risk of altering external behavior is too high.