refactor

refactor is a skill for Claude Code from mgiovani/cc-arsenal. It costs 102 tokens per session (2,481 once invoked), scanned A, original, MIT.

A safe code-structure cleanup process that changes how existing code is organized while keeping its behaviour the same.

In plain words
What is it for?
Use it to extract methods or classes, simplify logic, map callers, add tests that capture current behaviour, and make small verified restructuring changes.
Why use it?
It helps make code easier to read and maintain while tests check that users and other code still get the same results.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: mentions CLAUDE.md; mentions subagents; names the AskUserQuestion tool.

Part of the cc-arsenal-dev plugin — 19 skills shipped together , and of cc-arsenal

Good fit Use it to extract methods or classes, simplify logic, map callers, add tests that capture current behaviour, and make small verified restructuring changes.

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

Made for: Claude Code.

Or install cc-arsenal-dev, the plugin that ships this one along with the rest of its 19 skills.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/mgiovani/cc-arsenal/refactor"><img src="https://agentmods.dev/badge/skills/mgiovani/cc-arsenal/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 102 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,481 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. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00102 $0.02481
Opus 5.5 $0.00041 $0.00992
Sonnet 5.5 $0.00020 $0.00496
Haiku 4.5 $0.00010 $0.00248

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

Security

Grade A, and why

refactor 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 22d 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/refactor/SKILL.md · 164 lines

How it starts

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

Refactor

Refactor code safely: capture current behavior with characterization tests, then restructure it in small steps, running the full test suite after each one before moving to the next.

Refactoring Goal

$ARGUMENTS

Core Principle: Behavior Preservation

Refactoring changes code structure WITHOUT changing behavior. Every step must be verified against existing tests. If tests break, the refactoring introduced a bug: revert and retry.

Anti-hallucination guidelines

  1. Read the code first: understand all callers and dependencies before touching anything.
  2. Run the full test suite before starting and again after every incremental change; results must match.
  3. Where coverage is thin, capture current behavior in characterization tests before restructuring.
  4. Change one small, verifiable thing at a time. Never combine steps into a single edit.
  5. Refactoring changes structure, not behavior: no new features, no bug fixes. Those are separate tasks (implement-feature, fix-bug), and Phase 0's scope gate below is where this gets enforced, not just stated.
  6. Never claim a structure you haven't verified by reading the actual files.
  7. When several call sites share logic, consolidate it into one place and delete the copies, rather than wrapping them in a new abstraction.
  8. Simplifying structure must never remove a validation check or an error/data-loss path, nor a security control or an accessibility branch already in place. Losing any of those counts as a behavior change, not a refactor, so stop and re-scope it separately.

Quality Gates

A Stop hook re-runs the Phase 4 Quality Gates Checklist automatically and blocks completion if any item fails, see the hook prompt above for the exact wording.

Task Management

Whether the ceremony below (formal task chain, subagent fan-out) is worth it depends on blast radius, not on whether the skill fired.

The Phase 0 scope gate below always runs, even on the skip path: it's a five-second scan of the request, not ceremony.

Read the full file on GitHub · 164 lines

Files

What ships with it

4 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. 22d ago Changed · -1 lines d568186eda22
  2. 1mo ago Changed · +4 lines 61750c6f7915
  3. 1mo ago Changed · +2 lines 3ed024cd53c0
  4. 1mo ago First seen · 159 lines · 102 tokens per session scan A 21263a9384c1

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository mgiovani/cc-arsenal (8 stars, last pushed 2d ago), licensed MIT. It adds 102 tokens to every session and 2,481 once invoked, about $0.0004 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

Other skills, from other repositories

testing-anti-patterns

Reviews test code to identify and fix common testing anti-patterns including flaky tests, over-mocking, brittle assertions, test interdependency, and hidden test logic. Flags bad patterns, explains the specific defect, and provides corrected implementations. Use when reviewing test code, debugging intermittent or…

rohitg00/skillkit · 95 tokens

structured-code-review

Performs a structured five-stage code review covering requirements compliance, correctness, code quality, testing, and security/performance. Each stage uses targeted checklists and categorized feedback (Blocker/Major/Minor/Nit) with actionable suggestions and rationale. Use when the user asks for code review, PR…

rohitg00/skillkit · 112 tokens

junie

Delegate tasks or get a second opinion from Junie CLI. Infers mode (delegation vs validation) from prompt context. Detects available models at runtime via the CLI. Use when cross-validating code, plans, or architecture with Junie CLI, or offloading work to it. Do not use for tasks that do not benefit from cross-model…

darshitpp/x-agent · 75 tokens

find-simplifications

Use for a periodic repo-wide sweep of qwen-code for accumulated excess surface — dead components and files, orphaned locale keys, exports nothing consumes, added-then-removed scaffolding — filing candidates on a tracking issue and landing only what a maintainer has said yes to. Repo-wide and evidence-first; every…

QwenLM/qwen-code · 103 tokens

swarm-pr-review

Run a graph-guided, tool-augmented PR review using context packing, parallel exploration, mandatory repository-agnostic risk-family coverage with dispatch scaled to diff size and risk, independent reviewer validation, critic challenge, and metrics writeback. Use for deep pull request review with low false-positive…

ZaxbyHub/opencode-swarm · 91 tokens

agent-debug-ci

Investigate failed scheduled or nightly GitHub Actions runs on the default branch, determine whether the failure is reproducible and repository-owned, implement the smallest evidence-backed fix, validate it, and open a pull request. Use when a failed nightly CI event starts an agent, or when the standard CI or…

NVIDIA/elements · 80 tokens