claude-copilot: Skill for Claude Code

.claude/skills/code/refactoring-patterns/SKILL.md

refactoring-patterns is a skill for Claude Code from Everyone-Needs-A-Copilot/claude-copilot. It costs 111 tokens per session (2,100 once invoked), scanned A, original, MIT.

A refactoring guide for finding code smells and choosing safe ways to restructure existing code without changing what it does.

In plain words
What is it for?
Use it to assess long functions, deep nesting, large files, excessive parameters, and other design problems, then apply techniques such as extracting, moving, inlining, or renaming code.
Why use it?
It helps identify hard-to-maintain code before changes make it riskier, using tests as a check against accidental behaviour changes.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: reads .claude/ paths.

This is Everyone-Needs-A-Copilot/claude-copilot's own configuration. It tells Claude Code how to work on claude-copilot itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-copilot configures →

Part of the claude-copilot plugin — 73 skills, 18 commands, 16 agents, 6 hooks shipped together

Reuse

Borrowing it

Nothing to install: this file belongs to Everyone-Needs-A-Copilot/claude-copilot. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Everyone-Needs-A-Copilot/claude-copilot/main/.claude/skills/code/refactoring-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/Everyone-Needs-A-Copilot/claude-copilot

Made for: Claude Code.

Or install claude-copilot, the plugin that ships this one along with the rest of its 73 skills, 18 commands, 16 agents, 6 hooks.

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/everyone-needs-a-copilot/claude-copilot/refactoring-patterns/github.svg)](https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/refactoring-patterns)
Your own site
<a href="https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/refactoring-patterns"><img src="https://agentmods.dev/badge/skills/everyone-needs-a-copilot/claude-copilot/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/everyone-needs-a-copilot/claude-copilot/refactoring-patterns"><img src="https://agentmods.dev/badge/skills/everyone-needs-a-copilot/claude-copilot/refactoring-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 111 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,100 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.00111 $0.02100
Opus 5.5 $0.00044 $0.00840
Sonnet 5.5 $0.00022 $0.00420
Haiku 4.5 $0.00011 $0.00210

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

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/refactor_metrics.py, scripts/test_refactor_metrics.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

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

How it starts

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

Refactoring Patterns

Code smell detection, refactoring triggers, and safe transformation patterns for improving existing code without changing behaviour.

refactor_metrics.py detects deterministic complexity signals (long functions, deep nesting, etc.). The prose sections below cover judgment-level smells that the script cannot evaluate (Feature Envy, Primitive Obsession, etc.). Run the script first to get a structural baseline; apply judgment from the prose sections to interpret findings in context.

Purpose

  • Identify code smells systematically before refactoring
  • Apply the right refactoring technique for each smell
  • Refactor safely with tests as the safety net
  • Avoid common refactoring anti-patterns that create new problems

Code Smell Catalog

Smell Detection Signal Refactoring Technique
Long Method Method body > 20 lines Extract Method
Feature Envy Method uses another class's data more than its own Move Method to the class it envies
Shotgun Surgery One change requires touching many unrelated classes Move Field/Method to consolidate responsibility
Long Parameter List Function signature has > 3 parameters Introduce Parameter Object
Primitive Obsession Using string, number, boolean for domain concepts (e.g., email, money, status) Replace with Value Object
Data Clump Same group of fields appears together across multiple classes or function signatures Extract Class
Divergent Change One class is changed for multiple unrelated reasons Extract Class per single responsibility
Middle Man Class does nothing but delegate every method call to another Remove Middle Man or Inline Delegation

Detection Examples

// SMELL: Long Parameter List (>3 params)
function createOrder(userId: string, productId: string, quantity: number, discount: number, shippingAddress: string) {}

// BETTER: Parameter Object
interface OrderRequest {
  userId: string;
  productId: string;
  quantity: number;
  discount: number;
  shippingAddress: string;
}
function createOrder(request: OrderRequest) {}

// SMELL: Primitive Obsession — email as raw string
function sendWelcome(email: string) {
  if (!email.includes('@')) throw new Error('invalid');
}

// BETTER: Value Object with self-validation
class Email {
  constructor(private readonly value: string) {
    if (!value.includes('@')) throw new Error('Invalid email');
  }
  toString() { return this.value; }
}
function sendWelcome(email: Email) {}

Read the full file on GitHub · 222 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. 1mo ago First seen · 222 lines · 111 tokens per session scan A c4ed599cafd3

Subscribe to this mod's changes

refactoring-patterns is a skill published in the GitHub repository Everyone-Needs-A-Copilot/claude-copilot (14 stars, last pushed yesterday), licensed MIT. It adds 111 tokens to every session and 2,100 once invoked, about $0.0004 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-09-04.