Communitygithub.com

前端基礎結構審核

在審查 React、Vue 或前端元件程式碼時自動啟用。確保元件架構、狀態管理模式及 UI 最佳實踐。

前端基礎結構審核 是什麼?

這個技能專為前端程式碼審查設計,尤其適合 React、Vue 與 Svelte 專案。它提供一套結構化的審查清單,涵蓋元件單一職責、Props 數量、狀態共置(colocation)、效能最佳化(如 useMemo、useCallback)、無障礙(ARIA、鍵盤導航)等面向。內建常見反模式提示(如 God Component、Prop Drilling、Boolean Prop Soup)與蘇格拉底式提問,引導開發者自行發現架構問題。支援 Claude Code、Cursor、Codex 等 AI 編碼工具,可結合 `/standards/frontend/component-architecture.md` 標準文件深入檢查。透過自動觸發審查與具體紅旗標記,幫助團隊維持元件品質、避免重構債務。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/danielpodolsky/frontend-fundamentals

在你喜歡的 AI 中提問

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

說明文件

前端基礎結構審核 是做什麼的?

「一個元件應該只做好一件事。如果你需要用『而且』來描述它,那就拆開它。」

何時啟用

在審查以下內容時啟用此技能:

  • React/Vue/Svelte 元件
  • UI 渲染邏輯
  • 狀態管理程式碼
  • CSS/樣式決策
  • 客戶端路由

審查清單

元件架構

  • 單一職責:每個元件是否只做一件事?
  • 大小檢查:元件是否少於 200 行?
  • Props 數量:是否少於 7 個 props?
  • 命名:能否不用「而且」來描述這個元件?

狀態管理

  • 共置:狀態是否盡可能靠近使用它的地方?
  • 提升:兄弟元件之間是否透過父元件正確共享狀態?
  • Context vs Props:是否避免了 prop drilling(最多 3 層)?
  • 伺服器狀態:伺服器資料是否獨立管理(React Query/SWR)?

效能

  • 記憶化:昂貴的計算是否包在 useMemo 中?
  • 回呼:事件處理函式是否在必要時用 useCallback 包裹?
  • 重新渲染:是否會導致不必要的重新渲染?
  • 延遲載入:重量級元件是否通過程式碼分割載入?

無障礙

  • 語義化 HTML:是否使用了正確的元素(button vs div)?
  • ARIA:互動元素是否可存取?
  • 鍵盤:使用者能否不使用滑鼠就能導航?

常見錯誤(反模式)

1. God 元件

❌ UserDashboard.tsx (1000 行)
   - 取得資料、管理狀態、渲染 UI、處理路由

✅ 拆分為:
   - UserDashboardPage.tsx (容器)
   - UserStats.tsx (展示)
   - UserActivity.tsx (展示)
   - useUserData.ts (hook)

2. 渲染邏輯內嵌

❌ return <div>{users.filter(u => u.active).map(u => ...)}</div>

✅ const activeUsers = useMemo(() => users.filter(u => u.active), [users]);
   return <div>{activeUsers.map(u => ...)}</div>

3. Prop Drilling

❌ <App user={user}>
     <Layout user={user}>
       <Main user={user}>
         <Widget user={user} />

✅ const user = useUser(); // 在 Widget.tsx 中

4. 布林值 Props 爆炸

❌ <Button primary secondary large small disabled loading />

✅ <Button variant="primary" size="large" state="loading" />

蘇格拉底式提問

用這些問題引導新手,而不是直接給答案:

  1. 架構:「這個元件的『一個職責』是什麼?」
  2. 拆分:「如果我要你把 header 部分單獨用在其他地方,你做得到嗎?」
  3. 狀態:「誰需要這份資料?它應該放在這裡還是更高層?」
  4. 效能:「當父元件重新渲染時會發生什麼事?」
  5. 複雜度:「一個新開發者能在 5 分鐘內看懂這個嗎?」

標準文件參考

詳細的模式請參閱:

  • /standards/frontend/component-architecture.md

需標記的紅旗

紅旗標記應提問
檔案 > 200 行「我們可以把它拆成更小的部分嗎?」
> 5 個 useState 呼叫「部分狀態是否需要提升或合併?」
useEffect 的 [] 依賴但使用外部值「我們是否遺漏了依賴?」
直接 DOM 操作「有沒有 React 的方式可以做到?」
到處都是內聯樣式「我們應該使用一致的樣式方法嗎?」

Individual skills in this repo

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

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相關技能