Workflow Refactoring

Remove Duplication

Workflow for identifying and eliminating duplicated code

refactoringdrydeduplication
CLAUDE.md

When removing duplicated code:

  1. Identify the duplicated code blocks. Are they truly identical, or just similar?
  2. If identical: extract the common code into a shared function or module.
  3. If similar: identify the differences. Parameterize the shared function to handle the variations.
  4. Replace each duplicate with a call to the shared function.
  5. Run the tests after each replacement to verify behavior is preserved.
  6. Don’t force it. If the code is similar but serves different purposes, duplication is acceptable — premature abstraction is worse than repetition.

Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.

get crystl