guru-refactor-data

Identify and synthesize RefactoringGuru data refactoring techniques with concrete transformations and examples.

1|Updated Dec 22, 2025
One-click install
npx skills add https://github.com/CybLow/pypaginate --skill guru-refactor-data
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: guru-refactor-data
Source: https://github.com/CybLow/pypaginate/tree/main/.opencode/skills/guru-refactor-data
Command: npx skills add https://github.com/CybLow/pypaginate --skill guru-refactor-data

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Data organization problems, code smells, and repetitive data-handling patterns are transformed into structured, maintainable patterns using RefactoringGuru techniques.

Core Features & Use Cases

  • Replace Magic Number with Constant: convert unexplained literals to named constants for clarity and maintainability.
  • Encapsulate Collection: protect internal collections by returning copies or read-only views and provide mutator methods.
  • Replace Type Code with Class / with State/Strategy: replace primitive codes with proper types or strategy/state objects to enable behavior polymorphism.
  • Self Encapsulate Field / Encapsulate Field: enforce validation and invariants by routing field access through getters/setters.
  • Replace Data Value with Object / Replace Array with Object: wrap primitive or grouped data into rich objects with behavior.
  • Change Value to Reference / Change Reference to Value: switch between value and reference semantics to control identity and sharing.
  • Replace Subclass with Fields: simplify class hierarchies by using data fields instead of subclass variations.

Quick Start

Apply the Replace Magic Number with Constant technique to replace hard-coded literals with named constants in a sample module.

Frequently Asked Questions about guru-refactor-data

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

FAQPage Schema
How do I refactor magic numbers and type codes in my codebase?

To refactor magic numbers and type codes, apply techniques like Replace Magic Number with Constant and Replace Type Code with Class to transform unexplained literals and primitive codes into named constants and proper types for maintainability.

What is the best way to encapsulate collections and fields in object-oriented design?

The best way to encapsulate collections and fields is to route access through getters and setters, returning collection copies or read-only views, enforcing validation and invariants to protect internal data.

When should I replace primitive data values with objects?

You should replace primitive data values with objects when you need to wrap grouped data into rich objects with behavior, enabling better data organization and replacing repetitive data-handling patterns with structured code.

How do I switch between value and reference semantics for data organization?

To switch between value and reference semantics, apply the Change Value to Reference or Change Reference to Value refactoring techniques, allowing you to control object identity and data sharing across your codebase.

Can I simplify class hierarchies that use subclasses for data variations?

Yes, you can simplify class hierarchies by applying the Replace Subclass with Fields refactoring technique, which removes subclass variations by using data fields directly to reduce structural complexity.