refactoring

refactoring is a skill for Claude Code, Codex from kreek/consult. It costs 19 tokens per session (1,098 once invoked), scanned A, original, MIT.

A set of rules for changing a program's internal structure while keeping its behavior the same. Refactoring includes work such as renaming, extracting code, moving modules, or migrating callers without changing what users experience.

In plain words
What is it for?
Use it for legacy refactors, large renames, code extraction, migrations, characterization tests, branch-by-abstraction, or planning a safer alternative to a full rewrite.
Why use it?
It reduces the risk of breaking existing behavior by requiring tests before and after each small step. It also keeps structural changes separate from feature changes so problems are easier to identify and reverse.

Skill for Claude CodeCodex

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/kreek/consult/refactoring
Any agent
npx skills add kreek/consult --skill refactoring
Clone the repo
git clone --depth 1 https://github.com/kreek/consult

Made for: Claude Code, Codex.

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/kreek/consult/refactoring.svg)](https://agentmods.dev/skills/kreek/consult/refactoring)
Your own site
<a href="https://agentmods.dev/skills/kreek/consult/refactoring"><img src="https://agentmods.dev/badge/skills/kreek/consult/refactoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 19 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,098 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.00019 $0.01098
Opus 5 $0.00010 $0.00549
Sonnet 5 $0.00004 $0.00220
Haiku 4.5 $0.00002 $0.00110

Measured 3d ago against content hash e810cdadbc1b, 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 3d 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.

agents/.agents/skills/refactoring/SKILL.md · 100 lines

How it starts

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

Refactoring

Iron Law

GREEN BEFORE THE REFACTOR. GREEN AFTER EACH STEP. NEVER MIX STRUCTURE AND BEHAVIOR IN ONE COMMIT.

When to Use

  • Changing structure while preserving behavior: legacy refactors, large renames, extractions, migrations, branch by abstraction, strangler fig, Mikado planning, characterization tests, or big-bang rewrite avoidance.

When NOT to Use

  • Behavior-first feature work; use proof.
  • Commit grouping or git history surgery after changes already exist; use git-workflow.

Core Ideas

  1. Preserve behavior first; add characterization tests where coverage is missing. Separate structural from behavior changes: every commit is one or the other, never both.
  2. Name the coupling before changing structure: data shape, side effect, module boundary, ownership, time, transport, persistence, or compatibility.
  3. Make every step small, reversible, and shippable.
  4. Validate the target shape before moving large amounts of code.
  5. For public interfaces, use parallel change: expand, migrate callers, then contract. Ask which callers, data, and releases must keep working before adding shims, dual paths, or migration complexity.
  6. Delete old paths only when traffic/callers have moved and verification proves it.
  7. Simplification is refactoring: remove accidental complexity only after naming the behavior preserved and the coupling reduced.

Workflow

  1. Define the current behavior that must not change. Add or identify tests that catch regressions at the public boundary.
  2. Name the concern being separated and its current coupling point.
  3. Pick the smallest safe pattern: rename, extract, move, parallel change, branch by abstraction, or strangler. For broad renames, write a rename map first: separate private symbols, file paths, runtime/public keys, persisted names, docs, and compatibility cleanup.
  4. Record a preservation Proof Contract: unchanged behavior claim, relevant invariant, public boundary, before/after check, evidence.
  5. For simplification, remove only complexity that has a named cost: hidden mutable state, unnecessary layer, broad helper, scattered behavior, compatibility shim, dead flag, or duplicated rule with divergent meaning.
  6. Make one structural step, run focused tests, commit. Track any old path left behind with owner and removal condition.

Read the full file on GitHub · 100 lines

Files

What ships with it

1 file 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. 3d ago First seen · 100 lines · 19 tokens per session scan A e810cdadbc1b

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository kreek/consult (1 stars, last pushed 8d ago), licensed MIT. It adds 19 tokens to every session and 1,098 once invoked, about $0.0001 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

watch

File sentinel that monitors the working directory for changes and marker comments, then auto-triggers appropriate skills. Poll-based via git diff against the last scan commit. Writes intake items for batch processing and routes marker actions through /do. Use for automatic reactions to file changes; do NOT use for…

SethGammon/Citadel · 70 tokens

pr-watch

Local PR watcher. Monitors CI status, automatically fixes failing checks by reading failure logs and applying targeted fixes, then optionally merges when all checks pass. Local CLI analog to Claude Code's cloud auto-fix feature.

SethGammon/Citadel · 46 tokens

qa

Browser-based QA verification. Launches a real browser, navigates the app, clicks buttons, fills forms, and tests user flows. Works as a standalone skill or as a phase end condition in campaigns. Requires Playwright (optional dependency, graceful skip if not installed).

SethGammon/Citadel · 56 tokens

live-preview

Mid-build visual verification loop. Takes screenshots of components during construction, not just after. Catches visual regressions and invisible features before they compound. Requires Playwright or similar screenshot tool.

SethGammon/Citadel · 40 tokens

systematic-debugging

4-phase root cause analysis: observe, hypothesize, verify, fix. Enforces investigation before any code changes. Emergency stop after 2 failed fixes. Prevents shotgun debugging and fix cascades.

SethGammon/Citadel · 45 tokens

claude-code-session-broker

Use when running Arcgentic V2 in Claude Code and fixed Planner, Developer, and Auditor role sessions must be coordinated through a broker.

Arch1eSUN/Arcgentic · 35 tokens