refactoring_patterns
FreeNo executable scriptsNot checkedCommon refactoring patterns - Extract, Rename, Move ve code smell çözümleri.
by vuralserhat86★ 43 GitHub starsAbout this skill
🔄 Refactoring Patterns
Common refactoring patterns ve code smell çözümleri.
🎯 Altın Kural
Davranışı DEĞİŞTİRME, sadece yapıyı iyileştir
Before: Input X → [Code A] → Output Y
After: Input X → [Code B] → Output Y (AYNI!)
🔍 Code Smells
| Smell | Çözüm |
|---|---|
| Long Method | Extract Method |
| Large Class | Extract Class |
| Duplicate Code | Extract + Reuse |
| Long Parameter List | Parameter Object |
| Feature Envy | Move Method |
| Data Clumps | Extract Class |
📦 Extract Method
// ❌ Before
function processOrder(order) {
// 20 lines of validation
// 30 lines of calculation
// 15 lines of formatting
}
// ✅ After
function processOrder(order) {
validateOrder(order);
const total = calculateTotal(order);
return formatOutput(total);
}
🔄 Replace Conditional with Polymorphism
// ❌ Before
function getPrice(type) {
if (type === 'premium') return 100;
if (type === 'basic') return 50;
return 30;
}
// ✅ After
const pricing = { premium: 100, basic: 50, free: 30 };
const getPrice = (type) => pricing[type] ?? 30;
Refactoring Patterns v1.1 - Enhanced
🔄 Workflow
Kaynak: Refactoring.guru & Martin Fowler - Refactoring
Aşama 1: Preparation (Safety First)
- Red-Green-Refactor: Testin var mı? Yoksa önce test yaz ("Characterization Tests"), sonra refactor et.
- Small Steps: Değişiklikleri atomik commitler halinde yap. Her adımda testleri çalıştır.
- Backup: VCS (Git) üzerinde temiz bir dalda çalış.
Aşama 2: Applying Patterns
- Simplification: Karmaşık koşulları
Decompose ConditionalveyaReplace Nested Conditional with Guard Clausesile basitleştir. - Abstraction:
Extract MethodveExtract Classile sorumlulukları (SRP) ayır.Primitive Obsessionvarsa Value Object'e çevir. - Modernization:
var->const/let,for->map/filter, Callback -> Async/Await dönüşümlerini uygula (Dil özelliklerini kullan).
Aşama 3: Verification & Cleanup
- Regression Testing: Mevcut fonksiyonların bozulmadığını doğrula.
- Dead Code: Kullanılmayan kodları (Dead Code) acımasızca sil. Yorum satırına alma, sil (Git geçmişinde var zaten).
- Naming: Değişken ve fonksiyon isimlerini, kodun ne yaptığını değil "neden" yaptığını anlatacak şekilde güncelle.
Kontrol Noktaları
| Aşama | Doğrulama |
|---|---|
| 1 | Refactoring sırasında yeni özellik eklendi mi? (KESİNLİKLE HAYIR. İki şapka kuralı: Ya Refactor yap ya Feature ekle). |
| 2 | Kodun okunabilirliği arttı mı? (Cognitive Complexity düştü mü?). |
| 3 | Test kapsamı (Coverage) korundu mu? |
Install refactoring_patterns in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the refactoring_patterns skill do?
Common refactoring patterns - Extract, Rename, Move ve code smell çözümleri.
How do I install the refactoring_patterns skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the refactoring_patterns skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic