component-refactoring

Refactor high-complexity Langflow React components into modular units.

153k|9.8k|Updated Feb 8, 2023
One-click install
npx skills add https://github.com/langflow-ai/langflow --skill component-refactoring-langflow-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-refactoring
Source: https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring
Command: npx skills add https://github.com/langflow-ai/langflow --skill component-refactoring-langflow-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Refactor high-complexity Langflow frontend React components to reduce cognitive load and improve maintainability. Targets components with complexity > 50 or lineCount > 300, especially when the user requests code splitting, hook extraction, or broad complexity reduction; avoid refactoring for simple or well-structured components, third-party wrappers, or when explicit testing without refactoring is requested.

Core Features & Use Cases

  • Identify and extract complex state into custom hooks, enabling reuse and easier testing.
  • Split monolithic components into focused sub-components and modular patterns like modal management, advanced conditional logic, and isolated UI sections.
  • Follow Langflow conventions for folder structure and naming to maintain consistency across projects.

Quick Start

Begin by auditing a component for complexity, plan incremental extractions, and run lint/type-check/tests after each step.

Frequently Asked Questions about component-refactoring

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

FAQPage Schema
How do I refactor a monolithic React component into smaller focused sub-components?

To refactor monolithic React components, audit the file for complexity thresholds exceeding 50 or line counts over 300, then split monolithic structures into focused sub-components and extract custom hooks for state management. This process enables reuse and easier testing.

When should I extract custom hooks from my React components?

You should extract custom hooks from React components when facing high-complexity state logic, needing reuse across the codebase, or when component complexity exceeds 50. Hook extraction isolates state management to reduce cognitive load and improve maintainability.

What is the best way to split large React component files for better maintainability?

The best way to split large React component files is to plan incremental extractions, separating isolated UI sections and modal management into focused sub-components. Run lint, type-check, and tests after each step to ensure structural integrity.

Can I use this refactoring approach for simple or well-structured React components?

You should avoid refactoring simple, well-structured React components, third-party wrappers, or codebases where explicit testing is requested without refactoring. This approach targets high-complexity frontend components needing code splitting.

Does this refactoring process enforce specific folder structure and naming conventions?

Yes, the refactoring process requires adherence to Langflow conventions for folder structure and naming. This maintains consistency across projects when extracting hooks, sub-components, and managing modular UI patterns.

Why does my React component need code splitting and modular patterns?

Your React component needs code splitting when high complexity and long file lengths create cognitive load and poor maintainability. Applying modular patterns like modal management and sub-component extraction reduces these issues.