All skills
vercel-labs avatar

/react-best-practices

@805687f official
by Vercel Labsvercel-labs/agent-skills32k stars
2,784

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

Use this Skill: https://skilld.dev/gh/vercel-labs/agent-skills/react-best-practices

This session only. Nothing lands on disk.

README.md

≈840 tokens on demand. Your agent reads this file only when SKILL.md points to it.

React Best Practices

A structured repository for creating and maintaining React Best Practices optimized for agents and LLMs.

Structure

  • rules/ - Individual rule files (one per rule)
    • _sections.md - Section metadata (titles, impacts, descriptions)
    • _template.md - Template for creating new rules
    • area-description.md - Individual rule files
  • src/ - Build scripts and utilities
  • metadata.json - Document metadata (version, organization, abstract)
  • AGENTS.md - Compiled output (generated)
  • test-cases.json - Test cases for LLM evaluation (generated)

Getting Started

  1. Install dependencies:

    pnpm install
  2. Build AGENTS.md from rules:

    pnpm build
  3. Validate rule files:

    pnpm validate
  4. Extract test cases:

    pnpm extract-tests

Creating a New Rule

  1. Copy rules/_template.md to rules/area-description.md
  2. Choose the appropriate area prefix:
    • async- for Eliminating Waterfalls (Section 1)
    • bundle- for Bundle Size Optimization (Section 2)
    • server- for Server-Side Performance (Section 3)
    • client- for Client-Side Data Fetching (Section 4)
    • rerender- for Re-render Optimization (Section 5)
    • rendering- for Rendering Performance (Section 6)
    • js- for JavaScript Performance (Section 7)
    • advanced- for Advanced Patterns (Section 8)
  3. Fill in the frontmatter and content
  4. Ensure you have clear examples with explanations
  5. Run pnpm build to regenerate AGENTS.md and test-cases.json

Rule File Structure

Each rule file should follow this structure:

---
title: Rule Title Here
impact: MEDIUM
impactDescription: Optional description
tags: tag1, tag2, tag3
---

## Rule Title Here

Brief explanation of the rule and why it matters.

**Incorrect (description of what's wrong):**

```typescript
// Bad code example

Correct (description of what's right):

// Good code example

Optional explanatory text after examples.

Reference: Link

File Naming Convention

  • Files starting with _ are special (excluded from build)
  • Rule files: area-description.md (e.g., async-parallel.md)
  • Section is automatically inferred from filename prefix
  • Rules are sorted alphabetically by title within each section
  • IDs (e.g., 1.1, 1.2) are auto-generated during build

Impact Levels

  • CRITICAL - Highest priority, major performance gains
  • HIGH - Significant performance improvements
  • MEDIUM-HIGH - Moderate-high gains
  • MEDIUM - Moderate performance improvements
  • LOW-MEDIUM - Low-medium gains
  • LOW - Incremental improvements

Scripts

  • pnpm build - Compile rules into AGENTS.md
  • pnpm validate - Validate all rule files
  • pnpm extract-tests - Extract test cases for LLM evaluation
  • pnpm dev - Build and validate

Contributing

When adding or modifying rules:

  1. Use the correct filename prefix for your section
  2. Follow the _template.md structure
  3. Include clear bad/good examples with explanations
  4. Add appropriate tags
  5. Run pnpm build to regenerate AGENTS.md and test-cases.json
  6. Rules are automatically sorted by title - no need to manage numbers!

Acknowledgments

Originally created by @shuding at Vercel.

Source: SKILL.md on GitHub

No alerts16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a comprehensive set of performance optimization and best practice guidelines for React and Next.js applications. No security issues or risky patterns were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    1/63 files flagged

Signed by skilld at 805687f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 6 months ago
metadata
{
  "author": "vercel",
  "version": "1.0.0"
}

README badge

README badge for vercel-labs/agent-skills/react-best-practices

Provides 70 React and Next.js performance optimization rules organized by priority, from eliminating waterfalls and bundle size optimization to re-render and rendering performance. Use this skill when writing, reviewing, or refactoring React/Next.js code to apply Vercel's performance patterns for data fetching, component structure, and bundle optimization.

Generated from the current SKILL.md.

Does this skill cover both React and Next.js?
Yes. The skill includes guidelines for React components, Next.js pages, server-side rendering, server actions, and data fetching patterns across both frameworks.
Are these rules ranked by importance?
Yes. Rules are organized into 8 categories ranked by impact, from eliminating waterfalls and bundle optimization (CRITICAL) down to advanced patterns (LOW).
Can this skill be used during code review and refactoring?
Yes. The skill is intended for writing new code, reviewing existing code for performance issues, and refactoring React/Next.js applications.
Does this skill include code examples?
Yes. Each of the 70 rules has a detailed file with incorrect and correct code examples, explanations, and additional context.

Generated from the current SKILL.md. These answers refresh after source changes.