refactoring-expert

refactoring-expert is a skill for Claude Code from Miaoge-Ge/coding-agent-skills. It costs 71 tokens per session (929 once invoked), scanned A, original, MIT.

A guide to safely restructuring existing code while keeping its observable behaviour unchanged.

In plain words
What is it for?
Use it to extract functions, rename or simplify code, reduce nesting, decouple components, and clean up legacy code.
Why use it?
It reduces complexity, duplication, and technical debt while using small steps and tests to catch accidental changes.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the refactoring-expert plugin — 1 skill shipped together

Good fit Use it to extract functions, rename or simplify code, reduce nesting, decouple components, and clean up legacy code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/miaoge-ge/coding-agent-skills/refactoring-expert
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Miaoge-Ge/coding-agent-skills --skill refactoring-expert
Clone the repo
git clone --depth 1 https://github.com/Miaoge-Ge/coding-agent-skills

Made for: Claude Code.

Or install refactoring-expert, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refactoring-expert

README.md
[![agentmods](https://agentmods.dev/badge/skills/miaoge-ge/coding-agent-skills/refactoring-expert.svg)](https://agentmods.dev/skills/miaoge-ge/coding-agent-skills/refactoring-expert)
Your own site
<a href="https://agentmods.dev/skills/miaoge-ge/coding-agent-skills/refactoring-expert"><img src="https://agentmods.dev/badge/skills/miaoge-ge/coding-agent-skills/refactoring-expert.svg" alt="Measured on agentmods" height="20"></a>
Per session 71 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 929 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00071 $0.00929
Opus 5 $0.00036 $0.00464
Sonnet 5 $0.00014 $0.00186
Haiku 4.5 $0.00007 $0.00093

Measured 8d ago against content hash af55db16a693, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

refactoring-expert scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/refactoring-expert/skills/refactoring-expert/SKILL.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Refactoring Expert

Refactoring preserves behavior — full stop. Small reversible steps under a green test suite, separate from feature/bug commits. Refactor toward a goal, then stop.

When to Use

  • Cleaning up, simplifying, or decoupling existing code.
  • Addressing code smells (long functions, duplication, deep nesting, god objects, primitive obsession, feature envy).
  • Preparing messy code before adding a feature ("make the change easy, then make the easy change").
  • Paying down technical debt in legacy code.

When NOT to Use

  • Adding behavior/features — that's not refactoring → relevant language skill.
  • Fixing a defect → debugging-expert.
  • Optimizing speed (may justify behavior/structure trade-offs) → performance-expert.

Core Principles

1. Behavior must not change

  • Refactoring changes structure, never observable behavior. Keep refactors in separate commits from features and bug fixes so review and rollback stay clean.
  • If you find a bug mid-refactor, note it and fix it separately — don't smuggle a behavior change into a refactor.

2. Establish a safety net first

  • Tests are what make refactoring safe. No tests around the code? Add characterization tests (capture current behavior, even if "wrong") before changing legacy code. Then refactor against green.

3. Small, reversible steps

  • One named transformation at a time — Extract Function, Rename, Inline, Introduce Parameter Object, Replace Conditional with Polymorphism, Move Method — running tests after each. Commit frequently so any step is cheap to revert.
  • Prefer IDE/automated refactorings (rename, extract) — they're safer than hand edits.

4. Target real smells, then stop

  • Extract long functions into small, single-purpose, well-named ones. Remove duplication once a pattern is proven (rule of three — don't abstract on the first repeat).
  • Flatten nesting with guard clauses/early returns. Replace magic numbers/flags with named constants/types. Improve names — good names delete the need for comments.
  • Refactor in service of a goal (readability, an upcoming change), not endlessly. Don't gold-plate or add speculative generality (YAGNI).

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 84 lines · 71 tokens per session scan A af55db16a693

Subscribe to this mod's changes

refactoring-expert is a skill published in the GitHub repository Miaoge-Ge/coding-agent-skills (5 stars, last pushed 3mo ago), licensed MIT. It adds 71 tokens to every session and 929 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

audit

Audits recent work against its Definition of Done and project patterns. Runs the test suite, compares code against the spec, and reports PASS / PARTIAL / FAIL. Also runs the Critical Gate — a safety scan of the diff for destructive or dangerous operations. Generates an incremental prompt pack for any gaps found. With…

pe-menezes/vibeflow · 93 tokens

replen

Triage today's Replen matches for this repo: a verdict and effort estimate per candidate, grounded in your code. Invoke with /replen or "what's new from Replen?".

replenhq/replen · 0 tokens

codex

Delegate coding tasks to the OpenAI Codex CLI for features, refactoring, PR reviews, and batch fixes. Requires the codex CLI and typically a git repository.

deepelementlab/jupyter-studio · 37 tokens

analyze

Deep-analyzes the current codebase to discover stack, architecture, patterns, conventions, and pitfalls. Creates curated documentation in .vibeflow/ that persists and can be committed to git. Supports incremental updates, scoped deep-dives, interactive review, and satellite repo analysis. Use when setting up a…

pe-menezes/vibeflow · 81 tokens

vibeflow-audit

Audits implementation against its DoD and project patterns. Runs the test suite, compares code against the spec, and reports PASS / PARTIAL / FAIL. Also runs the Critical Gate — a safety scan of the diff for destructive or dangerous operations. With --consolidate-hotfixes, reclassifies hotfix trace docs against the…

pe-menezes/vibeflow · 86 tokens

sdd-tasks

Break an SDD change into implementation tasks. Trigger: orchestrator launches task planning for a change.

Gentleman-Programming/gentle-ai · 25 tokens