Component Refactoring
langflow-ai/langflow
Refactor high-complexity React components in Langflow frontend.
Refactor high-complexity React components in frontend. An agent skill from PageAI-Pro/ralph-loop.
$ npx skills add PageAI-Pro/ralph-loop --skill component-refactoring -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install PageAI-Pro/ralph-loop 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/PageAI-Pro/ralph-loop.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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 PageAI-Pro/ralph-loop --skill component-refactoring -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install PageAI-Pro/ralph-loop component-refactoring --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PageAI-Pro/ralph-loop.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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 PageAI-Pro/ralph-loop --skill component-refactoring -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install PageAI-Pro/ralph-loop component-refactoring --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PageAI-Pro/ralph-loop.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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/PageAI-Pro/ralph-loop.git --path .agent/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 PageAI-Pro/ralph-loop --skill component-refactoring -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install PageAI-Pro/ralph-loop component-refactoring --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PageAI-Pro/ralph-loop.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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 PageAI-Pro/ralph-loop 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 PageAI-Pro/ralph-loop --skill component-refactoring -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/PageAI-Pro/ralph-loop.git skills-src && mkdir -p .github/skills && cp -r skills-src/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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 PageAI-Pro/ralph-loop --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 PageAI-Pro/ralph-loop component-refactoring --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PageAI-Pro/ralph-loop.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.agent/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/PageAI-Pro/ralph-loop/tree/main/.agent/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 frontend. An agent skill from PageAI-Pro/ralph-loop.
Component Refactoring is an agent skill from PageAI-Pro/ralph-loop. Refactor high-complexity React components in frontend. Use when the user asks for code splitting, hook extraction, or complexity reduction, or when you come across a component that is too complex to understand and refactor it.
Its SKILL.md is about 1.8k 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: A long-running AI agent loop. Ralph automates software development tasks by iteratively working through a task list until completion. The licence is MIT.
Read from SKILL.md and the folder at commit eba65eb. 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.
No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
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 1.8k tokens when it runs, and up to ~9.4k if it reads all its reference files. Until then it costs about 62 tokens; SKILL.md has 189 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 PageAI-Pro/ralph-loop at commit eba65eb, republished under its MIT licence (© PageAI-Pro). 189 words, ~1,785 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 with the patterns and workflow below.
When: Component has complex state management, multiple useState/useEffect, or business logic mixed with UI.
Dify Convention: Place hooks in a hooks/ subdirectory or alongside the component as use-<feature>.ts.
// ❌ Before: Complex state logic in component
const Configuration: FC = () => {
const [modelConfig, setModelConfig] = useState<ModelConfig>(...)
const [datasetConfigs, setDatasetConfigs] = useState<DatasetConfigs>(...)
const [completionParams, setCompletionParams] = useState<FormValue>({})
// 50+ lines of state management logic...
return <div>...</div>
}
// ✅ After: Extract to custom hook
// hooks/use-model-config.ts
export const useModelConfig = (appId: string) => {
const [modelConfig, setModelConfig] = useState<ModelConfig>(...)
const [completionParams, setCompletionParams] = useState<FormValue>({})
// Related state management logic here
return { modelConfig, setModelConfig, completionParams, setCompletionParams }
}
// Component becomes cleaner
const Configuration: FC = () => {
const { modelConfig, setModelConfig } = useModelConfig(appId)
return <div>...</div>
}When: Single component has multiple UI sections, conditional rendering blocks, or repeated patterns.
// ❌ Before: Monolithic JSX with multiple sections
const AppInfo = () => {
return (
<div>
{/* 100 lines of header UI */}
{/* 100 lines of operations UI */}
{/* 100 lines of modals */}
</div>
)
}
// ✅ After: Split into focused components
// app-info/
// ├── index.tsx (orchestration only)
// ├── app-header.tsx (header UI)
// ├── app-operations.tsx (operations UI)
// └── app-modals.tsx (modal management)
const AppInfo = () => {
const { showModal, setShowModal } = useAppInfoModals()
return (
<div>
<AppHeader appDetail={appDetail} />
<AppOperations onAction={handleAction} />
<AppModals show={showModal} onClose={() => setShowModal(null)} />
</div>
)
}When: Deep nesting (> 3 levels), complex ternaries, or multiple if/else chains.
// ❌ Before: Deeply nested conditionals
const Template = useMemo(() => {
if (appDetail?.mode === AppModeEnum.CHAT) {
switch (locale) {
case LanguagesSupported[1]:
return <TemplateChatZh />
case LanguagesSupported[7]:
return <TemplateChatJa />
default:
return <TemplateChatEn />
}
}
if (appDetail?.mode === AppModeEnum.ADVANCED_CHAT) {
// Another 15 lines...
}
// More conditions...
}, [appDetail, locale])
// ✅ After: Use lookup tables + early returns
const TEMPLATE_MAP = {
[AppModeEnum.CHAT]: {
[LanguagesSupported[1]]: TemplateChatZh,
[LanguagesSupported[7]]: TemplateChatJa,
default: TemplateChatEn,
},
[AppModeEnum.ADVANCED_CHAT]: {
[LanguagesSupported[1]]: TemplateAdvancedChatZh,
// ...
},
}
const Template = useMemo(() => {
const modeTemplates = TEMPLATE_MAP[appDetail?.mode]
if (!modeTemplates) return null
const TemplateComponent = modeTemplates[locale] || modeTemplates.default
return <TemplateComponent appDetail={appDetail} />
}, [appDetail, locale])When: Component directly handles API calls, data transformation, or complex async operations.
// ❌ Before: API logic in component
const MCPServiceCard = () => {
const [basicAppConfig, setBasicAppConfig] = useState({})
useEffect(() => {
if (isBasicApp && appId) {
(async () => {
const res = await fetchAppDetail({ url: '/apps', id: appId })
setBasicAppConfig(res?.model_config || {})
})()
}
}, [appId, isBasicApp])
// More API-related logic...
}
// ✅ After: Extract to data hook using React Query
// use-app-config.ts
import { useQuery } from '@tanstack/react-query'
import { get } from '@/service/base'
const NAME_SPACE = 'appConfig'
export const useAppConfig = (appId: string, isBasicApp: boolean) => {
return useQuery({
enabled: isBasicApp && !!appId,
queryKey: [NAME_SPACE, 'detail', appId],
queryFn: () => get<AppDetailResponse>(`/apps/${appId}`),
select: data => data?.model_config || {},
})
}
// Component becomes cleaner
const MCPServiceCard = () => {
const { data: config, isLoading } = useAppConfig(appId, isBasicApp)
// UI only
}React Query Best Practices:
NAME_SPACE for query key organizationenabled option for conditional fetchingselect for data transformationuseInvalidXxxWhen: Component manages multiple modals with complex open/close states.
// ❌ Before: Multiple modal states in component
const AppInfo = () => {
const [showEditModal, setShowEditModal] = useState(false)
const [showDuplicateModal, setShowDuplicateModal] = useState(false)
const [showConfirmDelete, setShowConfirmDelete] = useState(false)
const [showSwitchModal, setShowSwitchModal] = useState(false)
const [showImportDSLModal, setShowImportDSLModal] = useState(false)
// 5+ more modal states...
}
// ✅ After: Extract to modal management hook
type ModalType = 'edit' | 'duplicate' | 'delete' | 'switch' | 'import' | null
const useAppInfoModals = () => {
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,
}
}// ❌ 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 }
}frontend-testing - For testing refactored components© PageAI-Pro, 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 .agent/skills/component-refactoring of PageAI-Pro/ralph-loop.
Open the folder on GitHubat commit eba65eb
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 skillPageAI-Pro/ralph-loop | 311 | — | ~1.8k | Automated safety check: Pass | MIT | |
| Component Refactoringlangflow-ai/langflow | 156k | — | ~3.5k | Automated safety check: Pass | MIT | |
| Code Review And Qualityhylarucoder/hai-stack | 380 | — | ~934 | Automated safety check: Pass | MIT | |
| React Composition Patternsvercel-labs/openreview | 1.7k | 58 repos | ~721 | Automated safety check: Pass | MIT | |
| 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 |
langflow-ai/langflow
Refactor high-complexity React components in Langflow frontend.
hylarucoder/hai-stack
Reviews a code change for correctness, security, maintainability, architecture, performance, and verification gaps, or performs a local code-smell review.
vercel-labs/openreview
Rules for structuring React components with composition instead of boolean props, covering compound components, lifted state, variants and React 19 changes.
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.
PageAI-Pro/ralph-loop
Comprehensive vitest testing patterns covering test structure, AAA pattern, parameterized tests, assertions, mocking, test doubles, error handling, async testing, and performance optimization.
PageAI-Pro/ralph-loop
Playwright E2E testing patterns. An agent skill from PageAI-Pro/ralph-loop.
PageAI-Pro/ralph-loop
Guides creation of comprehensive Product Requirement Documents (PRDs) for software projects through structured questioning and validation, then generates implementation task lists in JSON format.
Categories
Refactor high-complexity React components in frontend. An agent skill from PageAI-Pro/ralph-loop. Component Refactoring is an agent skill from PageAI-Pro/ralph-loop. Refactor high-complexity React components in frontend.
Component Refactoring fits situations like: the user asks for code splitting; hook extraction; complexity reduction; you come across a component that is too complex to understand and refactor it.
Run `npx skills add PageAI-Pro/ralph-loop --skill component-refactoring -a claude-code`. Or copy the skill folder (.agent/skills/component-refactoring in PageAI-Pro/ralph-loop) into .claude/skills/component-refactoring in your project. Claude Code loads it when a task matches its description.
Run `npx skills add PageAI-Pro/ralph-loop --skill component-refactoring -a codex`. Or copy the skill folder (.agent/skills/component-refactoring in PageAI-Pro/ralph-loop) 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 PageAI-Pro/ralph-loop --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.
SKILL.md names no scripts, command-line tools or credentials: Component Refactoring is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. 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 1.8k tokens (SKILL.md is roughly 7.1k 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 7.6k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Component Refactoring: Component Refactoring (langflow-ai/langflow, 156k stars), Code Review And Quality (hylarucoder/hai-stack, 380 stars), React Composition Patterns (vercel-labs/openreview, 1.7k 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.
PageAI-Pro (a GitHub organization) maintains it in PageAI-Pro/ralph-loop, which has 311 GitHub stars. The repository holds 4 skills in this directory. The repository was last updated on August 31, 2026.
Source: PageAI-Pro/ralph-loop on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.