component-reuse-guard

Extract reusable components from duplicated JSX structures and shared logic.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/muddyrain/valley-mas --skill component-reuse-guard
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-reuse-guard
Source: https://github.com/muddyrain/valley-mas/tree/main/.codex/skills/component-reuse-guard
Command: npx skills add https://github.com/muddyrain/valley-mas --skill component-reuse-guard

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

自动判断当前改动中是否存在可提取的公用组件或可复用逻辑,避免在多处重复编写相同 JSX 与 handlers,从而降低维护成本。

Core Features & Use Cases

  • 识别同一段 JSX 结构(如弹窗、表单、卡片)在多处的重复出现,以及相同的状态和处理逻辑。
  • 提供提取指导与清理步骤,包含组件放置位置、接口设计与后续替换流程。

Quick Start

When two or more files share an almost identical JSX structure or logic, extract it as a public component and migrate all usages to the new component.

Frequently Asked Questions about component-reuse-guard

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

FAQPage Schema
How do I identify and extract reusable React components from duplicated JSX structures?

To extract reusable React components, identify duplicated JSX structures and shared state or handler logic across multiple files, then consolidate them into a shared component with a defined interface to reduce maintenance costs. This process includes specifying extraction rules and post-migration cleanup.

What is the best way to refactor duplicated frontend UI patterns like modals and forms?

Refactoring duplicated frontend UI patterns involves detecting identical structures like modals or forms appearing in multiple files and migrating them into a shared component. This ensures builds remain stable and original behavior is preserved through systematic usage updates.

When do I need to extract shared components from my frontend codebase?

You need to extract shared components when two or more files share an almost identical JSX structure or identical state and handler logic. Extracting these duplicated patterns as a public component prevents repetitive code and lowers long-term maintenance overhead.

How do I ensure stable builds when refactoring duplicated UI architecture into shared components?

To ensure stable builds during UI architecture refactoring, specify clear component interfaces, follow structured extraction rules, and perform post-migration cleanup. Replacing all previous usages with the new shared component preserves the original behavior throughout the codebase.

Can I use automated extraction rules for refactoring common state and handler logic in React?

Yes, applying automated extraction rules guides the refactoring of common state and handler logic into public components. This process systematically defines the component placement, interface design, and replacement workflow to successfully remove code duplication.