dry-refactoring
Code-Duplikation durch DRY-Refaktorierung eliminieren
Code-Duplikation führt zu Wartungsproblemen und inkonsistentem Verhalten. Diese Anleitung führt Sie durch einen systematischen 4-Schritte-Prozess zum Identifizieren, Abstrahieren, Ersetzen und Überprüfen von Refaktorisierungsänderungen, die Wiederholungen eliminieren und die Codequalität verbessern.
스킬 ZIP 다운로드
Claude에서 업로드
설정 → 기능 → 스킬 → 스킬 업로드로 이동
토글을 켜고 사용 시작
테스트해 보기
"dry-refactoring" 사용 중입니다. I have these two functions that look almost identical. Help me refactor them.
예상 결과:
- I can see the duplication between these functions. Let me apply the DRY workflow:
- Step 1 - Identify: Both functions share the same structure for calculating discounts above a threshold. The only difference is the variable names.
- Step 2 - Abstract: Create a single function that takes the amount and threshold as parameters.
- Step 3 - Replace: Update both call sites to use the new abstraction.
- Step 4 - Verify: Let me help you write tests to confirm the behavior remains identical.
"dry-refactoring" 사용 중입니다. My code has the same magic number 0.08 repeated in multiple places for tax calculations.
예상 결과:
- I can help you eliminate these magic numbers. Here is the approach:
- Step 1 - Identify: The value 0.08 appears in calculate_tax_1, calculate_tax_2, and calculate_total.
- Step 2 - Abstract: Create a constant TAX_RATE = 0.08 in a central location.
- Step 3 - Replace: Replace all occurrences with TAX_RATE.
- Step 4 - Verify: Run tests to confirm tax calculations remain correct.
"dry-refactoring" 사용 중입니다. Help me refactor my validation logic that is repeated across three different service files.
예상 결과:
- I see you have similar validation patterns across services. Let me guide you through DRY refactoring:
- Step 1 - Identify: All three services perform email validation, password validation, and role checks.
- Step 2 - Abstract: Create a validation utility module with reusable functions.
- Step 3 - Replace: Import and use the utility functions in each service.
- Step 4 - Verify: Ensure all validation behavior is preserved and add comprehensive tests.
보안 감사
안전Pure documentation skill containing only guidance and code examples for DRY refactoring. No executable code, no network calls, no file access, and no system commands. All 92 static findings are false positives caused by the analyzer misinterpreting markdown documentation patterns as security issues.
위험 요인
🌐 네트워크 접근 (2)
⚙️ 외부 명령어 (62)
품질 점수
만들 수 있는 것
Copy-Paste-Code bereinigen
Identifizieren und eliminieren Sie doppelte Codeblöcke, die in Ihrer Codebasis verstreut sind, mit dem systematischen 4-Schritte-Workflow.
Refaktorisierungs-Reviews standardisieren
Wenden Sie konsistente Kriterien an, wenn Sie Refaktorisierungsänderungen auf die Einhaltung der DRY-Prinzipien überprüfen.
Team-Refaktorisierungsstandards etablieren
Definieren Sie klare Richtlinien für Ihr Team, um Code-Duplikation in Legacy-Systemen systematisch zu adressieren.
이 프롬프트를 사용해 보세요
Help me identify duplicate code in my function that calculates prices. Here is my code: [paste code]
I have three similar validation functions. Help me extract the common logic into a single reusable function following the DRY workflow.
My codebase has magic numbers like 0.08 for tax rates appearing in many places. Guide me through replacing them with named constants.
Guide me through a complete DRY refactoring of my order calculation module. I want to identify all duplication, abstract it properly, and verify the changes.
모범 사례
- Wenden Sie die Regel der Zweimaligkeit an: Refaktorisieren Sie, wenn Sie ähnlichen Code zum zweiten Mal schreiben.
- Verwenden Sie progressive Refaktorisierung: Nehmen Sie kleine, testbare Änderungen vor, anstatt große Neuschreibungen.
- Schreiben oder aktualisieren Sie immer Tests vor der Refaktorisierung, um sicherzustellen, dass das Verhalten erhalten bleibt.
피하기
- Über-Abstraktion: Erstellen generischer Lösungen, bevor das wahre Muster verstanden ist.
- Partielle Ersetzung: Hinterlassen von doppeltem Code, während anderer bereinigt wird.
- Leistung ignorieren: Einführung unnötiger Funktionsaufruf-Overhead durch Abstraktion.