Component Refactoring
PageAI-Pro/ralph-loop
Refactor high-complexity React components in frontend. An agent skill from PageAI-Pro/ralph-loop.
Refactor high-complexity React components in Langflow frontend.
$ npx skills add langflow-ai/langflow --skill component-refactoring -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install langflow-ai/langflow component-refactoring --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/langflow-ai/langflow.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/component-refactoring .claude/skills/component-refactoring && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "component-refactoring" agent skill from https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring into .claude/skills/component-refactoring/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "component-refactoring", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoringType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add langflow-ai/langflow --skill component-refactoring -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install langflow-ai/langflow component-refactoring --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langflow-ai/langflow.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agents/skills/component-refactoring .agents/skills/component-refactoring && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "component-refactoring" agent skill from https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring into .agents/skills/component-refactoring/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "component-refactoring", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add langflow-ai/langflow --skill component-refactoring -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install langflow-ai/langflow component-refactoring --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langflow-ai/langflow.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agents/skills/component-refactoring .cursor/skills/component-refactoring && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "component-refactoring" agent skill from https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring into .cursor/skills/component-refactoring/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "component-refactoring", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/langflow-ai/langflow.git --path .agents/skills/component-refactoring--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add langflow-ai/langflow --skill component-refactoring -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install langflow-ai/langflow component-refactoring --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langflow-ai/langflow.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agents/skills/component-refactoring .gemini/skills/component-refactoring && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "component-refactoring" agent skill from https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring into .gemini/skills/component-refactoring/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "component-refactoring", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install langflow-ai/langflow component-refactoringInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add langflow-ai/langflow --skill component-refactoring -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/langflow-ai/langflow.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agents/skills/component-refactoring .github/skills/component-refactoring && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "component-refactoring" agent skill from https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring into .github/skills/component-refactoring/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "component-refactoring", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add langflow-ai/langflow --skill component-refactoring -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install langflow-ai/langflow component-refactoring --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/langflow-ai/langflow.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agents/skills/component-refactoring .opencode/skills/component-refactoring && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "component-refactoring" agent skill from https://github.com/langflow-ai/langflow/tree/main/.agents/skills/component-refactoring into .opencode/skills/component-refactoring/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "component-refactoring", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
component-refactoringRefactor high-complexity React components in Langflow frontend.
Component Refactoring is an agent skill from langflow-ai/langflow. Refactor high-complexity React components in Langflow frontend. Use when manual complexity assessment shows complexity 50 or lineCount 300, when the user asks for code splitting, hook extraction, or complexity reduction; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.
Its SKILL.md is about 3.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/complexity-patterns.md`, `references/component-splitting.md` and `references/hook-extraction.md`).
It sits in Development, covering Refactoring and React components. The repository describes itself as: Langflow is a powerful tool for building and deploying AI-powered agents and workflows. The licence is MIT.
8 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 504c02f. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Component Refactoring loads about 3.5k tokens when it runs, and up to ~14k if it reads all its reference files. Until then it costs about 94 tokens; SKILL.md has 791 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from langflow-ai/langflow at commit 504c02f, republished under its MIT licence (© langflow-ai). 791 words, ~3,529 tokens.
.claude/skills/component-refactoring/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.Refactor high-complexity React components in the Langflow frontend codebase with the patterns and workflow below.
Complexity Threshold: Components with complexity > 50 (measured manually by counting conditionals, nesting levels, and lines) should be refactored before testing.
src/frontend/)cd src/frontend
# Lint with Biome
npm run lint
# Type checking
npm run type-check
# Run tests
npm testSince Langflow does not have automated complexity analysis tools, assess components manually:
if/else, switch/case, ternary, &&/|| chain adds +1.useState calls suggests hook extraction.useEffect calls suggests effect consolidation.| Score | Level | Action |
|---|---|---|
| 0-25 | Simple | Ready for testing |
| 26-50 | Medium | Consider minor refactoring |
| 51-75 | Complex | Refactor before testing |
| 76-100 | Very Complex | Must refactor |
When: Component has complex state management, multiple useState/useEffect, or business logic mixed with UI.
Langflow Convention: Place hooks in a hooks/ subdirectory or alongside the component as use-<feature>.ts. Langflow uses kebab-case filenames with use- prefix.
// Before: Complex state logic in component
const FlowPage: FC = () => {
const [nodes, setNodes] = useState<Node[]>([])
const [edges, setEdges] = useState<Edge[]>([])
const [buildStatus, setBuildStatus] = useState<BuildStatus>(BuildStatus.IDLE)
// 50+ lines of state management logic...
return <div>...</div>
}
// After: Extract to custom hook
// hooks/use-flow-state.ts
export const useFlowState = (flowId: string) => {
const [nodes, setNodes] = useState<Node[]>([])
const [edges, setEdges] = useState<Edge[]>([])
const [buildStatus, setBuildStatus] = useState<BuildStatus>(BuildStatus.IDLE)
// Related state management logic here
return { nodes, setNodes, edges, setEdges, buildStatus, setBuildStatus }
}
// Component becomes cleaner
const FlowPage: FC = () => {
const { nodes, setNodes, edges, setEdges } = useFlowState(flowId)
return <div>...</div>
}Langflow Examples:
src/frontend/src/hooks/use-add-component.tssrc/frontend/src/hooks/use-unsaved-changes.tssrc/frontend/src/hooks/use-refresh-model-inputs.tsWhen: Single component has multiple UI sections, conditional rendering blocks, or repeated patterns.
Langflow Convention: Place sub-components in subdirectories or as separate files in the same directory. UI primitives go in components/ui/, domain components in components/core/, reusable components in components/common/.
// Before: Monolithic JSX with multiple sections
const GenericNode = () => {
return (
<div>
{/* 100 lines of header UI */}
{/* 100 lines of parameter fields */}
{/* 100 lines of output handles */}
</div>
)
}
// After: Split into focused components
// CustomNodes/GenericNode/
// generic-node.tsx (orchestration only — kebab-case, descriptive name)
// components/
// node-header.tsx
// node-parameters.tsx
// node-outputs.tsx
const GenericNode = () => {
return (
<div>
<NodeHeader nodeData={data} />
<NodeParameters fields={fields} />
<NodeOutputs outputs={outputs} />
</div>
)
}Langflow Examples:
src/frontend/src/CustomNodes/GenericNode/components/src/frontend/src/components/core/src/frontend/src/components/ui/When: Deep nesting (> 3 levels), complex ternaries, or multiple if/else chains.
// Before: Deeply nested conditionals
const getFieldComponent = (field: InputFieldType) => {
if (field.type === "str") {
if (field.multiline) {
return <TextAreaComponent />
} else if (field.password) {
return <PasswordInput />
} else if (field.options?.length) {
return <Dropdown options={field.options} />
} else {
return <InputComponent />
}
} else if (field.type === "int") {
return <IntComponent />
} else if (field.type === "float") {
return <FloatComponent />
}
return null
}
// After: Use lookup tables + early returns
const FIELD_COMPONENT_MAP: Record<string, FC<FieldProps>> = {
int: IntComponent,
float: FloatComponent,
bool: ToggleComponent,
code: CodeAreaComponent,
}
const STR_VARIANT_MAP: Record<string, FC<FieldProps>> = {
multiline: TextAreaComponent,
password: PasswordInput,
options: Dropdown,
}
const getFieldComponent = (field: InputFieldType) => {
if (field.type !== "str") {
const Component = FIELD_COMPONENT_MAP[field.type]
return Component ? <Component {...field} /> : null
}
const variant = field.multiline ? "multiline"
: field.password ? "password"
: field.options?.length ? "options"
: "default"
const Component = STR_VARIANT_MAP[variant] ?? InputComponent
return <Component {...field} />
}When: Component directly handles API calls, data transformation, or complex async operations.
Langflow Convention:
frontend-query-mutation for query patterns, UseRequestProcessor, cache invalidation, and mutation error handling.useQuery wrappers during refactoring; only extract a custom hook when it truly orchestrates multiple queries/mutations or shared derived state.controllers/API/queries/{domain}/.Langflow Examples:
src/frontend/src/controllers/API/queries/flows/use-post-add-flow.tssrc/frontend/src/controllers/API/queries/variables/use-get-global-variables.tssrc/frontend/src/controllers/API/queries/folders/use-get-folders.tsWhen: Component manages multiple modals with complex open/close states.
Langflow Convention: Modals should be extracted with their state management.
// Before: Multiple modal states in component
const FlowToolbar = () => {
const [showExportModal, setShowExportModal] = useState(false)
const [showShareModal, setShowShareModal] = useState(false)
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false)
const [showApiModal, setShowApiModal] = useState(false)
// 5+ more modal states...
}
// After: Extract to modal management hook
type ModalType = "export" | "share" | "delete" | "api" | null
const useFlowToolbarModals = () => {
const [activeModal, setActiveModal] = useState<ModalType>(null)
const openModal = useCallback((type: ModalType) => setActiveModal(type), [])
const closeModal = useCallback(() => setActiveModal(null), [])
return {
activeModal,
openModal,
closeModal,
isOpen: (type: ModalType) => activeModal === type,
}
}When: Complex form validation, submission handling, or field transformation.
Langflow Convention: Extract form state and validation into hooks.
// Extract form validation and submission
const useFlowSettingsForm = (initialValues: FlowSettings) => {
const [values, setValues] = useState(initialValues)
const [errors, setErrors] = useState<Record<string, string>>({})
const validate = useCallback(() => {
const newErrors: Record<string, string> = {}
if (!values.name?.trim()) newErrors.name = "Name is required"
if (values.endpoint_name && !/^[a-z0-9-]+$/.test(values.endpoint_name)) {
newErrors.endpoint_name = "Must be lowercase alphanumeric with hyphens"
}
setErrors(newErrors)
return Object.keys(newErrors).length === 0
}, [values])
const handleChange = useCallback((field: string, value: any) => {
setValues((prev) => ({ ...prev, [field]: value }))
}, [])
return { values, errors, validate, handleChange }
}When: Component reads many values from a Zustand store, causing unnecessary re-renders.
// Before: Selecting too many values
const Component = () => {
const flowStore = useFlowStore()
// Component re-renders on ANY store change
}
// After: Use individual selectors
const Component = () => {
const nodes = useFlowStore((state) => state.nodes)
const edges = useFlowStore((state) => state.edges)
// Component only re-renders when nodes or edges change
}Langflow Reference: All stores in src/frontend/src/stores/ follow this selector pattern.
When: Refactoring flow node components (CustomNodes/GenericNode/).
Conventions:
components/ subdirectory for sub-componentsCustomNodes/GenericNode/
generic-node.tsx # Node registration and main render (kebab-case, NOT index.tsx)
components/
handle-render.tsx # Handle rendering
node-description.tsx # Node description display
node-input-field.tsx # Input field rendering
node-name.tsx # Node name display
node-output-field.tsx # Output field rendering
node-status.tsx # Build status displayWhen: Refactoring components related to the flow editor canvas.
Conventions:
@xyflow/react v12 is the canvas libraryuseFlowStore for flow state managementuseFlowsManagerStore for multi-flow managementWhen: Refactoring components that consume API data.
Conventions:
controllers/API/queries/UseRequestProcessor for new queries/mutations["useGetGlobalVariables"] for cache managementonSettled callbacksManually count:
Create a refactoring plan based on detected features:
| Detected Feature | Refactoring Action |
|---|---|
5+ useState hooks with related state | Extract custom hook |
| API calls in component body | Extract to query hook |
| 3+ event handlers with logic | Extract event handlers to hook |
| 300+ lines | Split into sub-components |
| Deep conditional nesting (>3) | Simplify conditional logic |
| Multiple modal states | Extract modal management |
For each extraction:
1. Extract code
2. Run: npm run lint
3. Run: npm run type-check
4. Run: npm test
5. Test functionality manually
6. PASS? -> Next extraction
FAIL? -> Fix before continuingAfter refactoring, re-assess complexity manually:
// Too many tiny hooks
const useButtonText = () => useState("Click")
const useButtonDisabled = () => useState(false)
const useButtonLoading = () => useState(false)
// Cohesive hook with related state
const useButtonState = () => {
const [text, setText] = useState("Click")
const [disabled, setDisabled] = useState(false)
const [loading, setLoading] = useState(false)
return { text, setText, disabled, setDisabled, loading, setLoading }
}components/ui/, components/core/, components/common/useQuery or useMutation directly for API callsUseRequestProcessor pattern for consistency with retry and invalidation logicfrontend-query-mutation skill for API hook patternssrc/frontend/src/hooks/src/frontend/src/CustomNodes/GenericNode/components/src/frontend/src/components/ui/src/frontend/src/components/core/src/frontend/src/components/common/src/frontend/src/controllers/API/queries/src/frontend/src/stores/frontend-query-mutation - For API query and mutation patternsfrontend-testing - For testing refactored components© langflow-ai, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 3 other files (references) in .agents/skills/component-refactoring of langflow-ai/langflow.
Open the folder on GitHubat commit 504c02f
Component Refactoring next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Component Refactoring this skilllangflow-ai/langflow | 156k | — | ~3.5k | Automated safety check: Pass | MIT | |
| Component RefactoringPageAI-Pro/ralph-loop | 311 | — | ~1.8k | Automated safety check: Pass | MIT | |
| Code Review And Qualityhylarucoder/hai-stack | 382 | — | ~934 | Automated safety check: Pass | MIT | |
| Saleor App UIsaleor/apps | 162 | — | ~5.8k | Automated safety check: Pass | Custom licence | |
| Vercel React Best Practicessanity-io/sanity | 6.4k | 130 repos | ~1.6k | Automated safety check: Pass | MIT | |
| React Best Practicesmastra-ai/mastra | 29k | — | ~1.9k | Automated safety check: Pass | Custom licence |
PageAI-Pro/ralph-loop
Refactor high-complexity React components in frontend. An agent skill from PageAI-Pro/ralph-loop.
hylarucoder/hai-stack
Reviews a code change for correctness, security, maintainability, architecture, performance, and verification gaps, or performs a local code-smell review.
saleor/apps
Styling and layout guide for Saleor Apps using modern macaw-ui and @saleor/apps-ui-next.
sanity-io/sanity
React and Next.js performance optimization guidelines from Vercel Engineering.
mastra-ai/mastra
React performance optimization guidelines from Mastra Engineering.
mattiacerutti/supernova
Enforce the no-useEffect rule when writing or reviewing React code.
langflow-ai/langflow
Review backend code for quality, security, maintainability, and best practices based on established checklist rules.
langflow-ai/langflow
Write and review Playwright E2E tests for Langflow. An agent skill from langflow-ai/langflow.
langflow-ai/langflow
Guide for implementing Langflow frontend query and mutation patterns with Axios and TanStack React Query v5.
langflow-ai/langflow
Perform a scoped IBM Equal Access Level 1 compliance audit of a chosen Langflow frontend surface (routes, components, or a PR) and produce a findings report mapped to WCAG/IBM Level 1 criteria.
langflow-ai/langflow
Add, change, or review user-facing text in the Langflow frontend using the i18n system (i18next / react-i18next).
langflow-ai/langflow
Scan every frontend surface touched by the current PR/branch for IBM Equal Access Level 1 accessibility issues and fix all in-scope violations by default.
Categories
Refactor high-complexity React components in Langflow frontend. Component Refactoring is an agent skill from langflow-ai/langflow. Refactor high-complexity React components in Langflow frontend.
Component Refactoring fits situations like: manual complexity assessment shows complexity 50; the user asks for code splitting; hook extraction; complexity reduction.
Run `npx skills add langflow-ai/langflow --skill component-refactoring -a claude-code`. Or copy the skill folder (.agents/skills/component-refactoring in langflow-ai/langflow) into .claude/skills/component-refactoring in your project. Claude Code loads it when a task matches its description.
Run `npx skills add langflow-ai/langflow --skill component-refactoring -a codex`. Or copy the skill folder (.agents/skills/component-refactoring in langflow-ai/langflow) into .agents/skills/component-refactoring in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add langflow-ai/langflow --skill component-refactoring -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/component-refactoring, .gemini/skills/component-refactoring, .github/skills/component-refactoring and .opencode/skills/component-refactoring in your project.
Going by SKILL.md and its folder, Component Refactoring needs the command-line tools its instructions call (npm).
SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Component Refactoring is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 3.5k tokens (SKILL.md is roughly 14k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 11k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Component Refactoring: Component Refactoring (PageAI-Pro/ralph-loop, 311 stars), Code Review And Quality (hylarucoder/hai-stack, 382 stars), Saleor App UI (saleor/apps, 162 stars) and Vercel React Best Practices (sanity-io/sanity, 6.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
langflow-ai (a GitHub organization) maintains it in langflow-ai/langflow, which has 155,573 GitHub stars. The repository holds 10 skills in this directory. The repository was last updated on October 8, 2026.
Source: langflow-ai/langflow on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.