Mmcp.market

refactor skill

by code-yeongyu·code-yeongyu/oh-my-openagent·70k stars

Guides a refactor, cleanup, or restructure with the right decomposition. Use when the user asks to refactor, simplify, extract, or modernize code.

A100/100content scan

Is the refactor skill safe?

Clean: nothing in its files matched our rules. We read 1 file in the folder on 2026-09-28.

No findings.

Install the refactor skill

A skill is a folder. Copy it into your agent's skills folder and the agent loads it when the task matches its description.

git clone --depth 1 https://github.com/code-yeongyu/oh-my-openagent.git /tmp/oh-my-openagent
mkdir -p ~/.claude/skills
cp -r /tmp/oh-my-openagent/packages/shared-skills/skills/refactor ~/.claude/skills/refactor
available in every project

In the Claude apps, zip the folder and upload it from the Skills settings. The folder on GitHub

The instructions your agent would load

SKILL.md as published, without the frontmatter. Read it on GitHub

export const REFACTOR_TEMPLATE = # Intelligent Refactor Command

Usage

\\\ /refactor [--scope=] [--strategy=]

Arguments: refactoring-target: What to refactor. Can be:

  • File path: src/auth/handler.ts
  • Symbol name: "AuthService class"
  • Pattern: "all functions using deprecated API"
  • Description: "extract validation logic into separate module"

Options: --scope: Refactoring scope (default: module)

  • file: Single file only
  • module: Module/directory scope
  • project: Entire codebase

--strategy: Risk tolerance (default: safe)

\\\

  • safe: Conservative, maximum test coverage required
  • aggressive: Allow broader changes with adequate coverage

What This Command Does

Performs intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:

  1. Understands your intent - Analyzes what you actually want to achieve
  2. Maps the codebase - Builds a definitive codemap before touching anything
  3. Assesses risk - Evaluates test coverage and determines verification strategy
  4. Plans meticulously - Creates a detailed plan with Plan agent
  5. Executes precisely - Step-by-step refactoring with LSP and AST-grep
  6. Verifies constantly - Runs tests after each change to ensure zero regression

PHASE 0: INTENT GATE (MANDATORY FIRST STEP)

BEFORE ANY ACTION, classify and validate the request.

Step 0.1: Parse Request Type

Step 0.2: Validate Understanding

Before proceeding, confirm:

  • [ ] Target is clearly identified
  • [ ] Desired outcome is understood
  • [ ] Scope is defined (file/module/project)
  • [ ] Success criteria can be articulated

If ANY of above is unclear, ASK CLARIFYING QUESTION:

\\\ I want to make sure I understand the refactoring goal correctly.

What I understood: [interpretation] What I'm unsure about: [specific ambiguity]

Options I see:

  1. [Option A] - [implications]
  2. [Option B] - [implications]

My recommendation: [suggestion with reasoning]

Should I proceed with [recommendation], or would you prefer differently? \\\

Step 0.3: Create Initial Todos

IMMEDIATELY after understanding the request, create todos:

\\\ TodoWrite([ {"id": "phase-1", "content": "PHASE 1: Codebase Analysis - launch parallel explore agents", "status": "pending", "priority": "high"}, {"id": "phase-2", "content": "PHASE 2: Build Codemap - map dependencies and impact zones", "status": "pending", "priority": "high"}, {"id": "phase-3", "content": "PHASE 3: Test Assessment - analyze test coverage and verification strategy", "status": "pending", "priority": "high"}, {"id": "phase-4", "content": "PHASE 4: Plan Generation - invoke Plan agent for detailed refactoring plan", "status": "pending", "priority": "high"}, {"id": "phase-5", "content": "PHASE 5: Execute Refactoring - step-by-step with continuous verification", "status": "pending", "priority": "high"}, {"id": "phase-6", "content": "PHASE 6: Final Verification - full test suite and regression check", "status": "pending", "priority": "high"} ]) \\\

PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)

Mark phase-1 as inprogress.**

1.1: Launch Parallel Explore Agents (BACKGROUND)

Fire ALL of these simultaneously using \callomoagent\:

\\\ // Agent 1: Find the refactoring target callomoagent( subagenttype="explore", runin_background=true, prompt="Find all occurrences and definitions of [TARGET]. Report: file paths, line numbers, usage patterns." )

// Agent 2: Find related code callomoagent( subagenttype="explore", runin_background=true, prompt="Find all code that imports, uses, or depends on [TARGET]. Report: dependency chains, import graphs." )

// Agent 3: Find similar patterns callomoagent( subagenttype="explore", runin_background=true, prompt="Find similar code patterns to [TARGET] in the codebase. Report: analogous implementations, established conventions." )

// Agent 4: Find tests callomoagent( subagenttype="explore", runin_background=true, prompt="Find all test files related to [TARGET]. Report: test file paths, test case names, coverage indicators." )

// Agent 5: Architecture context callomoagent( subagenttype="explore", runin_background=true, prompt="Find architectural patterns and module organization around [TARGET]. Report: module boundaries, layer structure, design patterns in use." ) \\\

1.2: Direct Tool Exploration (WHILE AGENTS RUN)

While background agents are running, use direct tools:

LSP Tools for Precise Analysis:

\\\typescript // Find definition(s) LspGotoDefinition(filePath, line, character) // Where is it defined?

// Find ALL usages across workspace LspFindReferences(filePath, line, character, includeDeclaration=true)

// Get file structure LspDocumentSymbols(filePath) // Hierarchical outline LspWorkspaceSymbols(filePath, query="[target_symbol]") // Search by name

// Get current diagnostics lsp_diagnostics(filePath) // Errors, warnings before we start \\\

AST-Grep Skill for Pattern Analysis:

\\\bash // Find structural patterns python3 scripts/astgrephelper.py search 'function $NAME($$$) { $$$ }' --lang ts src/

Preview refactoring first

sg --pattern '[oldpattern]' --rewrite '[newpattern]' --lang ts src/ \\\

Grep for Text Patterns:

\\\ grep(pattern="[searchterm]", path="src/", include=".ts") \\\

1.3: Collect Background Results

\\\ backgroundoutput(taskid="[agent1id]") backgroundoutput(taskid="[agent2id]") ... \\\

Mark phase-1 as completed after all results collected.

PHASE 2: BUILD CODEMAP (DEPENDENCY MAPPING)

Mark phase-2 as inprogress.**

2.1: Construct Definitive Codemap

Based on Phase 1 results, build:

\\\

CODEMAP: [TARGET]

More skills from code-yeongyu/oh-my-openagent

  • Aast-grepSearches and rewrites code by AST shape across 25 languages. Use when the target is a syntax pattern (every call/class/import shaped like X, a codemod, a YAML rule) rather than literal text; for plain strings, comments, or filenames, use rg.
  • AbrowserDrives a real browser through the omowright library from the js eval kernel: sites the user is already signed into, forms and clicks, JS-rendered pages, screenshots, web QA, extension popups, a human handoff for login, CAPTCHA or OTP, and a browser you own for scraping, bot-scored targets, network capture and QA traces. Use for any interactive browser task; not for a plain search or an unblocked static fetch.
  • Acodex-qaQA the omo Codex Light edition (lazycodex / packages/omo-codex) itself, in strict isolation so ONLY our plugin is exercised, never the user's real ~/.codex. The first-party method drives the real `codex app-server` against an isolated CODEX_HOME plus a LOCAL mock model (no real API call), and proves a plugin hook fired by asserting hook/started + hook/completed notifications. Also: isolated install verification, per-component hook probes, a tmux TUI smoke, and runtime log observation (RUST_LOG / logs SQLite / /debug-config). Ships tested helper scripts each with a --self-test. Use whenever someone changes anything under packages/omo-codex or wants to QA, smoke-test, verify, or debug the Codex plugin, its hooks/components, the installer/config.toml, the app-server flow, or the Codex TUI. Triggers: codex qa, qa codex, codex-qa, test codex plugin, verify codex hook, codex app-server, lazycodex qa, isolated CODEX_HOME, prove codex hook fired, codex tui test.
  • Acoding-agent-sessionsFinds, reads, and reconstructs coding-agent sessions across Codex, Claude, OpenCode, OMO/Senpi, and other local agent logs. Use when asked to find or search past sessions, transcripts, or subagent runs, or to recover what an earlier session did.
  • Acomment-checkerUse when Codex needs to understand or respond to automatic comment-checker feedback emitted after an edit-like PostToolUse hook.
  • Adag-libraryStores a DAG definition once and re-runs it by name, instead of pasting the definition into every run. Use when the user wants to save a DAG, run a saved one, or schedule the same multi-agent graph repeatedly.
  • Ddata-scientistProcesses and analyzes data with resident-kernel engines (DuckDB, Polars) and one-shot tools. Use for CSV/parquet/JSON analysis, group-by/join/aggregation, time series, distributions, cleaning, or plotting a dataset.
  • AdebuggingRuns a hypothesis-driven debugging loop across any language or binary, escalating to orthogonal oracle angles and locking the fix with a failing test. Use for crashes, silent failures, hangs, wrong responses, memory leaks, async misbehavior, or reverse engineering.
  • Adev-browserBrowser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.
  • CfrontendBuilds, styles, and polishes web UI and UX. Use for any frontend, page, component, styling, layout, animation, or visual-quality task, or when asked to make an interface look or feel a certain way.
  • AfrontendBuilds, styles, and polishes web UI and UX. Use for any frontend, page, component, styling, layout, animation, or visual-quality task, or when asked to make an interface look or feel a certain way.
  • Aget-unpublished-changesCompare HEAD with the latest published npm versions and list all unpublished changes by release layer. Triggers: unpublished changes, changelog, what changed, whats new.

All agent skills → · MCP servers