Agent skill · Code Review & Quality

refactoring-patterns

Systematic refactoring techniques, code smell elimination, pattern extraction, and legacy modernization

Cosmic Stack3,294★ · 2 repos on radarProfile →
claude-codeMIT
Install
npx skills add cosmicstack-labs/mercury-agent-skills --skill refactoring-patterns --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 3 KB
Bundled scripts: none
Version: 1.0.0
Declared author: cosmicstack-labs
Path: categories/development/refactoring-patterns/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 364
Language: JavaScript
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Refactoring Patterns Systematically improve code without changing its behavior. ## The Refactoring Workflow 1. **Identify** a code smell or pain point 2. **Ensure** you have tests (write them first if not) 3. **Apply** one refactoring at a time 4. **Test** after each change (green = continue, red = revert) 5. **Commit** — small, focused, descriptive 6. **Repeat** ## Extract Method **When**: A method does multiple things or is too long. **How**: Find a cohesive block → extract to new method → call it. ```javascript // Before function processOrder(order) { const total = order.items.reduce((sum, i) => sum + i.price, 0); const tax = total * 0.08; const discount = order.coupon ? total * 0.1 : 0; return total + tax - discount; } // After function processOrder(order) { const subtotal = calculateSubtotal(order); const tax = calculateTax(subtotal); const discount = calculateDiscount(order, subtotal); return subtotal + tax - discount; } ``` ## Replace Conditional with Polymorphism **When**: Switch/if-else chains based on type grow too long. ```javascript // Before function calculateShipping(order) { if (order.type === 'standard') return order.weight * 0.5; if (order.type === 'express') ret

What's inside
Steps it walks through
  1. The Refactoring Workflow
  2. Extract Method
  3. Replace Conditional with Polymorphism
  4. Legacy Code Strategy
  5. Common Refactorings
More from mercury-agent-skills
All skills →
About this skill
What does the refactoring-patterns skill do?

Systematic refactoring techniques, code smell elimination, pattern extraction, and legacy modernization

How do I install it?

Run `npx skills add cosmicstack-labs/mercury-agent-skills --skill refactoring-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From cosmicstack-labs/mercury-agent-skills, a repository with 364 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going