codebase-cleanup-refactor-clean
重構程式碼為乾淨的 SOLID 架構
深受技術債、重複程式碼和難以維護的系統所苦?此技能應用經驗證的重構模式和 SOLID 原則,將混亂的程式碼庫轉換為乾淨、模組化、可測試的架構。
Télécharger le ZIP du skill
Importer dans Claude
Allez dans Paramètres → Capacités → Skills → Importer un skill
Activez et commencez à utiliser
Tester
Utilisation de "codebase-cleanup-refactor-clean". Refactor this 200-line OrderProcessor class that handles validation, payment, shipping, and email notifications all in one method.
Résultat attendu:
Separate into 5 focused classes: OrderValidator, PaymentService, ShippingCalculator, EmailNotificationService, and OrderOrchestrator. Reduced method complexity from 45 to 8 per method. Added 18 unit tests with 92% coverage.
Utilisation de "codebase-cleanup-refactor-clean". Our codebase has 30% duplication, especially in error handling and database queries across services.
Résultat attendu:
Extract common error handling into BaseExceptionHandler with 6 custom exception types. Create GenericRepository with CRUD operations. Eliminate 28% of duplication, reduce codebase by 1,400 lines while maintaining functionality.
Audit de sécurité
SûrAll 89 static analysis findings are false positives. The skill contains only markdown documentation with code examples for educational purposes. Detected patterns (backticks, file operations, network references) are part of fenced code blocks demonstrating refactoring concepts in Python, TypeScript, Go, and Java. No executable code, prompt injection attempts, or malicious patterns found. Safe for publication.
Score de qualité
Ce que vous pouvez construire
傳統單體現代化
將 500 行的單體函式轉換為乾淨的模組化架構,分離驗證、業務邏輯和資料存取的職責。
技術債清理衝刺
系統性地消除程式碼重複、將魔法數字提取為常數,並在高風險、頻繁修改的模組中應用 SOLID 原則。
功能前架構審查
在主要功能開發前評估程式碼庫品質,識別可降低實作風險並改善可擴展性的重構機會。
Essayez ces prompts
Review the current codebase for code smells and quick wins. Identify magic numbers, improve variable names, remove dead code, and extract any duplicate code into reusable functions.
Analyze this code for SOLID violations. Refactor to follow Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion principles. Show before/after comparisons.
Break down this monolithic system into clean layers: domain entities, repositories, services, and validators. Apply dependency injection and separate concerns completely. Generate comprehensive tests.
Audit the entire codebase and prioritize technical debt by business impact and risk. Provide a refactoring roadmap with effort estimates, ROI analysis, and recommended sprint scheduling.
Bonnes pratiques
- 在提出變更前務必先閱讀現有程式碼,以理解上下文和業務邏輯
- 從高影響、低 effort 的重構開始,例如提取魔法數字和改善命名
- 在重構前生成全面的測試以確保行為保留
- 將大型重構拆解為小型、可審查的提交,可獨立測試
Éviter
- 避免在不了解現有需求的情況下從頭重寫整個模組
- 不要隨處應用設計模式——僅在它們解決實際問題時使用
- 切勿在沒有測試或驗證功能等效機制的情況下重構
- 不要在單一重構迭代中變更多個無關的職責