praetorian-inc/public-workflows/adhering-to-dry
Claude Code and agent skill by praetorian-inc/public-workflows
- community
Checking that the SKILL.md file is still in the repository.
Use when writing new code or eliminating code duplication through DRY refactoring - applies Rule of Three and extract patterns
Install
npx vskill@latest install praetorian-inc/public-workflows/adhering-to-drySKILL.md
DRY Refactoring
Process
- Identify - Exact copies, similar patterns, parallel hierarchies, naming patterns (
data1/data2,handleXClick) - Analyze - Coupling, cohesion, frequency (Rule of Three: wait for 3+ occurrences), volatility
- Refactor - Choose technique below, extract incrementally, test after each step
Techniques
Extract Function - Same logic in multiple places
Extract Variable - Repeated expression
Parameterize - Code differs only in values
Extract Class - Related functions scattered
Polymorphism - Repeated switch/if-else
Strategy Pattern - Duplicated algorithm selection
Pull Up Method - Identical methods in subclasses
Detection
Code Smells: Numbered variables (data1, data2), parallel function names (handleXClick), near-identical code differing only in constants, repeated validation/error handling, parallel class structures, large switches in multiple places, repeated null checks, magic numbers
Rule of Three: Wait for 3+ occurrences before abstracting
When NOT to DRY
- Coincidental similarity - Different domains/business rules that happen to look alike (will diverge)
- Premature abstraction - Pattern isn't clear yet; early abstraction often guesses wrong
- Single use - Appears 1-2 times, unlikely to grow
- Test clarity - Readable test setup beats DRY
- Over-engineering - Don't abstract every 2-3 line similarity
Patterns
- Configuration over code - Data structures eliminate conditionals
- Template Method - Base defines skeleton, subclasses vary steps
- Dependency Injection - Parameterize dependencies
- Builder - Complex object construction
Best Practices
- Refactor after green tests
- One refactoring at a time
- Commit frequently
- Name for intent not implementation
- Consider performance
- Review abstractions with team
Related Techniques
- Balance DRY against YAGNI — don't abstract speculative features before they exist.
- Balance DRY against simplicity — avoid over-engineering; the simplest version that removes the duplication wins.
- Apply DRY during the refactor step after tests are green, so changes stay safe.
- Before writing new code, search the codebase for an existing implementation to reuse rather than duplicate.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/actions/stage-review-skills/allowlist/adhering-to-dry/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/praetorian-inc/public-workflows/adhering-to-dry)