refactoring

refactoring is a skill for Claude Code, Codex from tozhax/plumbwork. It costs 120 tokens per session (1,245 once invoked), scanned B, original, MIT.

A method for changing a program's internal structure while keeping its observable behaviour the same. It uses tests that record current behaviour, then makes small changes and checks each step.

In plain words
What is it for?
Use it to extract functions, rename code across files, restructure modules, or move callers while preserving existing behaviour.
Why use it?
It lowers the risk of breaking callers, error handling, side effects, or unusual cases during cleanup and code relocation.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Gemini CLI.

Good fit Use it to extract functions, rename code across files, restructure modules, or move callers while preserving existing behaviour.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tozhax/plumbwork/refactoring
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 tozhax/plumbwork --skill refactoring
Clone the repo
git clone --depth 1 https://github.com/tozhax/plumbwork

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/tozhax/plumbwork/refactoring/github.svg)](https://agentmods.dev/skills/tozhax/plumbwork/refactoring)
Your own site
<a href="https://agentmods.dev/skills/tozhax/plumbwork/refactoring"><img src="https://agentmods.dev/badge/skills/tozhax/plumbwork/refactoring/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refactoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/tozhax/plumbwork/refactoring"><img src="https://agentmods.dev/badge/skills/tozhax/plumbwork/refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 120 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,245 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00120 $0.01245
Opus 5.5 $0.00048 $0.00498
Sonnet 5.5 $0.00024 $0.00249
Haiku 4.5 $0.00012 $0.00125

Measured 2d ago against content hash ec5fabffdc63, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

refactoring scanned grade B with 1 finding 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 2d 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

Where existing tests do not cover the branches to be restructured, write characterization tests before the first code edit (following `~/.gemini/config/skills/harness/references/test-design.md`):
skills/refactoring/SKILL.md · 66 lines

How it starts

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

Refactoring: Behavior-Preserving Change

A refactor changes internal structure while leaving every observable behavior identical: return values, raised errors, side effects, ordering, and emitted messages. The discipline is to pin the behavior first, restructure in small green steps, and prove that the pins can fail.

1. One Kind of Change Per Change Set

A refactor and a behavior change never share a change set. A defect noticed while refactoring is reported to the user and fixed separately; it is never folded silently into the refactor. If the requested restructuring turns out to require a behavior change, stop and inform the user.

2. Read Before Touching

Answer from the codebase and version history, never from memory:

  • What is this code responsible for, and who calls it? Search for all callers, including dynamic references: strings in configuration, registries, re-exports, and reflection.
  • Which existing tests define its behavior today?
  • Which branches and boundary cases does it contain?
  • Why is it written this way? Inspect the commit history of the lines about to change (git log -L, git blame) before removing or simplifying them.

3. Pin the Behavior With Characterization Tests

Where existing tests do not cover the branches to be restructured, write characterization tests before the first code edit (following ~/.gemini/config/skills/harness/references/test-design.md):

  • The existing code is the oracle. A characterization test asserts what the code actually produces today, even if that looks questionable. If the code returns 19.27 and a document says 19.28, the characterization test asserts 19.27 and the discrepancy is reported separately.
  • Literal inputs and literal expected outputs, captured from running the current code.
  • Every branch gets a case: each arm of a conditional or switch, plus boundary values (zero, negative, maximum, empty).
  • At the public seam (GEMINI.md Rule 9), so the tests survive the internal restructuring they protect.
  • A comparison that cannot run is a failure, never a skip. Report how many characterization cases executed; zero executed proves nothing.

Read the full file on GitHub · 66 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. 2d ago First seen · 66 lines · 120 tokens per session scan B ec5fabffdc63

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository tozhax/plumbwork (33 stars, last pushed 2d ago), licensed MIT. It adds 120 tokens to every session and 1,245 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-12-02.

Related

refactoring compared with skills from other repositories

refactoring next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactoringtozhax/plumbworkSkill332d agoMITB120Claude Code, Codex
pull-requestspingdotgg/t3codeSkill89ktodayMITA34Claude Code, Codex
test-reviewdatahub-project/datahubSkill13ktodayApache-2.0A0Claude Code, Codex
grade-testsdotnet/skillsSkill6.4ktodayMITA119Claude Code
go-testingGentleman-Programming/gentle-aiSkill9.8ktodayMITA26Claude Code, Codex
brooks-testhyhmrright/brooks-lintSkill1.6k2d agoMITA161Claude Code
dart-mechanical-refactordartsim/dartSkill1.2kyesterdayBSD-2-ClauseA20Claude Code