with one click
refactoring-patterns
Systematic refactoring techniques, code smell elimination, pattern extraction, and legacy modernization
Menu
Systematic refactoring techniques, code smell elimination, pattern extraction, and legacy modernization
| name | refactoring-patterns |
| description | Systematic refactoring techniques, code smell elimination, pattern extraction, and legacy modernization |
| metadata | {"author":"cosmicstack-labs","version":"1.0.0","category":"development","tags":["refactoring","code-quality","patterns","legacy","modernization"]} |
Systematically improve code without changing its behavior.
When: A method does multiple things or is too long. How: Find a cohesive block → extract to new method → call it.
// 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;
}
When: Switch/if-else chains based on type grow too long.
// Before
function calculateShipping(order) {
if (order.type === 'standard') return order.weight * 0.5;
if (order.type === 'express') return order.weight * 1.5 + 5;
if (order.type === 'overnight') return order.weight * 3 + 15;
}
// After
class StandardShipping {
calculate(weight) { return weight * 0.5; }
}
class ExpressShipping {
calculate(weight) { return weight * 1.5 + 5; }
}
| Refactoring | When | Risk |
|---|---|---|
| Rename Variable | Unclear name | Low |
| Extract Method | Long function | Low |
| Replace Magic Literal | Hard-coded values | Low |
| Introduce Parameter Object | Many parameters | Medium |
| Replace Temp with Query | Reused expressions | Low |
| Decompose Conditional | Complex condition | Medium |
| Extract Class | Class doing too much | Medium-High |
Generate a 15-30 second scrolling video tour of any GitHub repository page with ElevenLabs AI narration and word-by-word subtitle sync. Captures a full-page mobile-viewport screenshot, scrolls top-to-bottom with GSAP, and burns synced subtitles onto the final MP4 using HyperFrames CLI.
Lightweight personal knowledge base — markdown + YAML frontmatter structured notes with full-text search and cross-referencing for AI agents
Automated daily tech briefing — multi-source collection → knowledge-base deduplication → AI summarization → TTS speech synthesis, generating MP3 audio briefings
Generate 1080x1920 Instagram Reels video promos for GitHub repositories using HyperFrames. 7-beat structure with fullscreen scrolling phone mockup, GSAP animations, dark GitHub theme, repo stats, ElevenLabs AI voiceover synced to scroll duration, and follow CTA. Depends on the website-to-hyperframes skill for HyperFrames composition patterns.
Design safe X/Twitter automation workflows for tweet search, reply reads, monitoring, posting, and agent-operated social media actions
Assess worker classification and compliance risk for temporary event staffing in the US and Canada. Use when a user asks about W-2 vs 1099 event workers, misclassification penalties, joint-employer liability, COI requirements, or wage/hour rules for event staff. Includes live state-by-state lookups via the TempGuru MCP server.