guru-refactor-generalization

Refactor inheritance hierarchies using Pull Up and Push Down techniques.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps software teams systematically refactor inheritance-heavy codebases to reduce duplication, improve hierarchy clarity, and promote safer evolution.

Core Features & Use Cases

  • Pull Up Field
  • Pull Up Method
  • Pull Up Constructor Body
  • Push Down Field
  • Push Down Method
  • Extract Subclass / Superclass / Interface
  • Collapse Hierarchy
  • Form Template Method
  • Replace Inheritance with Delegation
  • Replace Delegation with Inheritance

Quick Start

Apply Pull Up Method to consolidate common behavior across subclasses.

Frequently Asked Questions about guru-refactor-generalization

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

FAQPage Schema
How do I refactor inheritance hierarchies to reduce code duplication?

Consolidate common behavior across subclasses using Pull Up Method and Pull Up Field techniques to refactor inheritance hierarchies and reduce code duplication. Form Template Method standardizes shared algorithmic steps across multiple classes for safer evolution.

What is the best way to remove code smells in deep OOP class hierarchies?

Collapse unnecessary hierarchy levels and push down fields to remove code smells in deep OOP class hierarchies. Replacing inheritance with delegation breaks rigid couplings, ensuring classes expose only relevant behavior to their specific scope.

When should I use Form Template Method during object-oriented refactoring?

Use Form Template Method during object-oriented refactoring when multiple subclasses share similar algorithmic steps with slight variations. It standardizes the algorithm structure in a superclass, allowing subclasses to override specific primitive operations safely.

Can I safely push down methods and fields in an inheritance hierarchy?

Yes, safely push down methods and fields to relevant subclasses to ensure classes expose only behavior they actually use. This narrows class interfaces and is applied incrementally alongside testable changes to maintain hierarchy clarity and reduce coupling.

Why does replacing inheritance with delegation improve code maintainability?

Replacing inheritance with delegation improves code maintainability by breaking rigid class hierarchies and reducing unexpected coupling. It shifts behavior sharing to composition, allowing safer interface evolution and testable incremental changes during refactoring.