| Refactor avoidable React useEffect usage in Langfuse frontend code. Use when adding, reviewing, or removing effects; initializing forms or local UI state from query data; synchronizing client and server state; moving mutations or async workflows out of components; cleaning every effect from a frontend submodule; or reviewing whether an effect has a valid external-system owner.
npx skills add https://github.com/langfuse/langfuse --skill refactor-react-effects
Do not add useEffect by default. Use it only to synchronize a component with
a concrete system outside React. If there is no external system, remove the
effect.
Before adding or retaining an effect, answer all of these questions:
or existing integration hook not own the behavior?
If the first question has no concrete answer, do not use an effect.
web/AGENTS.md and the nearest package guidance before changing webcode.
also read
../frontend-large-feature-architecture/SKILL.md.
references/refactoring-patterns.md
before implementing a refactor.
Apply these rules in order:
client state instead of storing a synchronized copy.
without query data, let a parent own loading/error handling. Mount a child
only after the data exists and pass guaranteed initial values to its lazy
useState initializer.
key to remount for a new entityonly when discarding the old local draft is intended. Use an explicit user
action for refresh/reset when drafts must not be overwritten silently.
and multi-step async workflows in event handlers, actions/*.ts, or store
actions. Pass a React Query client, mutation callback, or vanilla Zustand
store as a dependency; never call React hooks from those actions.
listeners, timers, and imperative third-party APIs may need an effect. Make
setup and cleanup symmetrical and keep the effect in a narrow integration
hook or container. In a direct-effect-free module, use a pre-existing,
centrally owned integration hook. Do not create a feature-local wrapper just
to hide useEffect.
Presume that an effect which writes React or Zustand state from props or query
data is removable. Do not evade the design problem by switching to
useLayoutEffect, suppressing dependency lint, hiding the same synchronization
in a custom hook, or adding an ESLint disable.
Refactor when any of these shapes appear:
useEffect(() => setX(deriveFromY(y)), [y]);setState;after the precondition is true.
Identify the state owner, query owner, user events, external systems, and
loading/error states. For a bug fix, add the failing test first and confirm it
fails. For a behavior-preserving migration, reuse existing coverage where it
protects the relevant behavior; add focused coverage only for a meaningful
behavior risk such as draft preservation, entity changes, refetches, submits,
or cleanup. Do not add tests that inspect source code or merely assert that a
hook is absent. Use behavior tests and the effect inventory instead.
Search the full target module, including tests and stories:
rg -n '\b(use(?:Layout)?Effect|React\.use(?:Layout)?Effect)\b' 'web/src/features/<feature>'
Classify every result as:
Do not refactor from a raw count alone. Record what triggers each effect, what
it writes or controls, and the replacement pattern.
Prefer this order:
Keep user-visible behavior stable. Avoid bundling unrelated file moves, visual
changes, and state architecture changes into the same slice.
Repeat the inventory after each slice. Before declaring a submodule clean:
refactoring target.
Do not add or modify effect-specific ESLint rules or pre-commit checks as part
of this workflow. Treat enforcement policy as separate, explicitly requested
work.
Run, at minimum:
pnpm --filter web run lint;applicable;
Report the exact command summary lines and any retained effects with their
external-system rationale.
Return valid Markdown. For module audits, include a compact table with the
effect location, classification, replacement, and status. Check headings,
lists, links, tables, backticks, and code fences for valid Markdown syntax
before returning the report.
Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping
Comprehensive GitHub code review with AI-powered swarm coordination
Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message, stage changes, or split work into multiple commits.
Comprehensive truth scoring, code quality verification, and automatic rollback system with 0.95 accuracy threshold for ensuring high-quality agent outputs and codebase reliability.
GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.
GitHub CLI - manage repositories, issues, pull requests, actions, releases, and more from the command line.
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
Take langfuse/refactor-react-effects from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.