Agent skill

Oma Refactor

by first-fluke in first-fluke/oh-my-agent

Restructure existing code while preserving observable behavior.

MITAuto-check passedDevelopment

Install Oma Refactor

skills CLI
$ npx skills add first-fluke/oh-my-agent --skill oma-refactor -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install first-fluke/oh-my-agent oma-refactor --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/first-fluke/oh-my-agent.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/oma-refactor .claude/skills/oma-refactor && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
oma-refactor
GitHub stars
1.3k
Token cost
~3.2k tokens
SKILL.md length
1,499 words
Files
5
Skills in repo
57
Repo updated
First seen
Licence
MIT

At a glance

Restructure existing code while preserving observable behavior.

  • Works in 3 steps: Establish what motivates the refactoring… → Diagnose the safety net for that scope:… → Identify the destination form: the…
  • Targeted technical debt
  • SKILL.md covers Scheduling, Structural Flow, Logical Operations and References
  • Runs Python scripts from its folder

What it does

Oma Refactor is an agent skill from first-fluke/oh-my-agent. Restructure existing code while preserving observable behavior. Use for targeted technical debt or hotspot work with characterization tests.

Its SKILL.md is about 3.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files (for example `resources/definition.md`, `resources/governance.md` and `resources/hotspots.py`).

It sits in Development, covering Refactoring and Technical debt. The repository describes itself as: Mechanical verification for AI coding agents — skills pack or full harness (stop-hook gates, artifact checks, independent judges). The licence is MIT.

When your agent uses it

  • Targeted technical debt
  • Hotspot work with characterization tests

Example prompts

  • “/oma-refactor”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Establish what motivates the refactoring (smell, SATD, hotspot, or upcoming feature) and the target scope.
  2. Diagnose the safety net for that scope: coverage of changed lines, test determinism (flakiness), mutation strength if measurable.
  3. Identify the destination form: the language idiom and codebase convention the result must match.

What it can do on your machine

Read from SKILL.md and the folder at commit f65bbc0. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (Python), which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Oma Refactor loads about 3.2k tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 1,499 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~3.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from first-fluke/oh-my-agent at commit f65bbc0, republished under its MIT licence (© first-fluke). 1,499 words, ~3,219 tokens.

Download SKILL.mdSave it as .claude/skills/oma-refactor/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
oma-refactor
description
Restructure existing code while preserving observable behavior. Use for targeted technical debt or hotspot work with characterization tests.

Refactor Agent - Behavior-Preserving Restructuring Specialist

Scheduling

Goal

Improve internal code structure - readability first - without changing observable behavior, through small verified transformations, each gated by a safety net (tests / tooling / types) and committed separately from any behavior change.

Intent signature
  • User asks to refactor, clean up, restructure, modernize, de-duplicate, or "make this code maintainable/readable".
  • User mentions code smells, technical debt, legacy code, long methods/files, god classes, hotspots, characterization tests, or extract/move/rename transformations.
  • User asks "where should we refactor first?" or wants a refactoring plan/priority for a codebase.
When to use
  • Executing a refactoring on specific files/modules (extract, move, rename, decompose, pattern/idiom alignment)
  • Preparatory refactoring before a feature ("make the change easy, then make the easy change")
  • Legacy (brownfield) rescue: seam discovery + characterization tests, then restructuring
  • Refactoring target selection and prioritization (smells + SATD + hotspot = churn x complexity)
  • Auditing whether code is safe to refactor now (coverage breadth x mutation strength x flakiness)
When NOT to use
  • Fixing a reported bug or failing behavior -> use oma-debug (refactoring must not change behavior)
  • Security/performance/accessibility review or quality audit -> use oma-qa
  • System design, module boundary decisions, ADRs, convention changes -> use oma-architecture (a convention/pattern change is an architecture decision, not a local refactoring)
  • DB schema design or migration mechanics -> use oma-db (this skill only plans the expand-contract sequence)
  • Commit splitting / staging mechanics -> use oma-scm
  • Performance optimization as a goal -> out of scope by definition (tuning is a side effect, never the objective)
Expected inputs
  • target: file/module/path, smell report, SATD marker, or the feature request motivating preparatory refactoring
  • verification: existing project test command(s); coverage/mutation tooling if already available
  • constraints: coding guide / conventions, regulated-environment flags, merge-window concerns
  • Optional: prior metric reports, hotspot data, ADRs touching the target area
Expected outputs
  • Refactored code as a sequence of atomic, refactor-only commits (no test changes mixed in)
  • Safety-net additions when missing (characterization / golden-master tests) as separate commits
  • Before/after report: metric delta (cyclomatic/cognitive complexity, size, coupling) + readability verdict
yaml
outputs:
  - name: report
    description: refactoring plan or before/after report
    artifact: ".agents/results/refactor/*.md"
    required: false

Standalone runs write plan / before-after reports under .agents/results/refactor/; orchestrated runs (via the refactor-engineer agent) write .agents/results/result-refactor[-{sessionId}].md per the agent execution protocol.

Dependencies
  • resources/definition.md (invariant definition: 5 properties, boundaries, destination principle, naming roles, inline evidence)
  • resources/measurement.md (4-layer measurement + git forensics commands)
  • resources/governance.md (optional organization conventions and existing verification tools)
  • Configured code-intelligence symbol/reference tools; existing project test runners for the target language
  • Git history for churn/ownership/hotspot analysis
Control-flow features
  • Branches by safety-net state (greenfield vs brownfield), statefulness (code-only vs expand-contract), and verification outcome (pass vs Mikado revert)
  • Reads code/history/metrics; writes code, tests (in separate commits), and reports
  • Stops and routes to oma-architecture when the change requires a convention/boundary decision

Structural Flow

Entry
  1. Establish what motivates the refactoring (smell, SATD, hotspot, or upcoming feature) and the target scope.
  2. Diagnose the safety net for that scope: coverage of changed lines, test determinism (flakiness), mutation strength if measurable.
  3. Identify the destination form: the language idiom and codebase convention the result must match.
Scenes
  1. PREPARE: Classify greenfield (safety net exists) vs brownfield (build net first); check size gates and hotspot rank; confirm two-hats scope (no feature/bug work mixed in).
  2. ACQUIRE: Read target code via symbol tools; collect metrics (complexity, size, coupling) and git signals (churn, ownership); read the coding guide for conventions.
  3. REASON: Decompose the goal into a sequence of named atomic transformations; for stateful targets plan expand-contract; verify each step is independently verifiable and revertible.
  4. ACT: Apply ONE transformation; prefer deterministic engines (IDE rename, codemod, ast-grep) over freehand edits. When one feature spans several files after a split, consider G-5's optional header map if it helps navigation.
  5. VERIFY: Re-run existing tests unchanged. Pass -> commit (refactor-only) -> next transformation. Repeated failure -> Mikado: record the broken prerequisite, undo only this transformation's edits, recurse on the prerequisite first. Preserve pre-existing edits and other contributors' work.
  6. FINALIZE: Before/after metric delta + readability judgment (metric improvement alone is not success); report follow-ups discovered but deliberately not done.
Transitions
  • If the safety net is missing or weak (low diff coverage, flaky, no assertions), write characterization / golden-master tests FIRST, committed separately, before touching production code.
  • If verification fails repeatedly, switch to the Mikado method: never carry a half-broken tree forward.
  • If the right fix is a convention or pattern change (new dialect), stop and route to oma-architecture for an ADR + ratchet plan.
  • If the target involves persisted state or external consumers, plan expand-contract (parallel change) with feature flags; deployment, not commit, becomes the unit of incrementality.
  • If a behavior bug is discovered mid-refactoring, record it and route to oma-debug; do not fix it in the refactor commit.
  • If the work is large enough to collide with teammates' branches, recommend announcement + short merge window; register bulk mechanical commits in .git-blame-ignore-revs.
Failure and recovery
FailureRecovery
Tests fail after a transformationMikado: record prerequisite, undo only this transformation's edits, preserve unrelated work, attack prerequisite first
No tests and code is untestableFind a seam; apply only minimal mechanical changes to inject test access, then characterize
Tests are flakyFix or quarantine flaky tests before refactoring - an unreliable net is no net
Metric improves but readability worsensReject the transformation; readability is the success criterion, metrics are proxies
Scope keeps growingStop; report the boundary issue and split into a Mikado graph or route to architecture
Refactoring engine/codemod produces wrong outputEngines are not infallible - tests re-run is mandatory; fall back to manual atomic edits
Show full SKILL.md (617 more words)Show less
Exit
  • Success: behavior verified unchanged, structure measurably improved, readability confirmed, refactor-only commits, follow-ups reported.
  • Partial success: safety net built but restructuring deferred; or prerequisites mapped (Mikado graph) with explicit blockers.
  • Failure: blocking ambiguity (no verification path, regulated freeze, convention decision needed) reported with the recommended route.

Logical Operations

Actions
ActionSSL primitiveEvidence
Diagnose safety netVALIDATECoverage/flakiness/mutation state of target scope
Collect signalsREADMetrics, git churn/ownership, smells, SATD
Rank targetsCOMPAREHotspot = complexity x churn
Plan atomic sequenceINFERNamed transformations, Mikado graph
Write characterization testsWRITEGolden-master/snapshot tests (separate commit)
Apply transformationWRITE / CALL_TOOLOne atomic refactor, engine-first
Verify preservationVALIDATEExisting tests re-run unchanged
Commit separatelyUPDATE_STATErefactor:-typed commits only
Report deltaNOTIFYMetric + readability before/after
Tools and instruments
  • Configured code intelligence for symbol/reference/pattern impact analysis; an available semantic rename engine for renames. Native inspection remains valid, but do not replace a semantic rename with blind text replacement
  • Deterministic transformers: IDE refactoring actions, codemods (jscodeshift / OpenRewrite / ast-grep / comby)
  • Metrics: use already installed complexity tools such as lizard / radon and existing project lint limits; installing or downloading additional tools requires authorization
  • Test stack: preserve the project runner and configuration; use mutation tooling only when available and appropriate (see resources/governance.md)
  • Git forensics one-liners (see resources/measurement.md)
Canonical workflow path
  1. Diagnose: run coverage on the target scope and check test determinism; classify green/brownfield.
  2. If brownfield: find a seam, write characterization (golden-master) tests for CURRENT behavior, commit.
  3. Select targets by hotspot rank (complexity x churn), not by smell aesthetics alone.
  4. Plan a sequence of named atomic transformations toward the language-idiomatic, convention-conforming form.
  5. Loop per transformation: apply (engine-first) -> re-run tests UNCHANGED -> commit refactor: only. On repeated failure: record prerequisite, undo only this transformation's edits, preserve pre-existing and concurrent work, recurse (Mikado).
  6. Finish: metric delta + readability verdict; list discovered-but-deferred work; never mix in behavior changes.
Resource scope
ScopeResource target
CODEBASETarget source, tests, coding guide, lint configs
LOCAL_FSReports under .agents/results/refactor/, .git-blame-ignore-revs
PROCESSTest runners, coverage/mutation tools, codemod engines, git log analysis
MEMORYMikado prerequisite graph, deferred follow-ups, metric baselines
Preconditions
  • A verification path exists or can be built (tests/types/tooling); otherwise the first deliverable is the safety net, not restructuring.
  • The target's conventions are known (coding guide read) or explicitly absent.
Effects and side effects
  • Mutates production code (structure only) and adds tests in separate commits.
  • Runs test/coverage/mutation commands; reads git history.
  • May write reports under .agents/results/refactor/ and entries to .git-blame-ignore-revs.
  • Never alters observable behavior, public contracts, or persisted data without an expand-contract plan.
Guardrails
  1. Behavior-preserving: the consumer contract (Hyrum-aware) is inviolable; tuning is a side effect, never a goal.
  2. Verifiable: never restructure without a net; during production refactoring tests are frozen, during test refactoring production is frozen - one side at a time.
  3. Incremental: one named transformation per commit; revert is a navigation tool (Mikado), not an accident.
  4. Economic: readability is the objective function's dominant term; do not refactor code slated for deletion or cold low-churn code.
  5. Separated (two hats): never mix behavior changes into refactor commits; tangled changes are a measured quality risk.
  6. Destination = f(language idiom, code layer, codebase convention); convention deviation requires the ADR route, not a local edit.
  7. Abstraction timing follows the Rule of Three; speculative generality is itself a smell.
  8. All metrics are proxies (Goodhart): a 499-line mechanical split, assertion-free coverage, or pattern-count gains are failures, not wins.

References

  • Local code tools: ../_shared/core/code-intelligence.md (code search/navigation)

  • Invariant definition (5 properties, boundaries, destination, naming roles, contexts, D&C, inline evidence): resources/definition.md

  • Measurement: 4 layers + git forensics commands: resources/measurement.md

  • Optional organization conventions and existing verification tools: resources/governance.md

  • Context loading: ../_shared/core/context-loading.md

  • Quality principles: ../_shared/core/quality-principles.md

  • Adjacent skills: oma-debug (bugs), oma-qa (audits), oma-architecture (boundaries/ADR), oma-db (schema), oma-scm (commits)

© first-fluke, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files in skills/oma-refactor of first-fluke/oh-my-agent.

  • SKILL.md
  • resources/definition.md
  • resources/governance.md
  • resources/hotspots.py
  • resources/measurement.md

Open the folder on GitHubat commit f65bbc0

Used in 1 other repository

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders. This page covers the copy in first-fluke/oh-my-agent, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Oma Refactor next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Oma Refactor compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Oma Refactor this skillfirst-fluke/oh-my-agent1.3k—~3.2kAutomated safety check: PassMIT
Systematic Code Refactoringluongnv89/claude-howto42k—~3kAutomated safety check: PassMIT
Code Simplification for ego-litecitrolabs/ego-lite17k—~1.2kAutomated safety check: PassMIT
Code Refactoring Workflowluongnv89/claude-howto42k—~3.1kAutomated safety check: PassMIT
Tech Debt Analyzerailabs-393/ai-labs-claude-skills4542 repos~3.9kAutomated safety check: PassMIT
FIXME Resolvertailcallhq/forgecode7.6k—~1.1kAutomated safety check: PassApache-2.0

Similar skills

  • Systematic Code Refactoring

    luongnv89/claude-howto

    Guides refactoring in phases based on Martin Fowler's method: research, test coverage check, planning and small tested steps, with your approval at each phase.

    42k GitHub stars~3k tokensUpdated 8 days ago
    DevelopmentAuto-check passed
  • Finds and implements evidence-backed simplifications in the ego-lite repository, such as dead code, duplicated state and speculative abstractions, without hiding behavior changes.

    17k GitHub stars~1.2k tokensUpdated 15 days ago
    DevelopmentAuto-check passed
  • Code Refactoring Workflow

    luongnv89/claude-howto

    Guides systematic, test-backed refactoring in the style of Martin Fowler, moving through research, planning and small incremental changes with your approval at each phase.

    42k GitHub stars~3.1k tokensUpdated 8 days ago
    DevelopmentAuto-check passed
  • Tech Debt Analyzer

    ailabs-393/ai-labs-claude-skills

    This skill should be used when analyzing technical debt in a codebase, documenting code quality issues, creating technical debt registers, or assessing code maintainability.

    454 GitHub starsUsed in 2 repos~3.9k tokens
    DevelopmentAuto-check passed
  • FIXME Resolver

    tailcallhq/forgecode

    Finds every FIXME comment in a codebase, groups related ones across files into one task, implements the work they describe and removes the comments once it is done.

    7.6k GitHub stars~1.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Desloppify

    Git-on-my-level/codex-autorunner

    Codebase health scanner and technical debt tracker. An agent skill from Git-on-my-level/codex-autorunner.

    875 GitHub stars~3.4k tokensUpdated today
    DevelopmentAuto-check passed

More from first-fluke/oh-my-agent

All 57 skills in this repo
  • OMA Multi-Agent Orchestration

    first-fluke/oh-my-agent

    Decomposes a complex feature into tasks, dispatches parallel specialist agents with durable state, and supervises verification, QA review and retries.

    1.3k GitHub stars~4.1k tokensUpdated today
    Auto-check passed
  • Oma Video

    first-fluke/oh-my-agent

    Create short, explainer, or recorded-demo videos through the OMA video CLI.

    1.3k GitHub starsUsed in 1 repo~1.7k tokens
    Auto-check passed
  • OMA Multi-Agent Orchestrator

    first-fluke/oh-my-agent

    Splits a complex feature into prioritized tasks, spawns specialist CLI subagents in parallel, tracks them through shared memory and verifies each result.

    1.3k GitHub stars~3.1k tokensUpdated today
    Auto-check passed
  • Architecture Decisions and ADRs

    first-fluke/oh-my-agent

    Evaluates system boundaries and tradeoffs and writes architecture recommendations, option comparisons or ADRs, with a Mermaid diagram when structure changes.

    1.3k GitHub stars~2.6k tokensUpdated today
    Auto-check passed
  • OMA Backend Agent

    first-fluke/oh-my-agent

    Backend specialist for APIs, database work, authentication and migrations that follows clean architecture with router, service and repository layers.

    1.3k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • oma Bootstrap

    first-fluke/oh-my-agent

    Installs or checks the oma CLI and its runtimes (bun, uv, serena) in a fresh workspace so that oma-* skills can run their commands.

    1.3k GitHub stars~719 tokensUpdated today
    Auto-check passed

Categories

Questions about Oma Refactor

What does Oma Refactor do?

Restructure existing code while preserving observable behavior. Oma Refactor is an agent skill from first-fluke/oh-my-agent. Restructure existing code while preserving observable behavior.

When should I use Oma Refactor?

Oma Refactor fits situations like: targeted technical debt; hotspot work with characterization tests.

How do I install Oma Refactor in Claude Code?

Run `npx skills add first-fluke/oh-my-agent --skill oma-refactor -a claude-code`. Or copy the skill folder (skills/oma-refactor in first-fluke/oh-my-agent) into .claude/skills/oma-refactor in your project. Claude Code loads it when a task matches its description.

How do I install Oma Refactor in Codex?

Run `npx skills add first-fluke/oh-my-agent --skill oma-refactor -a codex`. Or copy the skill folder (skills/oma-refactor in first-fluke/oh-my-agent) into .agents/skills/oma-refactor in your project. Codex loads it when a task matches its description.

Can I use Oma Refactor in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add first-fluke/oh-my-agent --skill oma-refactor -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/oma-refactor, .gemini/skills/oma-refactor, .github/skills/oma-refactor and .opencode/skills/oma-refactor in your project.

What does Oma Refactor need to run?

Going by SKILL.md and its folder, Oma Refactor needs Python for the scripts in its folder. Our summary lists: Python 3.

Does Oma Refactor access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Oma Refactor safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Oma Refactor use?

Oma Refactor is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Oma Refactor use?

About 3.2k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Oma Refactor?

Skills that share tags, products or a category with Oma Refactor: Systematic Code Refactoring (luongnv89/claude-howto, 42k stars), Code Simplification for ego-lite (citrolabs/ego-lite, 17k stars), Code Refactoring Workflow (luongnv89/claude-howto, 42k stars) and Tech Debt Analyzer (ailabs-393/ai-labs-claude-skills, 454 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Oma Refactor?

first-fluke (a GitHub organization) maintains it in first-fluke/oh-my-agent, which has 1,338 GitHub stars. The repository holds 57 skills in this directory. The repository was last updated on October 8, 2026.

Source: first-fluke/oh-my-agent on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.