frontend-refactor-surgeon

A guide for reorganising frontend code while keeping its behaviour, displayed output, and public interfaces unchanged. Frontend code is the part of an application users interact with in a browser or app.

In plain words
What is it for?
Use it to extract components, hooks, utilities, or styles; move files; remove duplication; simplify state; clean up props and interfaces; or tighten TypeScript types.
Why use it?
It keeps cleanup work from quietly turning into bug fixing, redesign, or new feature development. It sets limits for safe changes and points to checks needed during the refactor.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ytvee-dev/webdev-agent-kit/frontend-refactor-surgeon
Any agent
npx skills add ytvee-dev/webdev-agent-kit --skill frontend-refactor-surgeon
Clone the repo
git clone --depth 1 https://github.com/ytvee-dev/webdev-agent-kit

Made for: Claude Code, Codex.

Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,406 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00055 $0.01406
Opus 5 $0.00028 $0.00703
Sonnet 5 $0.00011 $0.00281
Haiku 4.5 $0.00006 $0.00141

Measured 2d ago against content hash 47d5754a6648, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

frontend-refactor-surgeon scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/frontend-refactor-surgeon/SKILL.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

  1. Read AGENTS.md.
  2. Read common/prompt-intent-routing-rules.md when workflow level is unclear.
  3. Read common/refactor-safety-rules.md.
  4. Read common/approved-patterns.md for component decomposition rules.
  5. Read common/anti-patterns.md and relevant anti-pattern templates when the refactor touches components.
  6. Read common/verification-loop-rules.md and common/bounded-retry-rules.md when verification repair is in scope.
  7. Read common/typescript-discipline.md.
  8. Read relevant boundary docs such as common/state-ownership-rules.md when the refactor touches state.
  9. Read project overlays and affected source files needed to define the behavior boundary.

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_docs only 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.

Read the full file on GitHub · 138 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 138 lines · 55 tokens per session scan A 47d5754a6648

Subscribe to this mod's changes

frontend-refactor-surgeon is a skill published in the GitHub repository ytvee-dev/webdev-agent-kit (5 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 55 tokens to every session and 1,406 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

playwright-cli

Automates browser interactions for testing and validating your own web applications using playwright-cli. Use when you need terminal-first browser control for navigation, form filling, screenshots, tracing, bound browser sessions, debugging, or generating Playwright test code. Only use against applications you own or…

testdino-hq/playwright-skill · 64 tokens

harness-design

Quality harness for design-dna Phase 3 output with browser-based visual verification. After an agent generates a design from a Design DNA JSON + user content, this skill acts as a verification and scoring layer — collecting all page resources via console/network inspection, performing section-by-section screenshot…

zanwei/harness-design · 232 tokens

tester

Run end-to-end web quality audits with Playwright and Lighthouse using existing project scripts first. Use when the user says /tester, e2e test, smoke test, Playwright audit, Lighthouse audit, performance audit, accessibility audit, dark mode audit, mobile audit, or asks for 100/100 Lighthouse improvement guidance.

erikfiala/e2e-tester · 67 tokens

playwright-ci

Production-ready CI/CD configurations for Playwright — GitHub Actions, GitLab CI, CircleCI, Azure DevOps, Jenkins, Docker, parallel sharding, reporting, code coverage, and global setup/teardown.

testdino-hq/playwright-skill · 48 tokens

playwright-pom

Page Object Model patterns for Playwright — when to use POM, how to structure page objects, and when fixtures or helpers are a better fit.

testdino-hq/playwright-skill · 35 tokens

playwright-migration

Step-by-step migration guides for moving to Playwright from Cypress or Selenium/WebDriver — command mappings, architecture changes, and incremental adoption strategies.

testdino-hq/playwright-skill · 33 tokens