refactoring

refactoring is a skill for Claude Code from Sagargupta16/claude-skills. It costs 51 tokens per session (1,573 once invoked), scanned A, original, MIT.

A skill for reorganizing code while keeping its behavior the same.

In plain words
What is it for?
Use it to extract functions, rename symbols, move files, remove duplication, simplify conditions, or migrate JavaScript to TypeScript and CommonJS to ES modules.
Why use it?
It lowers the chance of regressions by recommending tests before and after each small change and keeping refactoring separate from new features.

Skill for Claude Code

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

Part of the refactoring plugin — 1 skill, 1 command, 1 agent shipped together

Good fit Use it to extract functions, rename symbols, move files, remove duplication, simplify conditions, or migrate JavaScript to TypeScript and CommonJS to ES modules.

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

Made for: Claude Code.

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

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/sagargupta16/claude-skills/refactoring/github.svg)](https://agentmods.dev/skills/sagargupta16/claude-skills/refactoring)
Your own site
<a href="https://agentmods.dev/skills/sagargupta16/claude-skills/refactoring"><img src="https://agentmods.dev/badge/skills/sagargupta16/claude-skills/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/sagargupta16/claude-skills/refactoring"><img src="https://agentmods.dev/badge/skills/sagargupta16/claude-skills/refactoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,573 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.00051 $0.01573
Opus 5 $0.00026 $0.00787
Sonnet 5 $0.00010 $0.00315
Haiku 4.5 $0.00005 $0.00157

Measured 10d ago against content hash 692cfa6da664, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, 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 10d 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/skills/refactoring/SKILL.md · 194 lines

How it starts

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

Refactoring Patterns

Quick Reference

Task Approach
Extract function/method Identify repeated or complex block, extract with clear name
Rename safely Find all references first, rename, run tests
Move file/module Update all imports, check for re-exports, run tests
Reduce duplication Extract shared logic only when used 3+ times
Migrate JS -> TS File by file, start with strictest config, add types gradually
Migrate CJS -> ESM Update require/module.exports to import/export, fix package.json
Simplify conditionals Replace nested if/else with early returns or guard clauses

Safe Refactoring Workflow

  1. Verify tests pass before touching anything
  2. Make one change at a time -- don't combine refactors
  3. Run tests after each change to catch regressions immediately
  4. Commit frequently -- each refactor step gets its own commit
  5. Never mix refactoring with behavior changes in the same commit

Code Smell Detection

Smell Symptom Refactoring
Long function > 30 lines or does multiple things Extract method
Duplicate code Same logic in 3+ places Extract shared function
Deep nesting > 3 levels of if/for/try Early returns, extract helper
Long parameter list > 4 parameters Introduce parameter object
Feature envy Method uses another class's data more than its own Move method
God class/module One file does everything Split by responsibility
Dead code Unreachable or unused code Delete it
Primitive obsession Raw strings/ints for domain concepts Introduce value types
Shotgun surgery One change requires editing many files Consolidate related logic
Middle man Class that only delegates Remove and call directly

Extract Patterns

Extract Function

Before:

def process_order(order):
    # validate
    if not order.items:
        raise ValueError("Empty order")
    if order.total < 0:
        raise ValueError("Negative total")
    # calculate tax
    tax = order.total * 0.08
    if order.state == "CA":
        tax = order.total * 0.0975
    order.tax = tax
    order.final_total = order.total + tax

Read the full file on GitHub · 194 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. 10d ago First seen · 194 lines · 51 tokens per session scan A 692cfa6da664

Subscribe to this mod's changes

refactoring is a skill published in the GitHub repository Sagargupta16/claude-skills (5 stars, last pushed 3d ago), licensed MIT. It adds 51 tokens to every session and 1,573 once invoked, about $0.0003 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

coordinate-readmes

Coordinate a Foundry plugin's Claude and Codex README editions, preserving common product content and verifying platform-specific installation, availability and benchmark evidence. Use for paired README edits, benchmark updates or a README parity review before release.

V-Songbird/foundry · 48 tokens

phpunit-test-team-reviewing

Use this skill when the user asks for a team-based, consensus, multi-reviewer, or red-team review of Shopware PHPUnit tests — trigger phrases like "team review these tests", "consensus review the tests in PR.

shopwareLabs/ai-coding-tools · 52 tokens

phpunit-test-reconciling

Internal sub-skill. Do not auto-activate. Use only when explicitly invoked by name by another skill or agent.

shopwareLabs/ai-coding-tools · 32 tokens

audit-comment-residue

Classify code comments for four residue shapes. History narration ("used to… now…"), plan/session references ("Task 2 replaces the old…", "in this PR"), conversational antecedents ("per your request", "as you asked"), and ticket/PR/branch back-references a future reader will never see. Emitting Tier 1 (remove) and…

melodic-software/claude-code-plugins · 159 tokens

issue-analyzing

Use this skill when the user asks to analyze a specific GitHub issue, understand what area of code an issue affects, assess an issue's scope, or research the code context around an issue — example triggers like "analyze issue.

shopwareLabs/ai-coding-tools · 51 tokens

pr-analyzing

Use this skill when the user asks to analyze a specific GitHub pull request, review a PR's architectural impact, assess what changed in a PR and why it matters, or research the code relationships affected by a PR — example triggers like "analyze PR.

shopwareLabs/ai-coding-tools · 56 tokens