aspiers/ai-config / .agents/skills/code-refactoring-dry
code-refactoring-dry
VerifiedEvaluate repeated code and consolidate duplication when a shared abstraction improves correctness or maintenance. Use after introducing similar logic or when repeated changes reveal a missing source of truth.
Refactoring Duplication
Remove harmful duplication without replacing clear local code with a forced abstraction.
Workflow
- Compare the repeated code and the reasons each copy exists.
- Decide whether the copies represent one concept that should change together or merely look similar today.
- If one concept exists, choose the smallest natural shared boundary in the repository: a function, data structure, type, module, or generated source.
- Refactor all relevant call sites while preserving behavior and useful local differences.
- Run focused tests and repository quality gates appropriate to the change.
Prefer an abstraction when it creates a real source of truth, prevents drift, or makes future changes safer. Keep duplication when sharing would couple independent concepts, obscure control flow, or add more indirection than value.
Do not broaden a focused request into a repository-wide deduplication project. Report nearby opportunities separately unless they are necessary for a sound refactor.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |