refactoring-patterns

refactoring-patterns is a skill for Claude Code, Codex from ApexIQ/skillsmith. It costs 27 tokens per session (548 once invoked), scanned A, original, MIT.

A guide to changing existing code while keeping its behavior the same. It describes patterns such as extracting functions or components, naming important values, and grouping related parameters.

In plain words
What is it for?
Use it to split large functions or files, remove repeated code, simplify confusing code, improve React components, and replace unexplained numbers with named values.
Why use it?
It helps make code easier to understand and maintain while reducing the risk of accidental behavior changes.

Skill for Claude CodeCodex

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

Good fit Use it to split large functions or files, remove repeated code, simplify confusing code, improve React components, and replace unexplained numbers with named values.

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

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 refactoring-patterns

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/apexiq/skillsmith/refactoring_patterns"><img src="https://agentmods.dev/badge/skills/apexiq/skillsmith/refactoring_patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 548 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.00027 $0.00548
Opus 5.5 $0.00011 $0.00219
Sonnet 5.5 $0.00005 $0.00110
Haiku 4.5 $0.00003 $0.00055

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

Security

Grade A, and why

refactoring-patterns 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 3mo 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.

.agent/skills/refactoring_patterns/SKILL.md · 87 lines

What it actually says

♻️ Refactoring Patterns

Rule: Refactor with tests. No tests = No refactor.

1. When to Refactor

Signal Action
Same code in 3+ places Extract to function/component.
Function >50 lines Split into smaller functions.
File >500 lines Split into modules.
"I don't understand this" Add comments, then simplify.

When NOT to Refactor:

  • No tests covering the code.
  • Deadline pressure (ship first, refactor later).
  • "Just because" - there must be a clear benefit.

2. Common Refactoring Patterns

Extract Function

# Before
def process_email(email):
    # 50 lines of validation
    # 50 lines of processing

# After
def process_email(email):
    validate_email(email)
    transform_email(email)

Extract Component (React)

// Before: 200-line component
// After: Split into <EmailList />, <EmailRow />, <EmailActions />

Replace Magic Numbers

# Before
if priority > 7:

# After
HIGH_PRIORITY_THRESHOLD = 7
if priority > HIGH_PRIORITY_THRESHOLD:

Introduce Parameter Object

# Before
def send_email(to, subject, body, cc, bcc, attachments): ...

# After
def send_email(request: SendEmailRequest): ...

3. Safe Refactoring Workflow

  1. Write tests (if they don't exist).
  2. Run tests - they should pass.
  3. Refactor in small steps.
  4. Run tests after each step.
  5. Commit when green.

Examples

  • Good refactor: Extract calculatePriority() from a 100-line function. Tests pass before and after.
  • Bad refactor: "Cleaned up" a file with no tests. Shipped a bug.

Guidelines

  • One refactor per commit. Don't mix refactors with features.
  • Use IDE refactoring tools (Rename, Extract) - they're safer.
  • If refactor is risky, create a feature flag to roll back.
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. 3mo ago First seen · 87 lines · 27 tokens per session scan A 77658d59be41

Subscribe to this mod's changes

refactoring-patterns is a skill published in the GitHub repository ApexIQ/skillsmith (5 stars, last pushed 8mo ago), licensed MIT. It adds 27 tokens to every session and 548 once invoked, about $0.0001 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

refactoring-patterns compared with skills from other repositories

refactoring-patterns next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
refactoring-patternsApexIQ/skillsmithSkill58mo agoMITA27Claude Code, Codex
refactor-agentchandrudp29/skillhubSkill145mo agoMITA32Claude Code, Codex
refactoringasgarovf/locusaiSkill238mo agoMITA31Claude Code
refactoring-patternssummarybotng/summarybot-ngSkill25mo agoMITA33Claude Code
a-philosophy-of-software-designciembor/agent-rules-booksSkill3.4k2mo agoMITA33Claude Code, Codex
domain-driven-designciembor/agent-rules-booksSkill3.4k2mo agoMITA29Claude Code, Codex
pptxaxoviq-ai/synthadocSkill2.0ktodayAGPL-3.0A10Claude Code, Codex