benefriches-react-best-practices
React best practices and performance optimization for Benefriches (Vite + Redux). Reference when writing components, implementing Redux patterns, reviewing code quality, or optimizing performance.
Best use case
benefriches-react-best-practices is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
React best practices and performance optimization for Benefriches (Vite + Redux). Reference when writing components, implementing Redux patterns, reviewing code quality, or optimizing performance.
Teams using benefriches-react-best-practices should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/benefriches-react-best-practices/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How benefriches-react-best-practices Compares
| Feature / Agent | benefriches-react-best-practices | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
React best practices and performance optimization for Benefriches (Vite + Redux). Reference when writing components, implementing Redux patterns, reviewing code quality, or optimizing performance.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# React Best Practices for Benefriches
> **Performance optimization guidelines for React 19+ SPA with Vite + Redux**
>
> **Based on**: [Vercel React Best Practices](https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices)
>
> **Adapted for**: Client-side rendering only
---
## When to Apply This Skill
Use these practices when:
- ✅ Writing new React components
- ✅ Implementing Redux thunks or selectors
- ✅ Reviewing code for performance issues
- ✅ Refactoring existing React code
- ✅ Optimizing bundle size
- ✅ Improving rendering performance
- ✅ Debugging slow interactions or waterfalls
---
## Rule Categories by Priority
| Priority | Category | Rules | Impact |
| -------- | -------------------------- | ----- | ------------------------------- |
| 🔴 | **Bundle Size** | 4 | 200-800ms import cost reduction |
| 🟠 | **Async/Waterfall** | 4 | 2-10× improvement |
| 🟡 | **Array/Data** | 2 | Fast-fail + immutability |
| 🟢 | **Re-render** | 12 | Prevent unnecessary renders |
| 🔵 | **Bundle (Continued)** | 2 | Load on demand |
| 🟣 | **Client Data** | 2 | Scroll + storage optimization |
| ⚫ | **Rendering Performance** | 7 | Static hoisting + transitions |
| ⚪ | **JavaScript Performance** | 11 | Caching + O(1) lookups |
| 🔘 | **Advanced Patterns** | 2 | Singletons + stable refs |
**Total**: 31 applicable practices
---
## Quick Reference by Category
### 🔴 CRITICAL: Bundle Size Optimization
| Rule | Impact | Relevance |
| -------------------------------- | ---------------------- | ----------------------------------------- |
| Avoid Barrel File Imports | 200-800ms import cost | Check `@/features` imports |
| Dynamic Imports for Heavy Comp. | Reduce initial bundle | Lazy-load maps, forms, charts |
| Promise.all() for Independence | 2-10× parallel speedup | Redux thunks fetching multiple resources |
| Dependency-Based Parallelization | Start async ops ASAP | Complex thunks with multiple dependencies |
### 🟠 HIGH: Async/Waterfall Optimization
| Rule | Impact | Relevance |
| ----------------------------- | --------------------------- | ------------------------------------- |
| Defer Await Until Needed | Avoid blocking code paths | Conditional logic in thunks |
| Strategic Suspense Boundaries | Show wrapper UI immediately | Feature pages with async requirements |
| Conditional Module Loading | Load heavy libs on demand | Charts, PDFs, advanced map features |
| CSS content-visibility | ~10× faster for long lists | Site lists, project tables |
### 🟡 MEDIUM-HIGH: Array/Data Optimization
| Rule | Impact | Relevance |
| -------------------------------- | ------------------------ | --------------------------------- |
| Early Length Check | Fast-fail expensive ops | Redux selectors, form validation |
| Use toSorted() Instead of sort() | Immutability (critical!) | ALL sorting in reducers/selectors |
### 🟢 MEDIUM: Re-render Optimization
| Rule | Impact | Relevance |
| -------------------------------------- | ------------------------------- | ------------------------------------ |
| Calculate Derived State in Render | Avoid redundant state | Redux selectors |
| Extract to Memoized Components | Enable early returns | Heavy presentational components |
| Functional setState Updates | Prevent stale closures | Already followed via Redux |
| Lazy State Initialization | Compute expensive values once | Local state with complex init |
| Use Transitions for Non-Urgent Updates | Maintain UI responsiveness | Search/filter inputs |
| Use useRef for Transient Values | Avoid re-renders | Animation values, scroll positions |
| Narrow Effect Dependencies | Reduce effect re-runs | Extract specific values from objects |
| Put Logic in Event Handlers | Avoid state + effect modeling | Forms, user interactions |
| Subscribe to Derived State | Boolean from continuous values | Redux selectors for UI state |
| Defer State Reads to Usage Point | Read dynamic state in callbacks | Event handlers |
| Don't Wrap Simple Expressions | Avoid over-optimization | Simple calculations |
| Extract Default Non-primitive Params | Preserve memoization | Memoized component props |
### 🔵 MEDIUM: Bundle Optimization (Continued)
| Rule | Impact | Relevance |
| ---------------------------- | ------------------------- | --------------------------- |
| Defer Non-Critical Libraries | Load after initialization | Analytics, error tracking |
| Preload Based on User Intent | Reduce perceived latency | Heavy modals, project forms |
### 🟣 MEDIUM: Client Data Patterns
| Rule | Impact | Relevance |
| ------------------------------- | ---------------------- | ------------------------------ |
| Passive Event Listeners | Eliminate scroll delay | Infinite scroll, animations |
| Version + Minimize localStorage | Prevent breaks, reduce | Redux persistence, preferences |
### ⚫ LOW-MEDIUM: Rendering Performance
| Rule | Impact | Relevance |
| ------------------------------------- | ---------------------- | ------------------------------ |
| Hoist Static JSX | Avoid re-creation | Empty states, error messages |
| Use Activity Component for Visibility | Preserve state/DOM | Toggle forms/maps |
| Explicit Conditional Rendering | Prevent rendering 0 | Count displays |
| useTransition Over Manual Loading | Built-in pending state | Replace useState loading flags |
| Optimize SVG Precision | Reduce file size | Map icons, illustrations |
| Animate SVG Wrapper | Hardware acceleration | Spinning icons |
### ⚪ LOW-MEDIUM: JavaScript Performance
| Rule | Impact | Relevance |
| ------------------------------ | ----------------------- | ---------------------------------- |
| Cache Repeated Function Calls | Module-level Maps | Area calculations, transformations |
| Build Index Maps | O(1) vs O(n) lookups | Redux selectors by ID |
| Use Set/Map for Lookups | O(1) membership checks | Selected IDs, uniqueness filtering |
| Avoid Layout Thrashing | Batch DOM reads/writes | Animations, dynamic layouts |
| Cache Property Access in Loops | Hot path optimization | Array iterations |
| Cache Storage API Calls | Avoid repeated reads | localStorage access |
| Combine Array Iterations | Single loop vs multiple | Chained filter/map operations |
| Early Return from Functions | Skip unnecessary work | Validation functions |
| Hoist RegExp Creation | Don't create in render | Email validation, parsing |
| Loop for Min/Max vs Sort | O(n) vs O(n log n) | Finding extremes |
### 🔘 LOW: Advanced Patterns
| Rule | Impact | Relevance |
| ---------------------------- | -------------------- | ---------------------------- |
| Initialize App Once | Module-level guards | Redux store, analytics setup |
| Store Event Handlers in Refs | Stable subscriptions | Event bus listeners |
---
## Benefriches-Specific Integration
### Redux Patterns
**Already following these best practices:**
- ✅ Functional updates (reducers use immutable patterns)
- ✅ Derived state in selectors (not duplicated in state)
- ✅ Deferred state reads (useAppSelector in components)
**Apply these explicitly:**
- 🟡 **Use `toSorted()`** instead of `sort()` in all reducers/selectors
- 🟢 **Single ViewData selector** per container (already following)
- 🔴 **Parallel async in thunks** with `Promise.all()`
### Clean Architecture Integration
**Core layer** (business logic):
- ✅ Pure functions - already optimizable with caching/memoization
- ✅ No framework deps - easy to extract heavy computations
**Infrastructure layer** (gateways):
- 🟠 **Conditional module loading** - load heavy services on demand
- 🔵 **Preload on intent** - import services before API calls
**Views layer** (React components):
- 🟢 **React.memo()** for heavy presentational components with lots of potential re-render (DO NOT pre-optimize when it's not necessary)
- ⚫ **Hoist static JSX** - extract constants outside components
- 🟠 **Suspense boundaries** - wrap data-dependent sections
### Path Aliases (`@/`)
When optimizing imports:
- 🔴 **Avoid barrel files** - use direct paths with `@/` alias
- Example: `import { X } from '@/features/create-site/core/createSite.reducer'`
---
## See Also
- **Full detailed guide**: `AGENTS.md` in this skill directory
- **Web app guide**: `apps/web/CLAUDE.md`
- **Monorepo guide**: Root `CLAUDE.md`
- **Original source**: [Vercel React Best Practices](https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices)
---
**END OF QUICK REFERENCE** - For code examples and detailed patterns, see `AGENTS.md`.Related Skills
better-auth-best-practices
Skill for integrating Better Auth - the comprehensive TypeScript authentication framework.
architectural-patterns-large-react
Establish scalable architecture using modular boundaries, domain-driven design, and consistent data access patterns.
arcanea-react-best-practices
React 19 and Next.js 16 performance optimization for the Arcanea platform. Use when writing, reviewing, or refactoring React components, data fetching logic, bundle optimization, or any frontend performance work. Triggers on: React components, Next.js pages, hooks, data fetching, bundle size, re-renders, Server Components, Client Components, hydration. Sourced from Vercel Engineering's official React best practices (57 rules, 8 categories) and adapted for the Arcanea stack.
apple-dev-best-practices
Apple platform development best practices for Swift 6, SwiftUI, SwiftData, and iOS/macOS apps. Use when building any iOS or macOS app, writing Swift code, designing SwiftUI views, working with Xcode projects, implementing navigation, state management, concurrency, networking, persistence, or testing on Apple platforms. Triggers on Swift, SwiftUI, iOS, macOS, Xcode, UIKit, SwiftData, Core Data, XCTest, StoreKit, CloudKit, MapKit, HealthKit, or any Apple framework. Also use when reviewing Swift code, debugging iOS apps, migrating UIKit to SwiftUI, or planning Apple platform architecture.
animation-best-practices
CSS and UI animation patterns for responsive, polished interfaces. Use when implementing hover effects, tooltips, button feedback, transitions, or fixing animation issues like flicker and shakiness.
angular-best-practices
Angular performance optimization and best practices guide. Use when writing, reviewing, or refactoring Angular code for optimal performance, bundle size, and rendering efficiency.
agent-react-specialist
Expert React specialist mastering React 18+ with modern patterns and ecosystem. Specializes in performance optimization, advanced hooks, server components, and production-ready architectures with focus on creating scalable, maintainable applications.
Advanced React Clean Integration
Integrate React with clean architecture without framework leakage using hooks as adapters and presenters. Use when connecting React to domain logic, designing hook-based DI, or isolating UI from business rules.
add-reaction
Slack メッセージにリアクションを追加する。「リアクション追加」「リアクションつけて」「👍つけて」「絵文字で反応」「リアクションで返信」「いいねして」「リアクション送って」などで起動。User Token があればユーザーとしてリアクション、なければ Bot としてリアクション。
stripe-best-practices
Best practices for building Stripe integrations
power-bi-report-design-best-practices
Comprehensive Power BI report design and visualization best practices based on Microsoft guidance for creating effective, accessible, and performant reports and dashboards. Triggers on: **/*.{pbix,md,json,txt}
best-practices-guidelines
Specifies best practices, including following RESTful API design principles, implementing responsive design, using Zod for data validation, and regularly updating dependencies. This rule promotes mode