# Dry

> Refactors duplicated code by extracting helper methods, shared abstractions, or reusable structures, with automated testing and commits after each extraction.

- Skill: `sdiamante13/dry` (Agent Skill)
- Install (CLI): `npx skillmds@latest add sdiamante13/dry`
- Raw SKILL.md: https://api.skillmd.com/api/skills/sdiamante13/dry/raw
- Safety review: PASS (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools, Refactoring
- Tags: Code Duplication, Dry, Git Commit, Refactoring
- Author: SDiamante13 (https://skillmd.com/u/sdiamante13)
- Updated: 2026-08-22
- Page: https://skillmd.com/skills/sdiamante13/dry

---


# DRY Refactor

Ask the user for the file or directory to refactor. Support multiple files if a directory is provided.

## Process

Work through these steps in order, making a separate commit for each extraction:

1. **Extract simple helper methods** (strings, calculations, parsing)
   - Identify duplicated logic
   - Extract to focused method with clear name
   - Remove duplicated code immediately after extraction
   - Commit the extraction

2. **Extract complex methods with parameters**
   - Find similar code blocks with variations
   - Extract with parameters to handle variations
   - Remove duplicated code immediately after extraction
   - Commit the extraction

3. **Apply design patterns when beneficial**
   - Template Method, Strategy, etc. for structural duplication
   - Only when it improves readability/maintainability
   - Avoid over-engineering or premature abstraction
   - Remove duplicated code immediately after extraction
   - Commit the extraction

After EACH extraction:
- Run tests automatically
- If tests fail, revert the change immediately
- If tests pass and using IDE refactoring tool, commit: `. r <description>`
- If tests pass but manual refactoring, commit: `^ r <description>`
- Remove the now-duplicated code in the same commit

## Output

- If no duplication found, report "No duplication found"
- Otherwise provide brief summary at end (e.g., "Extracted 4 methods, removed 3 duplicated blocks")

## Commit Format

Use Arlo's Commit Notation (ACN):
- `. r extract saveToDatabase method` - IDE refactoring or provably safe
- `^ r extract validation logic` - Manual refactoring validated by tests

