react-dedup

Analyzes React components for duplicate code and refactors them into reusable shared components.

Updated Jan 4, 2026
One-click install
npx skills add https://github.com/threadedstack/threadedstack --skill react-dedup-threadedstack
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: react-dedup
Source: https://github.com/threadedstack/threadedstack/tree/main/.claude/skills/react-dedup
Command: npx skills add https://github.com/threadedstack/threadedstack --skill react-dedup-threadedstack

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React codebases accumulate duplicated JSX patterns, repeated hook logic, and redundant components as features grow, making maintenance harder and increasing inconsistency across the UI. ## Core Features & Use Cases - Duplication Discovery: Scans .tsx/.ts files to find repeated JSX structures, hook call patterns, inline styles, and conditional rendering blocks. - Reuse-First Refactoring: Cross-references findings against existing shared component libraries before creating anything new, following a strict reuse-extend-extract hierarchy. - Structured Analysis Report: Presents a table-based report of components to reuse, extract, or remove, and waits for approval before executing changes. - Use Case: After building several admin pages with similar card grids, drawers, and empty states, run this Skill to consolidate them into shared components like a generic ItemCard or EmptyState. ## Quick Start Analyze the components in my admin app directory for duplication and refactor them into reusable shared components.

Frequently Asked Questions about react-dedup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find and remove duplicate code in React components?▼

Scan all .tsx and .ts files in the target directory for repeated JSX structures, hook call sequences, and style objects. Then cross-reference each pattern against existing shared components and either reuse, extend, or extract components based on how often the pattern repeats.

When should I extract a shared component in React?▼

Extract a new shared component only when a pattern repeats three or more times and no existing component covers it. Patterns used once or twice, or components that look similar but serve different purposes, should be left alone to avoid premature abstraction.

What counts as code duplication in React?▼

Duplication includes identical JSX layouts with different data, the same hook call sequences in multiple components, repeated style objects, and repeated loading/error/empty conditional rendering. Sharing a common UI primitive like a Box component does not count as duplication.

Does this refactoring approach work with TypeScript React projects?▼

Yes, the workflow is designed for TypeScript React codebases using .tsx files. It includes updating type definitions, maintaining barrel exports, and running TypeScript checks and tests after refactoring to confirm no regressions.

When should I not refactor duplicated React code?▼

Avoid refactoring when two components look similar now but serve fundamentally different purposes and will diverge, when the duplication is only a simple one-liner, or when the code is stable and working with no real repetition. Premature abstraction creates maintenance burden.