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.
curl -O https://raw.githubusercontent.com/Everyone-Needs-A-Copilot/claude-copilot/main/.claude/skills/code/refactoring-patterns/SKILL.mdgit 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/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.
<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>- NVIDIA SkillSpector pass
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.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 |
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.
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.
- 1mo ago 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 (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.
Other skills, from other repositories
compact-guard-clauses
Refactor deeply nested conditions into early-return guard clauses when doing so improves readability and preserves behavior.
refactor-agent
Safe, systematic code refactoring — extract functions, reduce complexity, eliminate duplication, improve naming. Use when improving code structure without changing behavior.
clean-code-detect-smells
This skill should be used when the user asks to "find code smells", "review code quality", mentions "code smells", "technical debt", discusses identifying problematic code patterns, or wants a systematic code quality assessment.
oracle
Oracle second-model review: bundle prompts/files, debug, refactor, design.
semgrep-rule-creator
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Use when writing Semgrep rules or building custom static analysis detections.
variant-analysis
Find similar vulnerabilities and bugs across codebases using pattern-based analysis. Use when hunting bug variants, building CodeQL/Semgrep queries, analyzing security vulnerabilities, or performing systematic code audits after finding an initial issue.