Agent skill · Code Review & Quality

refactor

Intelligent refactor command. Triggers: refactor, refactoring, cleanup, restructure, extract, simplify, modernize.

YeonGyu-Kim69,732★ · +488/wk · 2 repos on radarProfile →
claude-codecodexcursorNOASSERTION
Install
npx skills add code-yeongyu/oh-my-openagent --skill refactor --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 24 KB
Bundled scripts: none
Path: packages/shared-skills/skills/refactor/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 67,209 · +483 this week
Language: TypeScript
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

The skill provides a structured, multi-phase workflow to perform intelligent refactoring. It defines commands and options to specify a refactoring target, scope, and risk strategy. It orchestrates a six-phase process: codebase analysis, codemap building, test assessment, plan generation, deterministic execution, and final verification. It uses explicit steps for discovery, dependency mapping, pattern-based transformations, and verification after each change, with mandatory diagnostics and test runs throughout.

How it works

  • It accepts a refactor command with a target and optional scope and strategy.
  • Phase 1: Launches multiple background explore agents to locate occurrences, dependencies, similar patterns, tests, and architecture context, while concurrently using LSP tools, AST-grep, and grep for analysis.
  • Phase 2: Builds a definitive codemap from Phase 1 results, including core files, dependency graphs, impact zones, and established patterns, plus constraints to follow or avoid.
  • Phase 3: Assesses tests by detecting test infrastructure, analyzing coverage, and determining a verification strategy with a decision matrix based on coverage levels.
  • Phase 4: Invokes a Plan agent to generate a detailed, atomic refactoring plan and then converts it into granular todos.
  • Phase 5: Executes refactoring step-by-step with pre-step checks, targeted tools (rename, pattern transformations, structural edits), and mandatory post-step verification (diagnostics, tests, type checks). Includes a rollback path on failure.
  • Phase 6: Performs final verification with full test suite, type checks, lint, build verification, and a summary of changes and results.
  • It enforces frequent diagnostics and test runs after each change and requires commits at logical checkpoints.

When to use it

Use when you need to perform an intelligent refactor with awareness of the codebase, dependencies, and tests, especially when aiming for a safe, verifiable transformation across a file, module, or project scope. Triggered by commands like /refactor with a target and optional scope/strategy.

What it can touch

The skill integrates with LSP tools and AST-Grep tooling to touch code through:

  • LSP: LspGotoDefinition, LspFindReferences, LspDocumentSymbols, LspWorkspaceSymbols, lsp_diagnostics
  • AST-Grep: scripts/ast_grep_helper.py, sg CLI tool
  • Pattern and structural edits via edit helper tools, and shell commands for tests and type checks
  • Git for committing at checkpoints

Caveats

  • Requires explicit target and scope; ambiguity triggers clarifying prompts.
  • Dependent on test coverage levels: if LOW/NONE coverage, the workflow proposes user choices and may pause.
  • Relies on external agents (explore, plan, oracle, librarian) to perform specialized tasks.
  • Risk of modification depends on adherence to existing patterns and constraints; must not break critical paths.
From the SKILL.md

export const REFACTOR_TEMPLATE = `# Intelligent Refactor Command ## Usage \`\`\` /refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>] 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** - S

What's inside
Steps it walks through
  1. Usage
  2. What This Command Does
  3. Step 0.1: Parse Request Type
  4. Step 0.2: Validate Understanding
  5. Step 0.3: Create Initial Todos
  6. 1.1: Launch Parallel Explore Agents (BACKGROUND)
  7. 1.2: Direct Tool Exploration (WHILE AGENTS RUN)
  8. LSP Tools for Precise Analysis:
  9. AST-Grep Skill for Pattern Analysis:
  10. Grep for Text Patterns:
  11. 1.3: Collect Background Results
  12. 2.1: Construct Definitive Codemap
  13. CODEMAP: [TARGET]
  14. Core Files (Direct Impact)
More from oh-my-openagent
All skills →
About this skill
What does the refactor skill do?

Intelligent refactor command. Triggers: refactor, refactoring, cleanup, restructure, extract, simplify, modernize.

How do I install it?

Run `npx skills add code-yeongyu/oh-my-openagent --skill refactor --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From code-yeongyu/oh-my-openagent, a repository with 67,209 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going