component-refactoring

Refactor high-complexity React components in the Dify frontend.

785|169|Updated Aug 8, 2024
One-click install
npx skills add https://github.com/Ohh-889/skyroc-admin --skill component-refactoring-ohh-889
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-refactoring
Source: https://github.com/Ohh-889/skyroc-admin/tree/main/.agents/skills/component-refactoring
Command: npx skills add https://github.com/Ohh-889/skyroc-admin --skill component-refactoring-ohh-889

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Refactor high-complexity React components in the Dify frontend to improve maintainability, readability, and testability by enforcing modularization and clean separation of concerns across large codebases.

Core Features & Use Cases

  • Analyze component complexity and identify refactoring opportunities such as extracting hooks, sub-components, and API/data logic.
  • Provide a guided, incremental workflow with quality checks (lint, type-check, tests) after each extraction.
  • Enforce Dify-style patterns for component organization, modal management, and form handling across web apps.

Quick Start

From the web directory, run pnpm refactor-component <path> to generate a refactoring prompt and follow the guided plan.

Frequently Asked Questions about component-refactoring

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

FAQPage Schema
How do I refactor high-complexity React components to improve maintainability?

Refactor high-complexity React components by applying structured modularization workflows that extract custom hooks, sub-components, and API logic. This enforces clean separation of concerns, improving readability and testability across large frontend codebases.

When do I need to extract custom hooks and sub-components from a React frontend?

Extract custom hooks and sub-components when a React frontend module exceeds complexity or line-count thresholds. This modularization separates data logic and UI rendering, making the codebase easier to maintain and test.

What is the best way to manage modal and form logic across large React web apps?

Manage modal and form logic by enforcing consistent component organization patterns across web apps. Extracting modal management and form handling into dedicated sub-components ensures clean separation of concerns and improved maintainability.

How do I ensure code quality during an incremental React refactoring workflow?

Ensure code quality during incremental React refactoring by running lint, type-check, and test validations after each extraction step. This structured workflow catches issues early while progressively modularizing the component.

Can I use this refactoring workflow for any React component in my web directory?

This refactoring workflow targets high-complexity React components that exceed specific complexity or line-count thresholds. It applies to web modules requiring extracted hooks, sub-components, and API logic for better separation of concerns.

Why does separating API and data logic improve React component testability?

Separating API and data logic improves React component testability by isolating data-fetching and state management into custom hooks. This allows UI sub-components to be tested independently, enforcing clean architecture and maintainability.