Communitygithub.com

ASoudy/AGS

来自 Vercel Engineering 的 React 和 Next.js 性能优化指南。适用于编写、审查或重构 React/Next.js 代码时,确保采用最佳性能模式。触发于涉及 React 组件、Next.js 页面、数据获取、包优化或性能改进的任务。

AGS 是什么?

此技能(ASoudy/AGS)提供了由 Vercel 维护的一套全面的 React 和 Next.js 性能优化规则。它包含 45 条规则,分为 8 个优先级类别,从消除关键的数据请求瀑布流(如使用 `Promise.all()` 进行并行获取)到包体积优化(如避免桶文件和使用 `next/dynamic`)。该指南适用于各种场景,包括编写新组件、实现客户端或服务器端数据获取以及审查现有代码。每条规则都提供了解释、正确和错误的代码示例,并遵循清晰的结构化命名约定。该技能可指导开发者采用最高性能的模式,确保应用程序高效运行并提升用户体验。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ASoudy/AGS/tree/HEAD/claude_skills_libraries/landing-page-mastery/skills/vercel-react-best-practices

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Vercel React 最佳实践

由 Vercel 维护的 React 和 Next.js 应用综合性能优化指南。包含 8 大类别共 45 条规则,按影响程度排序,用于指导自动化重构和代码生成。

何时应用

在以下情况参考这些指南:

  • 编写新的 React 组件或 Next.js 页面
  • 实现数据获取(客户端或服务器端)
  • 审查代码中的性能问题
  • 重构现有的 React/Next.js 代码
  • 优化包体积或加载时间

规则类别(按优先级)

优先级类别影响前缀
1消除瀑布流关键async-
2包体积优化关键bundle-
3服务器端性能高server-
4客户端数据获取中-高client-
5重新渲染优化中rerender-
6渲染性能中rendering-
7JavaScript 性能低-中js-
8高级模式低advanced-

快速参考

1. 消除瀑布流(关键)

  • async-defer-await - 将 await 移动到实际使用的分支中
  • async-parallel - 对独立操作使用 Promise.all()
  • async-dependencies - 对部分依赖使用 better-all
  • async-api-routes - 在 API 路由中尽早启动 Promise,延迟 await
  • async-suspense-boundaries - 使用 Suspense 流式传输内容

2. 包体积优化(关键)

  • bundle-barrel-imports - 直接导入,避免使用桶文件
  • bundle-dynamic-imports - 对重型组件使用 next/dynamic
  • bundle-defer-third-party - 将分析/日志记录推迟到水合之后加载
  • bundle-conditional - 仅在功能激活时加载模块
  • bundle-preload - 在悬停/聚焦时预加载以获得感知速度

3. 服务器端性能(高)

  • server-cache-react - 使用 React.cache() 进行每请求去重
  • server-cache-lru - 使用 LRU 缓存进行跨请求缓存
  • server-serialization - 最小化传递给客户端组件的数据
  • server-parallel-fetching - 重构组件以并行化获取
  • server-after-nonblocking - 使用 after() 进行非阻塞操作

4. 客户端数据获取(中-高)

  • client-swr-dedup - 使用 SWR 进行自动请求去重
  • client-event-listeners - 去重全局事件监听器

5. 重新渲染优化(中)

  • rerender-defer-reads - 不要订阅仅在回调中使用的状态
  • rerender-memo - 将耗时工作提取到记忆化组件中
  • rerender-dependencies - 在副作用中使用原始值依赖
  • rerender-derived-state - 订阅派生的布尔值,而不是原始值
  • rerender-functional-setstate - 使用函数式 setState 以获得稳定回调
  • rerender-lazy-state-init - 为 useState 传递函数以处理昂贵的初始化值
  • rerender-transitions - 对非紧急更新使用 startTransition

6. 渲染性能(中)

  • rendering-animate-svg-wrapper - 动画化 div 包装器,而不是 SVG 元素
  • rendering-content-visibility - 对长列表使用 content-visibility
  • rendering-hoist-jsx - 将静态 JSX 提取到组件外部
  • rendering-svg-precision - 降低 SVG 坐标精度
  • rendering-hydration-no-flicker - 使用内联脚本处理仅客户端数据
  • rendering-activity - 使用 Activity 组件进行显示/隐藏
  • rendering-conditional-render - 使用三元运算符,而不是 && 进行条件渲染

7. JavaScript 性能(低-中)

  • js-batch-dom-css - 通过类或 cssText 分组 CSS 更改
  • js-index-maps - 为重复查找构建 Map
  • js-cache-property-access - 在循环中缓存对象属性
  • js-cache-function-results - 在模块级 Map 中缓存函数结果
  • js-cache-storage - 缓存 localStorage/sessionStorage 读取
  • js-combine-iterations - 将多个 filter/map 合并到一个循环中
  • js-length-check-first - 在执行昂贵比较之前检查数组长度
  • js-early-exit - 尽早从函数返回
  • js-hoist-regexp - 将 RegExp 创建提升到循环外部
  • js-min-max-loop - 使用循环获取 min/max,而不是 sort
  • js-set-map-lookups - 使用 Set/Map 进行 O(1) 查找
  • js-tosorted-immutable - 使用 toSorted() 实现不可变性

8. 高级模式(低)

  • advanced-event-handler-refs - 将事件处理程序存储在 refs 中
  • advanced-use-latest - 使用 useLatest 获取稳定的回调引用

如何使用

阅读各个规则文件以获取详细解释和代码示例:

rules/async-parallel.md
rules/bundle-barrel-imports.md
rules/_sections.md

每个规则文件包含:

  • 为何重要的简要说明
  • 带解释的错误代码示例
  • 带解释的正确代码示例
  • 额外的上下文和参考资料

完整编译文档

获取包含所有规则扩展的完整指南:AGENTS.md

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ASoudy/AGS

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

ASoudy/AGS

Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

ASoudy/AGS

Build content-focused websites with Astro — zero JS by default, islands architecture, multi-framework components, and Markdown/MDX support.

ASoudy/AGS

One sentence - what this skill does and when to invoke it

ASoudy/AGS

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

ASoudy/AGS

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

ASoudy/AGS

Pull a YouTube video transcript into a queryable markdown vault with yt-dlp subtitle discovery, VTT cleanup, metadata frontmatter, and capture-seed stubs.

ASoudy/AGS

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

ASoudy/AGS

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

ASoudy/AGS

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

ASoudy/AGS

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

ASoudy/AGS

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

ASoudy/AGS

Next.js App Router principles. Server Components, data fetching, routing patterns.

ASoudy/AGS

Expert integration of Supabase Auth with Next.js App Router

ASoudy/AGS

React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.

ASoudy/AGS

Best practices for Remotion - Video creation in React

ASoudy/AGS

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

ASoudy/AGS

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

ASoudy/AGS

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

ASoudy/AGS

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

相关技能