shared-module-extraction

Extract duplicated React component internals into shared modules verified by visual regression tests.

1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/VilnaCRM-Org/claude-plugins --skill shared-module-extraction-vilnacrm-org
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: shared-module-extraction
Source: https://github.com/VilnaCRM-Org/claude-plugins/tree/main/plugins/react-frontend-sdlc/skills/shared-module-extraction
Command: npx skills add https://github.com/VilnaCRM-Org/claude-plugins --skill shared-module-extraction-vilnacrm-org

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Duplication gates like jscpd or qlty flag cloned component code, but extracting the shared block risks silently changing what every consumer renders. This Skill guides the extraction of duplicated React component internals into a shared module and proves the refactor is safe by requiring a full visual regression suite run with zero rewritten baselines. ## Core Features & Use Cases - Guided extraction workflow: Confirm the clone is real, extract into the shared internals location under the source root, export through the barrel, and migrate every consumer. - Visual regression proof: Run the full visual suite and require zero rewritten baselines, so the rendered DOM is byte-identical for all consumers. - Repository-shape awareness: Adapts to React SPA, Next.js, and component-library shapes, with fallback steps when no visual suite or duplication gate exists. - Use Case: A jscpd failure flags two icon components differing only in path and viewBox. Extract the shared markup into the internals barrel, migrate all consumers, run the visual suite, and confirm no baseline changed before re-running the duplication gate. ## Quick Start Extract the duplicated component code flagged by the duplication gate into a shared module and verify the refactor with the full visual test suite.

Frequently Asked Questions about shared-module-extraction

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

FAQPage Schema
How do I fix a jscpd duplication failure in React components?▼

Extract the duplicated block into a shared internals module under the source root, export it through the barrel, and replace every consumer. Then run the full visual suite and re-run the duplication gate to confirm the clone is gone.

How do I verify a component refactor did not change rendering?▼

Run the full visual regression suite, not just the specs for the touched components, and require zero rewritten baselines. An unchanged baseline set means the rendered DOM is byte-identical for every consumer.

When should I not extract duplicated component code?▼

Skip extraction when the similarity is incidental and below the gate's token threshold, since abstracting it produces a worse shape than the duplication. Also avoid extracting behaviour along with markup, which creates flag arguments per caller.

What if my repository has no visual regression tests?▼

When the visual testing capability is unavailable, skip the visual proof steps with a recorded note and substitute the closest render evidence, such as component snapshot tests or a manual pass over every consumer.

Why does the duplication gate stay red after extraction?▼

The gate stays red when a consumer is left un-migrated or the clone was relocated rather than removed. Replace every consumer, not just the two the gate named, then re-run the duplication gate to confirm.