| name | code-dedup |
| description | Searches for duplicate code, duplicate tests, and dead code, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates", "remove dead code", "DRY up", or "code dedup". Requires test coverage — refuses to touch untested code. |
Code Dedup
Carefully search for duplicate code, duplicate tests, and dead code across the Diffr repo. Merge duplicates and delete dead code — but only when test coverage proves the change is safe.
Prerequisites — hard gate
Before touching ANY code, verify these conditions. If any fail, stop and report why.
- Run
make test — all tests must pass. If tests fail, stop. Do not dedup a broken codebase.
- Run
make test — tests are fail-fast AND enforce the coverage threshold from coverage-thresholds.json. If anything fails, stop and fix it before deduping.
- Verify the project uses static typing. TypeScript with
tsconfig.json "strict": true is required (which Diffr enforces — see CLAUDE.md). If strict is off, STOP and refuse.
Steps
Copy this checklist and track progress:
Dedup Progress:
- [ ] Step 1: Prerequisites passed (tests green, coverage met, strict TS)
- [ ] Step 2: Dead code scan complete
- [ ] Step 3: Duplicate code scan complete
- [ ] Step 4: Duplicate test scan complete
- [ ] Step 5: Changes applied
- [ ] Step 6: Verification passed (tests green, coverage stable)
Step 1 — Inventory test coverage
Before deciding what to touch, understand what is tested.
- Run
make test to confirm green baseline. make test is fail-fast AND enforces the coverage threshold from coverage-thresholds.json (REPO-STANDARDS-SPEC [TEST-RULES], [COVERAGE-THRESHOLDS-JSON]). It exits non-zero on any test failure OR coverage shortfall.