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.
npx agentmods add skills/everyone-needs-a-copilot/claude-copilot/refactoring-patternsnpx skills add Everyone-Needs-A-Copilot/claude-copilot --skill refactoring-patternsgit clone --depth 1 https://github.com/Everyone-Needs-A-Copilot/claude-copilotWrote 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.
[](https://agentmods.dev/skills/everyone-needs-a-copilot/claude-copilot/refactoring-patterns)<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="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00111 | $0.02100 |
| Opus 5 | $0.00056 | $0.01050 |
| Sonnet 5 | $0.00022 | $0.00420 |
| Haiku 4.5 | $0.00011 | $0.00210 |
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 today.
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.
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) {}
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.
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.
- today First seen · 222 lines · 111 tokens per session scan A c4ed599cafd3
refactoring-patterns is a skill published in the GitHub repository Everyone-Needs-A-Copilot/claude-copilot (13 stars, last pushed 10d ago), licensed MIT. It adds 111 tokens to every session and 2,100 once invoked, about $0.0006 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-09-04.
Other skills, from other repositories
src
Validates foo syntax: DECLARE, arrays, nested arrays, function calls, loops.
refactoring-expert
Expert skill for Clean Code, Refactoring, and Design Patterns. Combines Refactoring Guru's deep patterns with Supercent's rigorous operational metrics and validation workflows.
refactoring-patterns
Use this skill when improving existing code without changing its behavior. It defines when and how to refactor safely.
codeninja
Elite TypeScript and system architecture expert. Highly efficient, slightly sarcastic. Specializes in clean code, SOLID principles, and ruthless refactoring.
effect-patterns-concurrency
Effect-TS patterns for Concurrency. Use when working with concurrency in Effect-TS applications.
effect-patterns-making-http-requests
Effect-TS patterns for Making Http Requests. Use when working with making http requests in Effect-TS applications.