refactoring

refactoring is a skill for Claude Code, Codex from int2t05/engineering-skills. It costs 123 tokens per session (1,292 once invoked), scanned A, original, MIT.

A workflow for changing a codebase’s structure while keeping its behavior the same. It covers moving code, splitting files and changing dependency boundaries.

In plain words
What is it for?
Extracting modules, moving classes, splitting oversized files, merging duplicates and replacing direct dependencies with interfaces.
Why use it?
It reduces the risk of structural changes by keeping behavior pinned by tests. It helps make code easier to change as the project grows.

Skill for Claude CodeCodex

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the engineering-skills plugin — 48 skills, 1 agent, 1 hook shipped together

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.

agentmods
npx agentmods add skills/int2t05/engineering-skills/refactoring
Any agent
npx skills add int2t05/engineering-skills --skill refactoring
Clone the repo
git clone --depth 1 https://github.com/int2t05/engineering-skills

Made for: Claude Code, Codex.

Or install engineering-skills, the plugin that ships this one along with the rest of its 48 skills, 1 agent, 1 hook.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/int2t05/engineering-skills/refactoring.svg)](https://agentmods.dev/skills/int2t05/engineering-skills/refactoring)
Your own site
<a href="https://agentmods.dev/skills/int2t05/engineering-skills/refactoring"><img src="https://agentmods.dev/badge/skills/int2t05/engineering-skills/refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 123 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,292 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00123 $0.01292
Opus 5 $0.00062 $0.00646
Sonnet 5 $0.00025 $0.00258
Haiku 4.5 $0.00012 $0.00129

Measured 4d ago against content hash 919fcef8c06c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

refactoring 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 4d 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.

skills/05-tune/refactoring/SKILL.md · 88 lines

How it starts

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

Refactoring

Restructure code while preserving exact behavior — extract a module, move a class to its better home, redraw a dependency boundary, split or merge files. The goal is a codebase that is easier to evolve, not fewer lines or prettier names. Every move is behavior-preserving and test-pinned.

When to use

  • Extracting a module or class from inline code to redraw a boundary
  • Moving a function/class to where it has the most context (Feature Envy fix at structure level)
  • Splitting one oversized file/module into cohesive units, or merging near-duplicates into one
  • Changing a dependency direction — inverting, decoupling, replacing a concrete dep with an interface
  • Preparing a codebase for a feature by reshaping it first (then implement separately)
  • Triggers on "refactor structure", "extract module", "move class", "split file", "change dependency", "重构结构", "提取模块", "拆分文件", "改依赖图"

Not for: single-file clarity cleanup — renaming, nesting, dead-code removal (use simplify); producing an architecture audit or design doc without executing the change (use codebase-design); machine-detectable lint/style issues (use linting).

Steps

1. Pin behavior before moving anything

Refactoring is behavior-preserving by definition — if behavior can shift, you're not refactoring, you're rewriting. Pin it first:

  • Run the test suite; it must be green. If it isn't, stop — fix the breakage or establish the baseline separately.
  • If the area has weak coverage, add characterization tests that capture current behavior (inputs → observed outputs) before you touch structure. You're not testing what it should do; you're pinning what it does do so the refactor can't silently change it.
  • Note any behavior you suspect is accidental (a bug tests currently encode). Don't fix it here — refactoring preserves behavior, bugs included. File it; fix it in a separate change.

2. Name the structural move

State the move in one sentence before executing. The catalog:

Read the full file on GitHub · 88 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 88 lines · 123 tokens per session scan A 919fcef8c06c

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository int2t05/engineering-skills (3 stars, last pushed 3d ago), licensed MIT. It adds 123 tokens to every session and 1,292 once invoked, about $0.0006 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