refactor

Restructures code while preserving behavior through Git state verification, tests, and type checking.

15|3|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/richardcb/oh-my-gemini --skill refactor-richardcb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor
Source: https://github.com/richardcb/oh-my-gemini/tree/main/skills/refactor
Command: npx skills add https://github.com/richardcb/oh-my-gemini --skill refactor-richardcb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of improving code quality, readability, and maintainability by restructuring existing codebases without altering their functional behavior, ensuring safety through rigorous verification.

Core Features & Use Cases

  • Deterministic Refactoring: Ensures code changes are safe and verifiable.
  • Safety Protocols: Implements a strict checklist including Git state verification, passing tests before and after, and type checking.
  • Use Case: When a codebase becomes difficult to understand or modify due to technical debt, this Skill can systematically reorganize it, making it more manageable and less prone to bugs.

Quick Start

Use the refactor skill to reorganize the utils/ directory to improve modularity.

Frequently Asked Questions about refactor

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

FAQPage Schema
How do I safely restructure code to improve maintainability without breaking existing behavior?

To safely restructure code and improve maintainability, you need a refactoring process that preserves existing behavior through strict safety protocols. This involves verifying Git state, executing tests before and after changes, and running type checking to ensure functional consistency.

What is the best way to consolidate duplicate code and clean up technical debt?

The best way to consolidate duplicate code and clean up technical debt is through deterministic refactoring. This approach systematically reorganizes unmanageable codebases into modular structures, making them easier to understand and modify while enforcing verifiable safety checks.

How do I verify my codebase is safe before starting a major restructuring?

To verify your codebase is safe before restructuring, run a strict pre-refactoring checklist. You must confirm a clean Git state and ensure all existing tests pass, establishing a reliable baseline before applying any structural improvements.

Does code refactoring require type checking and test execution after changes are applied?

Yes, safe code refactoring requires type checking and test execution after changes are applied. Running post-refactoring tests and type validation ensures that the structural improvements did not alter the original functional behavior of the codebase.

Why does my code become difficult to modify and when do I need structural improvements?

Your code becomes difficult to modify due to accumulated technical debt, requiring structural improvements when readability and maintainability decline. Systematic refactoring reorganizes these complex codebases to make them more manageable and less prone to bugs.