refactor-module

refactor-module is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 63 tokens per session (1,044 once invoked), scanned A, original, Apache-2.0.

A guide for restructuring code while keeping its behavior unchanged; this process is called refactoring.

In plain words
What is it for?
Use it to extract functions, split files, rename code, reduce duplication, preserve public interfaces, and verify the result with tests and linting.
Why use it?
It provides a controlled way to improve code organization and readability without accidentally changing what the software does.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to extract functions, split files, rename code, reduce duplication, preserve public interfaces, and verify the result with tests and linting.

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

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 refactor-module

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/refactor-module/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/refactor-module)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/refactor-module"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/refactor-module/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 refactor-module

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/refactor-module"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/refactor-module.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,044 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.00063 $0.01044
Opus 5.5 $0.00025 $0.00418
Sonnet 5.5 $0.00013 $0.00209
Haiku 4.5 $0.00006 $0.00104

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

Security

Grade A, and why

refactor-module 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 1mo 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.

runner/skills/refactor-module/SKILL.md · 74 lines

How it starts

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

Refactor a module

A refactoring changes structure, not observable behaviour (Fowler). The discipline that makes it safe is small steps with the tests green between every one of them. You wear one hat at a time: while refactoring you add no feature and fix no bug.

Steps

  1. Establish the safety net. Run the suite (the run-tests skill) and confirm it is green BEFORE touching anything; record the command and summary. If the code you will move is thinly tested, first add characterization tests (the add-unit-test skill) that pin what it does today — including odd behaviour — through the public interface, not its private internals (tests coupled to internals break on every legitimate refactoring). Commit them separately.
  2. Read the lore. Call search_lore for module boundaries, layering and naming conventions so the new structure fits the codebase instead of inventing a new one.
  3. Name the target and list the moves. Write the end state in one or two sentences and the sequence of named refactorings that gets there: Extract Function, Inline Variable, Move Function, Rename, Split Phase, Replace Conditional with Polymorphism, Introduce Parameter Object. Each move is small enough to finish and test in minutes.
  4. Execute one move at a time. After each move: run the fastest relevant tests (and typecheck if the language has one). Green → commit (git commit -m "refactor: …") so there is a known-good point to return to. Red → undo that move (git restore --staged --worktree <paths>, and rm any file the move created — git clean -fd is hook-blocked) and take a smaller step. Never debug your way forward through a red refactoring.
  5. When a move fails because something else must change first, use the Mikado method. Note the goal, try the change naively, and when it breaks, write down the prerequisites it revealed, then revert. Work the prerequisites leaf-first, each as its own green commit, then retry the goal. Keep the list in your working notes; it doubles as your scope check.
  6. Preserve the public interface unless the ticket explicitly allows changing it. If it does, update every call site in the same change (grep the symbol, including string and dynamic references) and note the change in the evidence.
  7. Confirm equivalence. Run the full suite, lint and build once at the end (the run-tests and run-lint skills). Compare the test counts with step 1: the same tests, plus any characterization tests you added, must pass. A test you had to edit is a behaviour change unless the edit only follows a rename or a move.
  8. Evidence via the record-evidence skill: before and after test summaries, a diff_summary listing the moves, and any interface change (on a resume that call is refused: do not retry; put this, the AC → test map and the smallest-change note in your final message). Then the runner takes over.

Read the full file on GitHub · 74 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. 1mo ago Changed 07bd810def4a
  2. 2mo ago Changed · +37 lines f8e215a2e90a
  3. 3mo ago First seen · 37 lines · 63 tokens per session scan A a0d748c0f5f7

Subscribe to this mod's changes

refactor-module is a skill published in the GitHub repository tmj-90/gaffer (1 stars, last pushed 4d ago), licensed Apache-2.0. It adds 63 tokens to every session and 1,044 once invoked, about $0.0003 per session on Opus 5.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

refactor-module compared with skills from other repositories

refactor-module next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactor-moduletmj-90/gafferSkill14d agoApache-2.0A63Claude Code, Codex
bulwark-brainstormQBall-Inc/the-bulwarkSkill9yesterdayMITA50Claude Code
plan-creationQBall-Inc/the-bulwarkSkill9yesterdayMITA38Claude Code
anthropic-validatorQBall-Inc/the-bulwarkSkill9yesterdayMITA40Claude Code
create-subagentQBall-Inc/the-bulwarkSkill9yesterdayMITA42Claude Code
test-auditQBall-Inc/the-bulwarkSkill9yesterdayMITA0Claude Code
code-reviewQBall-Inc/the-bulwarkSkill9yesterdayMITA61Claude Code