frontend-refactor-surgeon
Skill7 starsChanged 21 days agoApache-2.0View on GitHub
Perform bounded, behavior-preserving frontend refactors such as component extraction, file moves, prop or interface cleanup, state simplification, and TypeScript tightening. Excludes bugfixes, features, redesign, packages, and unapproved behavior changes.
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-rules-skill-authorSkill
- agent-self-improvementSkill
- design-screenshot-specSkill
- execution-plan-managerSkill
- frontend-architecture-plannerSkill
- frontend-bugfix-debuggerSkill
- frontend-design-directorSkill
- frontend-design-intelligenceSkill
- frontend-layout-implementerSkill
- frontend-linter-managerSkill
- frontend-prototype-explorerSkill
- frontend-quality-reviewerSkill
- frontend-visual-qaSkill
- goal-plannerSkill
- greenfield-project-builderSkill
- loop-workflow-plannerSkill
- mcp-toolchain-managerSkill
- pattern-library-managerSkill
- project-context-adapterSkill
- project-onboarding-adapterSkill
- webdev-feedbackSkill
- webdev-kit-updaterSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. About 0 are common, 10 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 46
Use this skill when the user asks to simplify or reorganize frontend code, extract components, hooks, utilities, or styles, tighten …
- Distinctive: line 50
Do not use this skill for bugfix-first debugging, new feature implementation, design/spec work, visual QA only, broad rewrites without a …
- Very specific: line 52
Use frontend-bugfix-debugger when the primary goal is to fix a defect.
- Very specific: line 57
Read common/prompt-intent-routing-rules.md when workflow level is unclear.
- Very specific: line 59
Read common/approved-patterns.md for component decomposition rules.
- Very specific: line 60
Read common/anti-patterns.md and relevant anti-pattern templates when the refactor touches components.
- Very specific: line 61
Read common/verification-loop-rules.md and common/bounded-retry-rules.md when verification repair is in scope.
- Very specific: line 63
Read relevant boundary docs such as common/state-ownership-rules.md when the refactor touches state.
- Distinctive: line 64
Read project overlays and affected source files needed to define the behavior boundary.
- Very specific: line 66
When shared UI or compatible component wrappers are in scope, read common/frontend-design-system-rules.md and …
- Very specific: line 71
When React/Next work changes loading, imports, subscriptions or expensive rendering, read the relevant section of …
- Distinctive: line 80
Must not install packages, add testing workflows, change build tooling, add UI libraries, or migrate frameworks without explicit approval.
- Distinctive: line 81
Must not change production systems, secrets, or production data.
- Distinctive: line 91
Do not create or preserve components that mix routing, data access, state orchestration, transformations, form logic, repeated markup, …
- Very specific: line 92
Do not hide missing decomposition behind renderXxx, xxxRender, nested array pipelines, component-body JSX preparation, oversized custom …
- Distinctive: line 93
Run the smallest relevant verification after meaningful edits.
- Distinctive: line 94
If verification fails because of the current refactor, fix related failures using bounded retry rules and keep the behavior contract …
- Very specific: line 95
Use frontend-linter-manager after code-changing work when a lint command exists.
- Very specific: line 96
Use frontend-visual-qa when rendered UI could have changed.
- Very specific: line 97
Use frontend-quality-reviewer when the refactor is standard or deep, involved retry, or the user asks for review.
- Distinctive: line 98
Stop and ask before behavior change, architecture expansion, dependency changes, or broad rewrite.
- Distinctive: line 125
No testing workflow, UI library, package install, or framework migration may be introduced by default.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend Refactor Surgeon
Purpose
Refactor frontend code while preserving behavior, rendered output, and public contracts unless the user explicitly approves a behavior change.
Refactor verification may use a bounded loop for related failures, but the refactor must not expand into feature work or broad rewrite.
When To Use
Use this skill when the user asks to simplify or reorganize frontend code, extract components, hooks, utilities, or styles, tighten TypeScript types, remove duplication within a clear frontend boundary, decompose mixed-responsibility components, or prepare code for a future change without adding the feature yet.
When Not To Use
Do not use this skill for bugfix-first debugging, new feature implementation, design/spec work, visual QA only, broad rewrites without a boundary, backend refactors, package installation, or testing workflow creation.
Use frontend-bugfix-debugger when the primary goal is to fix a defect.
Required Context
- Read
AGENTS.md. - Read
common/prompt-intent-routing-rules.mdwhen workflow level is unclear. - Read
common/refactor-safety-rules.md. - Read
common/approved-patterns.mdfor component decomposition rules. - Read
common/anti-patterns.mdand relevant anti-pattern templates when the refactor touches components. - Read
common/verification-loop-rules.mdandcommon/bounded-retry-rules.mdwhen verification repair is in scope. - Read
common/typescript-discipline.md. - Read relevant boundary docs such as
common/state-ownership-rules.mdwhen the refactor touches state. - Read project overlays and affected source files needed to define the behavior boundary.
When shared UI or compatible component wrappers are in scope, read
common/frontend-design-system-rules.md and
common/component-substitution-rules.md. Apply purpose-specific naming from
common/frontend-implementation-boundaries.md to changed project-owned code.
When React/Next work changes loading, imports, subscriptions or expensive
rendering, read the relevant section of common/react-performance-rules.md.
Tool Contract
- May inspect affected source, styles, configs, and project overlays.
- May run existing lint, typecheck, build, or preview commands relevant to the refactor.
- May use Browser or Playwright MCP when rendered output must be checked.
- Activate
openai_platform_docsonly when current OpenAI API or ChatGPT Apps SDK behavior affects the preserved contract. - Must not install packages, add testing workflows, change build tooling, add UI libraries, or migrate frameworks without explicit approval.
- Must not change production systems, secrets, or production data.
Workflow
- Define the refactor boundary and behavior contract.
- Identify public APIs, rendered output, route behavior, state ownership, accessibility, and TypeScript contracts that must remain stable.
- Identify whether the refactor requires decomposition.
- Split the refactor into small mechanical steps.
- Edit one boundary at a time.
- Preserve project naming, folder, styling, and state conventions.
- Do not create or preserve components that mix routing, data access, state orchestration, transformations, form logic, repeated markup, large JSX, and side effects in one file.
- Do not hide missing decomposition behind
renderXxx,xxxRender, nested array pipelines, component-body JSX preparation, oversized custom hooks, or unnecessaryuseCallback. - Run the smallest relevant verification after meaningful edits.
- If verification fails because of the current refactor, fix related failures using bounded retry rules and keep the behavior contract unchanged.
- Use
frontend-linter-managerafter code-changing work when a lint command exists. - Use
frontend-visual-qawhen rendered UI could have changed. - Use
frontend-quality-reviewerwhen the refactor is standard or deep, involved retry, or the user asks for review. - Stop and ask before behavior change, architecture expansion, dependency changes, or broad rewrite.
Output Contract
Final response: return only facts that affect the user's understanding, confidence, or next action. Omit empty fields and workflow narration.
Refactor boundary:
Behavior preserved:
Decomposition applied:
Changes made:
Attempts:
Verification:
Rendered QA:
Deferred work:
Risks:Validation Gates
- The behavior boundary must be explicit before editing.
- Public contracts must remain stable unless approved.
- Refactor must not introduce feature work by default.
- Verification repair must not change behavior to make checks pass.
- Component decomposition rules must be applied regardless of framework, router, state layer, data layer, or styling system.
- Lint verification must run after code changes when a command exists.
- Rendered UI changes or risk must trigger visual QA when applicable.
- No testing workflow, UI library, package install, or framework migration may be introduced by default.
Trigger Evals
Should trigger:
- "Extract this component while preserving its public behavior."
- "Simplify this state flow in bounded verified steps."
Should not trigger:
- "Fix this runtime bug from its reproduction."
- "Redesign this page."
Reference Map
common/react-performance-rules.mdcommon/refactor-safety-rules.mdcommon/approved-patterns.mdcommon/anti-patterns.mdcommon/verification-loop-rules.mdcommon/bounded-retry-rules.mdcommon/typescript-discipline.mdcommon/state-ownership-rules.mdproject/verification-profile.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

