Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add vuralserhat86/antigravity-agentic-skills --skill "refactoring_strategies"
Install specific skill from multi-skill repository
# Description
Safe refactoring süreci - test-first, incremental changes ve güvenlik ağı.
# SKILL.md
name: refactoring_strategies
router_kit: FullStackKit
description: Safe refactoring süreci - test-first, incremental changes ve güvenlik ağı.
metadata:
skillport:
category: quality
tags: [architecture, automation, best practices, clean code, coding, collaboration, compliance, debugging, design patterns, development, documentation, efficiency, git, optimization, productivity, programming, project management, quality assurance, refactoring, refactoring strategies, software engineering, standards, testing, utilities, version control, workflow] - refactoring-patterns
🛡️ Refactoring Strategies
Safe refactoring süreci ve incremental değişiklikler.
⏰ Ne Zaman Refactor?
| Sinyal | Aksiyon |
|---|---|
| Code Smell | Refactor et |
| Before feature | Zemin hazırla |
| After bug fix | Kodu iyileştir |
❌ Ne Zaman YAPMA
- Deadline çok yakın
- Test coverage düşük
- Sistemi anlamadan
🔒 Güvenlik Ağı
// Önce mevcut davranışı test et
describe('calculateTotal', () => {
test('single item', () => {
expect(calculateTotal([{ price: 100, qty: 1 }])).toBe(100);
});
test('multiple items', () => {
expect(calculateTotal([
{ price: 100, qty: 2 },
{ price: 50, qty: 1 }
])).toBe(250);
});
test('empty array', () => {
expect(calculateTotal([])).toBe(0);
});
});
📊 Incremental Strategy
- Test yaz → Mevcut davranışı belgele
- Küçük değişiklik → Tek bir şeyi değiştir
- Test çalıştır → Hala geçiyor mu?
- Commit → Küçük, atomik commit
- Tekrarla
✅ Checklist
- [ ] Testler geçiyor
- [ ] Davranış değişmedi
- [ ] Küçük commit'ler
- [ ] Feature ile karıştırma
Refactoring Strategies v1.1 - Enhanced
🔄 Workflow
Kaynak: Working Effectively with Legacy Code & Refactoring to Patterns
Aşama 1: Safety Net (Test First)
- [ ] Characterization Tests: Kodun "ne yapması gerektiğini" değil, "ne yaptığını" doğrulayan testler yaz.
- [ ] Golden Master: Çıktının değişmediğini garanti etmek için büyük ölçekli snapshot testleri al.
- [ ] Coverage: Refactor edilecek bölgenin coverage'ını %100'e getirmeden dokunma.
Aşama 2: Strategic Patterns
- [ ] Strangler Fig: Eski sistemi bir anda değiştirmek yerine, yeni özellikleri "boğarak" (çevreleyerek) yavaş yavaş yerine geçir.
- [ ] Parallel Change: Eski ve yeni kodu bir süre paralel çalıştır (Feature Flag ile), emin olunca eskiyi sil.
- [ ] Branch by Abstraction: Kodun arasına bir interface (API) katmanı koy, arkasındaki implementasyonu değiştir.
Aşama 3: Lifecycle Management
- [ ] Deprecation: Eski API'leri
@deprecatedolarak işaretle ve loglara uyarı bas. - [ ] Monitoring: Refactor sonrası error rate ve latency'yi izle.
- [ ] Kill Switch: Feature Flag ile eski koda saniyeler içinde dönebilme imkanı sağla.
Kontrol Noktaları
| Aşama | Doğrulama |
|---|---|
| 1 | Test paketi 2 dakikanın altında çalışıyor mu? (Hızlı feedback). |
| 2 | Veritabanı şeması değişiyor mu? (Migration planı var mı?). |
| 3 | Rollback planı test edildi mi? |
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.