Skip to content

feat: add react-named-effects skill#213

Open
dnh33 wants to merge 3 commits intovercel-labs:mainfrom
dnh33:feat/react-named-effects
Open

feat: add react-named-effects skill#213
dnh33 wants to merge 3 commits intovercel-labs:mainfrom
dnh33:feat/react-named-effects

Conversation

@dnh33
Copy link
Copy Markdown

@dnh33 dnh33 commented Apr 2, 2026

Summary

Adds a react-named-effects skill that teaches agents to replace anonymous arrows in useEffect (and useCallback/useMemo) with named function expressions.

Structure follows the react-view-transitions pattern:

  • SKILL.md — core pattern, when to apply, quick reference (~80 lines)
  • references/diagnostics.md — anti-pattern detection, split/elimination signals
  • references/conventions.md — naming vocabulary, cleanup functions, custom hooks, ESLint enforcement, technical notes
  • AGENTS.md — compiled full guide
  • metadata.json + README.md per repo conventions

Complements existing react-best-practices rules (rerender-derived-state-no-effect, rerender-move-effect-to-event, rerender-split-combined-hooks) without overlap — no existing skill or rule covers naming conventions for hook callbacks.

Why This Matters

Named effects give agents three things:

  1. Better stack tracesat connectToWebSocket @ file:14 instead of at (anonymous) @ file:14
  2. Scannable data flow — read four function names to understand a component instead of four implementations
  3. A diagnostic surface — effects that resist clean naming have structural problems (should be split, eliminated, or extracted)

React's docs use anonymous arrows for brevity. This skill recommends named expressions for production code — acknowledged explicitly in the content.

Based On

Technical accuracy

The skill is precise about what naming does and doesn't do:

  • Does: Improve JS engine stack traces (Chrome, Firefox, Node, Sentry)
  • Does not: Change React DevTools display (DevTools uses source-map AST parsing, not function names)
  • Does not: Affect performance (named and anonymous functions are equivalent at runtime)

Test plan

  • SKILL.md has valid YAML frontmatter
  • All code examples syntactically valid TypeScript/TSX
  • All code examples SSR-safe (typeof window checks where needed)
  • No contradictions with existing react-best-practices rules (verified against 7 rules)
  • Zip package contains complete skill directory
  • Progressive disclosure works — SKILL.md references files that exist
  • AGENTS.md contains compiled content from all references
  • metadata.json schema matches existing skills

dnh33 added 3 commits April 3, 2026 00:39
Teach agents to use named function expressions in useEffect, useCallback,
and useMemo instead of anonymous arrows. Named effects improve stack traces,
make component data flow scannable, and act as a diagnostic — effects that
resist clean naming have structural problems worth fixing.

Follows react-view-transitions pattern:
- SKILL.md router with core pattern and quick reference
- references/diagnostics.md for anti-pattern detection
- references/conventions.md for naming vocabulary and tooling
- AGENTS.md compiled full guide
- metadata.json and README.md per repo conventions

Complements existing react-best-practices rules (derived-state-no-effect,
move-effect-to-event, split-combined-hooks) by providing the naming
discipline that naturally surfaces when those rules should apply.

Based on: https://neciudan.dev/name-your-effects
- Fix syncWidthAndApplyTheme example: show full body with both concerns
  and correct dependency array [user?.preferences?.theme]
- Add standard preamble to AGENTS.md matching repo convention
- Note AGENTS.md is compiled from source files (prevent drift)
- Add reset/clear and track/observe to SKILL.md quick reference table
  (examples used these verbs but table didn't include them)
- Add name and license fields to metadata.json
- Regenerate zip
- Add typeof window check in useWindowWidth useState initializer
  (SSR/Node.js would throw on bare window.innerWidth access)
- Remove name and license fields from metadata.json to match
  existing skill schema (composition-patterns, react-best-practices)
- Regenerate zip
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 2, 2026

@dnh33 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant