oma-refactor

Plans and executes behavior-preserving code refactoring with characterization tests and metric gates.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/javiruu/viru-air --skill oma-refactor-javiruu
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: oma-refactor
Source: https://github.com/javiruu/viru-air/tree/main/.agents/skills/oma-refactor
Command: npx skills add https://github.com/javiruu/viru-air --skill oma-refactor-javiruu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Restructuring legacy or messy code without breaking behavior is risky and hard to prioritize. This Skill provides a disciplined workflow for safe, incremental refactoring: it diagnoses test safety nets, ranks targets by hotspot analysis (complexity x churn), applies atomic transformations, and verifies behavior preservation at every step. ## Core Features & Use Cases - Safety-net diagnosis and construction: Classifies code as greenfield or brownfield, and writes characterization (golden-master) tests before touching untested production code. - Hotspot-driven target selection: Combines static complexity metrics (radon, lizard) with git forensics (churn, bug history, SATD markers) to rank what to refactor first. - Atomic verified transformations: Applies one named refactoring per commit, re-runs frozen tests after each step, and uses the Mikado method to revert and recurse when prerequisites break. - Use Case: You inherit a legacy Python module with 800-line files and no tests. The Skill finds a seam, writes golden-master tests pinning current behavior, then executes a sequence of extract-method refactorings, each committed separately with before/after complexity metrics. ## Quick Start Ask the agent to refactor the long methods in a target module while preserving behavior, building characterization tests first if coverage is missing.

Frequently Asked Questions about oma-refactor

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

FAQPage Schema
How do I refactor legacy code that has no tests?▼

Build a safety net first: find a seam where you can inject test access with minimal mechanical changes, then write characterization (golden-master) tests that pin current behavior, bugs included. Only after those tests pass should you begin restructuring.

How to prioritize which code to refactor first?▼

Rank targets by hotspot score: static complexity (cyclomatic or cognitive complexity from radon or lizard) multiplied by change frequency from git history. Add SATD markers like TODO and FIXME as a third independent signal, and skip cold low-churn code.

What is the difference between refactoring and fixing a bug?▼

Refactoring never changes observable behavior; it only improves internal structure. If you discover a bug mid-refactoring, record it and handle it in a separate behavior-change commit, never mixed into a refactor commit.

Can refactoring be done safely on database schemas or public APIs?▼

Yes, but git revert cannot restore persisted state, so use the expand-contract pattern: add the new structure alongside the old, dual-write and backfill, switch reads behind feature flags, then remove the old structure in a later deployment.

Why do refactoring metrics improve while readability gets worse?▼

Metrics are proxies subject to Goodhart's law: mechanical splits can hit line-count gates while creating tightly coupled halves. Readability is the actual success criterion, so reject transformations where metrics improve but comprehension worsens.

When should I not refactor code?▼

Skip code about to be deleted, cold stable low-churn code, anything right before a release, and code without a verification path. Also stop and route to an architecture decision when the real fix is a convention or boundary change rather than a local transformation.