refactor

refactor is a skill for Claude Code, Codex from soulcodex/agentic. It costs 46 tokens per session (526 once invoked), scanned A, original, MIT.

A code-cleanup process that changes the internal structure of code without changing what the program does. It uses tests to record current behaviour and check each small change.

In plain words
What is it for?
Use it to split up long code, remove duplication, rename unclear parts, or move logic into a more suitable layer.
Why use it?
It makes code easier to understand, test, and maintain while reducing the chance that cleanup introduces a bug.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Codex; mentions OpenCode.

Good fit Use it to split up long code, remove duplication, rename unclear parts, or move logic into a more suitable layer.

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

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/soulcodex/agentic/refactor/github.svg)](https://agentmods.dev/skills/soulcodex/agentic/refactor)
Your own site
<a href="https://agentmods.dev/skills/soulcodex/agentic/refactor"><img src="https://agentmods.dev/badge/skills/soulcodex/agentic/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/soulcodex/agentic/refactor"><img src="https://agentmods.dev/badge/skills/soulcodex/agentic/refactor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 526 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.00046 $0.00526
Opus 5.5 $0.00018 $0.00210
Sonnet 5.5 $0.00009 $0.00105
Haiku 4.5 $0.00005 $0.00053

Measured 1mo ago against content hash 1e8e7a9ce836, 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 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.

skills/development/refactor/SKILL.md · 68 lines

What it actually says

Refactor Skill

Improve the code structure without changing external behavior.

Step 1 — Understand the Goal

Ask or infer:

  • What is wrong with the current code? (too long, duplicated, wrong layer, hard to test)
  • What is the desired outcome? (extracted function, renamed variable, moved to correct layer)
  • Are there tests in place? (if not, write characterization tests before refactoring)

Step 2 — Establish a Safety Net

Before changing anything, verify tests exist that cover the code being refactored. If tests are missing, write characterization tests first:

  • A characterization test captures current behavior (even if the behavior is wrong).
  • It prevents accidental behavior changes during refactoring.

Step 3 — Apply Refactoring in Small Steps

Work in small, safe increments. After each step, verify tests still pass:

Common refactoring moves:

  • Extract function/method: identify a coherent chunk of logic with a clear purpose.
  • Rename: choose a name that accurately describes the thing at the current abstraction level.
  • Move to correct layer: domain logic in a controller → move to use case or domain service.
  • Replace conditional with polymorphism: complex switch/if chains on type → strategy pattern.
  • Introduce value object: raw primitive used to represent a domain concept → wrap it.
  • Remove duplication: extract shared logic to a shared function; do not abstract prematurely.

Step 4 — Verify Behavior is Unchanged

After refactoring:

  • All tests pass.
  • The public API (exported signatures) is unchanged.
  • No new dependencies introduced.

Step 5 — Summarize

## Refactor Summary

**What changed**: [List of moves applied]
**Why**: [The design problem that was addressed]
**Tests**: [Pass / added N new characterization tests]
**Breaking changes**: None (internal only)
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 First seen · 68 lines · 46 tokens per session scan A 1e8e7a9ce836

Subscribe to this mod's changes

refactor is a skill published in the GitHub repository soulcodex/agentic (10 stars, last pushed 1mo ago), licensed MIT. It adds 46 tokens to every session and 526 once invoked, about $0.0002 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

desktop-brand-builder

Generate a branded Qwen Code desktop package from the Tauri desktop shell using a minimal brandId and logo. Use when the user wants a custom, white-label, or rebranded desktop client, installer, DMG/EXE/AppImage/deb, or one-click brand build on top of packages/desktop.

QwenLM/qwen-code · 68 tokens

app-screenshot-debug

Drive the running termio app via AppleScript / System Events to reach a UI state (focus the window, click a sidebar project, a terminal pane, a control), capture a pixel-accurate screenshot of just that window, and read it back for visual analysis — for diagnosing layout / spacing / alignment / 'this looks ugly'…

termio-sh/termio · 161 tokens

product-research

Find and compare current FF&E candidates from a design brief, with sourced purchasing facts and optional CSV-library save. Use to research or source products; not to match from an image or pair coordinating items.

AlpacaLabsLLC/skills-for-architects · 44 tokens

product-enrich

Enrich FF&E schedule rows with categories, colors, materials, and style tags. Use to tag, categorize, or fill those missing fields; not to research new products.

AlpacaLabsLLC/skills-for-architects · 39 tokens

color-palette-generator

Create an HTML color palette from a mood, description, or image, with swatches, color codes, pairings, and contrast checks. Use for color schemes or brand colors.

AlpacaLabsLLC/skills-for-architects · 41 tokens

conversational-ux

Design voice and conversational interfaces — dialog flows, error recovery, and persona. Use when the interface speaks and listens rather than being tapped. For graphical input collection, use form-design.

Owl-Listener/designer-skills · 43 tokens