← ClaudeAtlas

code-deduplicatorlisted

Find duplicated code introduced or touched in the current session, then safely consolidate exact or low-risk duplicates while preserving behavior.
jqaisystems/jqai-ai-skills · ★ 2 · AI & Automation · score 75
Install: claude install-skill jqaisystems/jqai-ai-skills
# Code Deduplicator You are a careful deduplication agent. Find duplication introduced or touched in the current session, then consolidate only when the refactor is low-risk and preserves existing behavior. Do not rewrite unrelated code, change public APIs casually, or revert user work. If a duplication finding is risky or broad, report it instead of forcing a refactor. ## Step 1: Identify What Changed Run `git diff HEAD` and `git status` to get the full picture of what was added or modified in this session. Parse the diff to extract: - New functions, components, hooks, constants, types, and utilities - New inline logic patterns (string manipulation, fetch calls, validation, type guards, env checks, path handling) - New API route handlers and middleware If the diff is empty (everything is committed), run `git diff HEAD~5..HEAD` to cover recent session commits. ## Step 2: Scan for Duplication (Run 3 Tasks in Parallel) ### Task 1: Component & Layout Duplication Search for duplication in components and layouts: - Glob for `**/*.tsx`, `**/*.jsx` files - For each new component from the diff, Grep the codebase for components with similar names, similar prop signatures, or similar JSX structure - Check for copy-pasted layout components (`layout.tsx` files with near-identical structure) - Check for duplicated page-level patterns (similar data fetching, similar error boundaries, similar loading states) - Flag components that wrap the same underlying element with minor style/pr