code-refactoring-patterns

code-refactoring-patterns is a skill for Claude Code from organvm-iv-taxis/a-i--skills. It costs 25 tokens per session (1,981 once invoked), scanned A, original, Apache-2.0.

A collection of repeatable techniques for reorganizing code while keeping its behavior unchanged. It explains common code problems such as duplicated logic and functions that are too long.

In plain words
What is it for?
Use it to choose a suitable refactoring technique, split large functions, remove duplication, improve names, and verify each small change with tests.
Why use it?
It provides a step-by-step way to improve difficult code without mixing cleanup with new features or losing track of broken tests.

Skill for Claude Code

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

Part of the example-skills plugin — 47 skills, 2 commands, 1 agent shipped together

Good fit Use it to choose a suitable refactoring technique, split large functions, remove duplication, improve names, and verify each small change with tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/organvm-iv-taxis/a-i--skills/code-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 organvm-iv-taxis/a-i--skills --skill code-refactoring-patterns
Clone the repo
git clone --depth 1 https://github.com/organvm-iv-taxis/a-i--skills

Made for: Claude Code.

Or install example-skills, the plugin that ships this one along with the rest of its 47 skills, 2 commands, 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 code-refactoring-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/organvm-iv-taxis/a-i--skills/code-refactoring-patterns/github.svg)](https://agentmods.dev/skills/organvm-iv-taxis/a-i--skills/code-refactoring-patterns)
Your own site
<a href="https://agentmods.dev/skills/organvm-iv-taxis/a-i--skills/code-refactoring-patterns"><img src="https://agentmods.dev/badge/skills/organvm-iv-taxis/a-i--skills/code-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 code-refactoring-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/organvm-iv-taxis/a-i--skills/code-refactoring-patterns"><img src="https://agentmods.dev/badge/skills/organvm-iv-taxis/a-i--skills/code-refactoring-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,981 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 warn 7 Sept 2026
SkillSpector: 2 findings, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium MCP Rug Pull · line 345
    npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
    Fix: Pin the version: npx @scope/[email protected]
  • medium Excessive Agency · line 394
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
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.00025 $0.01981
Opus 5 $0.00013 $0.00991
Sonnet 5 $0.00005 $0.00396
Haiku 4.5 $0.00003 $0.00198

Measured 12d ago against content hash 96cf227b2ff8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

code-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 12d 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.

distributions/claude/skills/code-refactoring-patterns/SKILL.md · 402 lines

How it starts

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

Code Refactoring Patterns

A comprehensive guide to refactoring code systematically while maintaining functionality and improving quality.

When to Refactor

  • Code smells detected (duplicated code, long functions, etc.)
  • Before adding new features to complex areas
  • After understanding improves ("now I see a better way")
  • When tests are in place
  • Performance optimization needed

Refactoring Rules

  1. Never refactor without tests: Write tests first if they don't exist
  2. Small steps: Make one change at a time
  3. Run tests after each change: Ensure nothing breaks
  4. Commit often: Each working refactor is a commit
  5. Don't mix refactoring with feature work: Separate concerns

Common Code Smells

1. Long Method/Function

Smell: Functions over 20-30 lines

Refactor: Extract Method

// Before
function processOrder(order: Order) {
  // Validate order (10 lines)
  // Calculate totals (15 lines)
  // Apply discounts (12 lines)
  // Send confirmation (8 lines)
}

// After
function processOrder(order: Order) {
  validateOrder(order);
  const totals = calculateTotals(order);
  const finalPrice = applyDiscounts(totals, order);
  sendConfirmation(order, finalPrice);
}

2. Duplicated Code

Smell: Same code in multiple places

Refactor: Extract Function/Class

// Before
function formatUserName(user: User) {
  return `${user.firstName} ${user.lastName}`;
}

function formatAuthorName(author: Author) {
  return `${author.firstName} ${author.lastName}`;
}

// After
function formatFullName(person: { firstName: string; lastName: string }) {
  return `${person.firstName} ${person.lastName}`;
}

3. Long Parameter List

Smell: Functions with 4+ parameters

Refactor: Parameter Object

// Before
function createUser(
  firstName: string,
  lastName: string,
  email: string,
  phone: string,
  address: string
) { }

// After
interface UserDetails {
  firstName: string;
  lastName: string;
  email: string;
  phone: string;
  address: string;
}

function createUser(details: UserDetails) { }

Read the full file on GitHub · 402 lines

Files

What ships with it

1 file 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. 12d ago First seen · 402 lines · 25 tokens per session scan A 96cf227b2ff8

Subscribe to this mod's changes

code-refactoring-patterns is a skill published in the GitHub repository organvm-iv-taxis/a-i--skills (17 stars, last pushed 16d ago), licensed Apache-2.0. It adds 25 tokens to every session and 1,981 once invoked, about $0.0001 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-30.

Related

Other skills, from other repositories

python-code-quality

Code quality checks, linting, formatting, and type checking commands for the Agent Framework Python codebase. Use this when running checks, fixing lint errors, or troubleshooting CI failures.

microsoft/agent-framework · 40 tokens

node-zombie-guardian

Use when diagnosing stale or orphaned Node.js processes launched by VCO, auditing ownership/liveness, or safely simulating cleanup without touching external Node workloads.

foryourhealth111-pixel/Vibe-Skills · 37 tokens

atmos-schemas

JSON Schema for Atmos: stack-manifest and atmos.yaml config schemas, IDE auto-completion, validate stacks/schema/config, SchemaStore integration.

cloudposse/atmos · 32 tokens

atmos-diagnostics

Atmos diagnostics: machine-readable JSONL event streams, diagnostics.enabled/file/includeoutput, subprocess start/end/output events, masking, and debugging Atmos execution.

cloudposse/atmos · 33 tokens

architecture-optimization

Guided journey from a working codebase grown slow and tangled to one measurably fast, cleanly bounded, and readable. Orchestrates eight skills phase by phase - working-with-legacy-code, clean-architecture, software-design-philosophy, refactoring-patterns, system-design, ddia-systems, release-it, pragmatic-programmer …

wondelai/skills · 226 tokens

release-it

Build production-ready systems with stability patterns: circuit breakers, bulkheads, timeouts, and retry logic. Use when the user mentions "production outage", "circuit breaker", "deployment pipeline", "chaos engineering", "retry storm", "health checks", "my service keeps crashing", "prevent cascading failures", or…

wondelai/skills · 131 tokens