Communitygithub.com

xzedm/clipplic-landing

Vercel Engineering 提供的 React 與 Next.js 效能最佳化指南。適用於撰寫、審查或重構 React/Next.js 程式碼,以確保遵循最佳效能模式。

clipplic-landing 是什麼?

本技能「Vercel React 最佳實踐」是一套由 Vercel 維護的全面效能最佳化指南,專為 React 與 Next.js 應用程式設計。它包含 70 條規則,橫跨 8 個類別,並根據影響程度排列優先級,以引導自動化重構與程式碼生成。此技能支援在寫入新 React 元件或 Next.js 頁面、實作資料擷取(客戶端或伺服器端)、審查效能問題、重構現有程式碼以及最佳化套件大小或載入時間等任務時套用。其運作方式是透過優先級分類(如「消除瀑布效應」、「套件大小最佳化」)提供具體規則,並搭配詳細的規則檔案說明錯誤與正確範例。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/xzedm/clipplic-landing/tree/HEAD/.agents/skills/vercel-react-best-practices

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Vercel React 最佳實踐

由 Vercel 維護的 React 與 Next.js 應用程式綜合效能最佳化指南。包含 8 個類別的 70 條規則,按影響程度排序,以引導自動化重構和程式碼生成。

何時套用

請在下列情況參考這些指南:

  • 撰寫新的 React 元件或 Next.js 頁面
  • 實作資料擷取(客戶端或伺服器端)
  • 審查程式碼以找出效能問題
  • 重構現有的 React/Next.js 程式碼
  • 最佳化套件大小或載入時間

規則類別(按優先級排列)

優先級類別影響程度前綴
1消除瀑布效應關鍵async-
2套件大小最佳化關鍵bundle-
3伺服器端效能高server-
4客戶端資料擷取中高client-
5重新渲染最佳化中rerender-
6渲染效能中rendering-
7JavaScript 效能低中js-
8進階模式低advanced-

快速參考

1. 消除瀑布效應(關鍵)

  • async-cheap-condition-before-await - 在等待旗標或遠端值之前,先檢查便宜的同步條件
  • 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 - 直接匯入,避免使用 barrel 檔案
  • bundle-analyzable-paths - 偏好靜態可分析的路徑,以避免廣泛的套件與追蹤
  • bundle-dynamic-imports - 對重型元件使用 next/dynamic
  • bundle-defer-third-party - 在 hydration 之後載入分析/記錄
  • bundle-conditional - 僅在功能啟用時載入模組
  • bundle-preload - 在滑鼠懸停/聚焦時預載,以提升感知速度

3. 伺服器端效能(高)

  • server-auth-actions - 像 API 路由一樣對伺服器動作進行身份驗證
  • server-cache-react - 使用 React.cache() 進行每個請求的去重
  • server-cache-lru - 使用 LRU 快取進行跨請求快取
  • server-dedup-props - 避免在 RSC props 中重複序列化
  • server-hoist-static-io - 將靜態 I/O(字型、標誌)提升到模組層級
  • server-no-shared-module-state - 避免在 RSC/SSR 中使用模組層級的可變請求狀態
  • server-serialization - 最小化傳遞給客戶端元件的資料
  • server-parallel-fetching - 重構元件以並行化擷取
  • server-parallel-nested-fetching - 在 Promise.all 中為每個項目鏈式巢狀擷取
  • server-after-nonblocking - 使用 after() 執行非阻塞操作

4. 客戶端資料擷取(中高)

  • client-swr-dedup - 使用 SWR 進行自動請求去重
  • client-event-listeners - 去重全域事件監聽器
  • client-passive-event-listeners - 對滾動使用被動監聽器
  • client-localstorage-schema - 版本化並最小化 localStorage 資料

5. 重新渲染最佳化(中)

  • rerender-defer-reads - 不要訂閱只在回呼中使用的狀態
  • rerender-memo - 將昂貴的工作提取到 memoized 元件中
  • rerender-memo-with-default-value - 提升預設的非原始 props
  • rerender-dependencies - 在 effect 中使用原始類型相依性
  • rerender-derived-state - 訂閱衍生的布林值,而非原始值
  • rerender-derived-state-no-effect - 在渲染期間衍生狀態,而非 effect
  • rerender-functional-setstate - 使用函式型 setState 以獲得穩定的回呼
  • rerender-lazy-state-init - 對昂貴的初始值,將函式傳遞給 useState
  • rerender-simple-expression-in-memo - 對簡單的原始類型避免使用 memo
  • rerender-split-combined-hooks - 拆分具有獨立相依性的 hooks
  • rerender-move-effect-to-event - 將互動邏輯放入事件處理常式
  • rerender-transitions - 對非緊急更新使用 startTransition
  • rerender-use-deferred-value - 延後昂貴的渲染,以保持輸入回應
  • rerender-use-ref-transient-values - 對短暫的頻繁值使用 refs
  • rerender-no-inline-components - 不要在元件內部定義元件

6. 渲染效能(中)

  • rendering-animate-svg-wrapper - 動畫化 div 包裝層,而非 SVG 元素
  • rendering-content-visibility - 對長列表使用 content-visibility
  • rendering-hoist-jsx - 將靜態 JSX 提取到元件外部
  • rendering-svg-precision - 降低 SVG 座標精確度
  • rendering-hydration-no-flicker - 對僅客戶端資料使用內聯 script
  • rendering-hydration-suppress-warning - 抑制預期的不匹配
  • rendering-activity - 使用 Activity 元件顯示/隱藏
  • rendering-conditional-render - 對條件式渲染使用三元運算子,而非 &&
  • rendering-usetransition-loading - 偏好使用 useTransition 處理載入狀態
  • rendering-resource-hints - 使用 React DOM 資源提示進行預載
  • rendering-script-defer-async - 在 script 標籤上使用 defer 或 async

7. JavaScript 效能(低中)

  • js-batch-dom-css - 透過 class 或 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 - 使用迴圈取得最小/最大值,而非 sort
  • js-set-map-lookups - 使用 Set/Map 進行 O(1) 查詢
  • js-tosorted-immutable - 使用 toSorted() 確保不可變性
  • js-flatmap-filter - 使用 flatMap 在一次遍歷中完成映射和過濾
  • js-request-idle-callback - 將非關鍵工作延後到瀏覽器空閒時間

8. 進階模式(低)

  • advanced-effect-event-deps - 不要將 useEffectEvent 結果放入 effect 相依性
  • advanced-event-handler-refs - 將事件處理常式儲存在 refs 中
  • advanced-init-once - 每次應用程式載入時初始化一次
  • advanced-use-latest - 對穩定的回呼 ref 使用 useLatest

如何使用

閱讀個別規則檔案以取得詳細說明和程式碼範例:

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

每個規則檔案包含:

  • 為何重要的簡短解釋
  • 錯誤的程式碼範例與說明
  • 正確的程式碼範例與說明
  • 其他背景資訊與參考資料

完整編譯文件

如需包含所有規則的完整指南:AGENTS.md

Individual skills in this repo

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

xzedm/clipplic-landing

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

xzedm/clipplic-landing

Material Design 3 and Android platform guidelines. Use when building Android apps with Jetpack Compose or XML layouts, implementing Material You, navigation, or accessibility. Triggers on tasks involving Android UI, Compose components, dynamic color, or Material Design compliance.

xzedm/clipplic-landing

Apple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces.

xzedm/clipplic-landing

Design iOS apps following Apple's Human Interface Guidelines. Generate native components, validate designs, and ensure accessibility compliance for iPhone, iPad, and Apple Watch.

xzedm/clipplic-landing

Redesign mobile app UI to feel unmistakably Apple-like, iOS-forward, and native. Use this skill when building iOS apps, applying Apple Human Interface Guidelines, or creating native-feeling mobile interfaces with SF Pro typography, translucency, and system-like components.

xzedm/clipplic-landing

Accessibility engineering for product interfaces, from focus states and keyboard support to ARIA, forms, and screen readers. Use when building or reviewing UI components, modals, menus, forms, custom widgets, or when the user says "make this accessible" or reports keyboard or screen-reader issues. Triggers on accessibility, a11y, WCAG, aria, focus ring, focus-visible, focus trap, keyboard navigation, tab order, tabindex, screen reader, sr-only, aria-live, alt text, hit area, touch target, prefers-reduced-motion, autoplay, toast duration, skip link, semantic HTML, aria-label, form errors, disabled buttons, "not keyboard accessible".

xzedm/clipplic-landing

OKLCH color space and color usage for web projects. Convert hex/rgb/hsl to oklch, generate palettes, check contrast, handle gamut boundaries, theme with Tailwind v4, and apply color with meaning. Triggers on oklch, color conversion, palette generation, contrast ratio, gamut, display p3, design tokens, semantic color tokens, hue drift, chroma, dark mode colors, accent color, color meaning, light and dark appearance, increased contrast.

xzedm/clipplic-landing

Layout structure for web interfaces, from grouping and alignment to reading order, progressive disclosure, and adaptive breakpoints. Use when structuring a page or component, spacing or aligning controls, deciding what collapses at small sizes, handling RTL layout direction, or reviewing frontend code for layout. Triggers on layout, spacing, alignment, grouping, negative space, whitespace, visual hierarchy, reading order, progressive disclosure, breakpoints, responsive layout, container queries, safe area, full-bleed, edge-to-edge, layout margins, RTL layout, logical properties.

xzedm/clipplic-landing

Web typography from choosing fonts to spacing, wrapping and accessibility. Use when picking or pairing typefaces, configuring variable fonts or OpenType features, setting up a type scale, checking heading hierarchy, styling text in components, truncating text, styling underlines, selection, placeholders or carets, or reviewing frontend code for typography. Triggers on typography, fonts, font formats, woff2, variable fonts, font-weight, opentype, font-feature-settings, letter-spacing, line-height, type scale, heading hierarchy, heading levels, tabular numbers, text-wrap, truncation, line clamp, underlines, text-decoration, text selection, iOS input zoom, scaled input text, font smoothing, text contrast, measure, line length, text-box, smart punctuation, drop cap.

xzedm/clipplic-landing

Design engineering principles for making interfaces feel polished. Use when building UI components, reviewing frontend code, implementing animations, hover states, shadows, borders, micro-interactions, enter/exit animations, choosing or reviewing icons, or any visual detail work. Triggers on UI polish, design details, "make it feel better", "feels off", stagger animations, border radius, optical alignment, image outlines, box shadows, icons, icon stroke weight, icon states, motion restraint.

xzedm/clipplic-landing

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

xzedm/clipplic-landing

Generate developer handoff specs from a design. Use when a design is ready for engineering and needs a spec sheet covering layout, design tokens, component props, interaction states, responsive breakpoints, edge cases, and animation details.

xzedm/clipplic-landing

This skill encodes Emil Kowalski's philosophy on UI polish, component design, animation decisions, and the invisible details that make software feel great.

xzedm/clipplic-landing

Extract design primitives from a public website and generate starter token files for your project.

xzedm/clipplic-landing

Use this skill alongside figma-use when the task involves translating an application page, view, or multi-section layout into Figma. Triggers: 'write to Figma', 'create in Figma from code', 'push page to Figma', 'take this app/page and build it in Figma', 'create a screen', 'build a landing page in Figma', 'update the Figma screen to match code', 'convert this modal/dialog/drawer/panel to Figma'. This is the preferred workflow skill whenever the user wants to build or update a full page, modal, dialog, drawer, sidebar, panel, or any composed multi-section view in Figma from code or a description. Discovers design system components, variables, and styles from Code Connect files, existing screens, and library search, then imports them and assembles views incrementally section-by-section using design system tokens instead of hardcoded values.

xzedm/clipplic-landing

**MANDATORY prerequisite**: you MUST invoke this skill BEFORE every `use_figma` tool call. NEVER call `use_figma` directly without loading this skill first. Skipping it causes common, hard-to-debug failures. Trigger whenever the user wants to perform a write action or a unique read action that requires JavaScript execution in the Figma file context, e.g. create/edit/delete nodes, set up variables or tokens, build components and variants, modify auto-layout or fills, bind variables to properties, or inspect file structure programmatically.

xzedm/clipplic-landing

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

xzedm/clipplic-landing

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications.

xzedm/clipplic-landing

Elite UX/UI & Advanced GSAP Motion Engineer. Enforces Python-driven true randomization for layout variance, strict AIDA page structure, wide editorial typography (bans 6-line wraps), gapless bento grids, strict GSAP ScrollTriggers (pinning, stacking, scrubbing), inline micro-images, and massive section spacing.

xzedm/clipplic-landing

Fast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)

相關技能