refactoring-patterns

refactoring-patterns is a skill for Claude Code, Codex from medy-gribkov/arcana. It costs 40 tokens per session (1,304 once invoked), scanned A, original, Apache-2.0.

A collection of code-cleanup techniques showing before-and-after examples for reorganising existing programs. It covers actions such as extracting methods or classes, renaming, moving code, removing unused code, and detecting code smells.

In plain words
What is it for?
Improving existing code structure, separating responsibilities, introducing dependency injection, removing dead code, and deciding how to apply common refactoring changes.
Why use it?
It helps make code easier to read, test, and change without altering what it does. The examples show how to break up overly large functions and reduce common design problems.

Skill for Claude CodeCodex

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

Good fit Improving existing code structure, separating responsibilities, introducing dependency injection, removing dead code, and deciding how to apply common refactoring changes.

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

Made for: Claude Code, Codex.

Its marketplace also offers this one on its own, as the plugin refactoring-patterns/plugin install refactoring-patterns after adding the marketplace above.

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/medy-gribkov/arcana/refactoring-patterns.svg)](https://agentmods.dev/skills/medy-gribkov/arcana/refactoring-patterns)
Your own site
<a href="https://agentmods.dev/skills/medy-gribkov/arcana/refactoring-patterns"><img src="https://agentmods.dev/badge/skills/medy-gribkov/arcana/refactoring-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,304 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.00040 $0.01304
Opus 5 $0.00020 $0.00652
Sonnet 5 $0.00008 $0.00261
Haiku 4.5 $0.00004 $0.00130

Measured 7d ago against content hash 561e48e7a3b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 7d 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/refactoring-patterns/SKILL.md · 233 lines

How it starts

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

Extract Method

When: A code block does one logical thing within a function that does more.

BEFORE:

function processOrder(order: Order) {
  // Validate order
  if (!order.items || order.items.length === 0) {
    throw new Error('Order must have items');
  }
  if (order.total <= 0) {
    throw new Error('Order total must be positive');
  }

  // Calculate tax
  let tax = 0;
  for (const item of order.items) {
    tax += item.price * item.quantity * 0.08;
  }

  // Save to database
  db.orders.insert({ ...order, tax });
}

AFTER:

function processOrder(order: Order) {
  validateOrder(order);
  const tax = calculateTax(order.items);
  saveOrder(order, tax);
}

function validateOrder(order: Order) {
  if (!order.items || order.items.length === 0) {
    throw new Error('Order must have items');
  }
  if (order.total <= 0) {
    throw new Error('Order total must be positive');
  }
}

function calculateTax(items: OrderItem[]): number {
  return items.reduce((sum, item) => sum + item.price * item.quantity * 0.08, 0);
}

function saveOrder(order: Order, tax: number) {
  db.orders.insert({ ...order, tax });
}

Why: Each function has a single responsibility. Method names replace comments.

Extract Class

When: A class has multiple responsibilities or a group of fields are always used together.

BEFORE:

class User {
  id: number;
  name: string;
  email: string;
  street: string;
  city: string;
  zipCode: string;
  country: string;

  getFullAddress(): string {
    return `${this.street}, ${this.city}, ${this.zipCode}, ${this.country}`;
  }
}

AFTER:

class Address {
  constructor(
    public street: string,
    public city: string,
    public zipCode: string,
    public country: string
  ) {}

  getFullAddress(): string {
    return `${this.street}, ${this.city}, ${this.zipCode}, ${this.country}`;
  }
}

class User {
  id: number;
  name: string;
  email: string;
  address: Address;
}

Read the full file on GitHub · 233 lines

Files

What ships with it

2 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. 7d ago First seen · 233 lines · 40 tokens per session scan A 561e48e7a3b3

Subscribe to this mod's changes

refactoring-patterns is a skill published in the GitHub repository medy-gribkov/arcana (1 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 40 tokens to every session and 1,304 once invoked, about $0.0002 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

analyze

Analyzes code quality, complexity, patterns across codebase. Triggers: quality report, hotspot scan, code analysis, architecture signal.

softspark/ai-toolkit · 30 tokens

predict

Analyzes diffs for regression risk and blast radius, generates risk-scored impact report. Triggers: PR review, code change risk, breaking change, blast radius, regression check.

softspark/ai-toolkit · 39 tokens

audit-and-fix

Audit an existing codebase, then autonomously implement the fixes it judges worth making against your next goal — composing deep-dive → triage → prompt-pack → build-loop to turn "here's what's wrong" into verified, receipted local commits + an honest ledger. ALWAYS invoke when the user says any of "audit this repo and…

nelsonwerd/idea-to-ship-skills · 234 tokens

senior-engineering-partner

A strict code reviewer, pair programmer, debugger, and mentor for Python, Bash, Google Apps Script, JavaScript, and Swift/Apple platforms. Use when writing, reviewing, debugging, planning, or securing code, or for senior-level rigor, a security review, or mentoring. Mode triggers — REVIEW: (critique + refactor)…

bjgreenberg/senior-engineering-partner · 244 tokens

code

Use BEFORE generating, refactoring, reviewing, or debugging code. Trigger phrases include "write a function/script/class for X", "review this code/diff/PR", "refactor this", "debug this error", "is this implementation correct", "what's wrong with this code", "improve this code", "translate from X to Y", or any prompt…

ejentum/ejentum-mcp · 192 tokens

emergence

Analyzes what components create together that none intended — feedback loops, contention, timing bugs, and assumption collisions.

Kshitijpalsinghtomar/depth-skills · 26 tokens