refactor

refactor is a skill for Claude Code, Codex from mgiovani/cc-arsenal. It costs 102 tokens per session (2,536 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 CodeCodex

Part of the cc-arsenal plugin — 53 skills shipped together

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/mgiovani/cc-arsenal/refactor
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, Codex.

Or install cc-arsenal, the plugin that ships this one along with the rest of its 53 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.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.svg" alt="Measured on agentmods" 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,536 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.00102 $0.02536
Opus 5 $0.00051 $0.01268
Sonnet 5 $0.00020 $0.00507
Haiku 4.5 $0.00010 $0.00254

Measured 4d ago against content hash 21263a9384c1, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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 · 159 lines

How it starts

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

Refactor

Refactor code safely using characterization tests, incremental changes, and continuous verification. Every change preserves existing behavior while improving code structure, readability, and maintainability.

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 before changing: understand all callers and dependencies first.
  2. Test before and after: full suite before starting, and again after every incremental change. Results must match.
  3. Characterization tests first: where coverage is thin, capture current behavior in tests before restructuring.
  4. Incremental changes: one small, verifiable change at a time. Never combine steps into a single edit.
  5. No feature changes: refactoring doesn't add features, fix bugs, or change behavior; those are separate tasks (implement-feature, fix-bug). Phase 0's scope gate below is where this gets enforced, not just stated.
  6. Reference real code: never claim a structure you haven't verified by reading the actual files.
  7. Prefer deletion over addition: when several call sites share logic, consolidate it into one place and delete the copies, rather than wrapping them in a new abstraction.
  8. Never trim the floor: simplifying structure must not drop a validation check, an error/data-loss path, a security control, or an accessibility branch. If a step would drop one, it's a behavior change, not a refactor, 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.

Read the full file on GitHub · 159 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. 4d 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 (7 stars, last pushed 4d ago), licensed MIT. It adds 102 tokens to every session and 2,536 once invoked, about $0.0005 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

acl-rule-analysis

Vendor-agnostic ACL and firewall rule analysis with shadowed rule detection, overly permissive rule identification, unused rule discovery, redundant rule flagging, and rule ordering optimization. Covers ACLs (Cisco/JunOS/EOS) and firewall policies (PAN-OS/FortiGate/CheckPoint).

LeoYeAI/openclaw-master-skills · 64 tokens

add-analytics

Add Google Analytics 4 tracking to any project. Detects framework, adds tracking code, sets up events, and configures privacy settings.

LeoYeAI/openclaw-master-skills · 32 tokens

architecture-refiner

Facilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles: clean architecture (default), hexagonal / ports & adapters, modular monolith, or custom. Produces a formal architecture document that the corresponding atom will use. Use when setting up a…

techygarg/lattice · 114 tokens

lattice-init

Guided setup and upgrade-check experience for Lattice projects -- scans the repository, detects existing configuration and outdated conventions, suggests refiners and available upgrades in priority order, and creates or reconciles the .lattice/ config. Bridges the gap between installing skills and getting first value…

techygarg/lattice · 115 tokens

intelligent-investor-graham

Use Graham value investing for Is this investment or speculation, defensive stock screens, margin of safety, Mr. Market, allocation, funds, IPOs.

simbajigege/book2skills · 37 tokens

skill-to-workflow

将现有 Skill、Prompt、SOP 或 Agent 操作说明拆解为可执行、可监控、可重试的 Workflow 规格;识别真实节点、共享子工作流、工具调用、状态、分支、循环、 提示词、数据契约和验收方式。适用于用户要求把一个 Skill 转成工作流、节点图、 编排方案或 Workflow 实现规格时;不替代原 Skill 执行业务任务,也不在未要求时 绑定具体工作流平台或直接部署。.

simbajigege/book2skills · 120 tokens