skills/react-project-structure/SKILL.md
React 專案目錄結構。用於 Feature-based 組織、元件分層、共用模組擺放、測試與設定檔配置。
npx skillsauth add vincent119/ai-rules-kit react-project-structureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
依功能模組組織,每個 feature 自包含:
src/
├── app/ # 應用層:路由、Provider、全域設定
│ ├── App.tsx
│ ├── routes.tsx
│ └── providers.tsx
├── features/ # 功能模組(核心業務)
│ ├── auth/
│ │ ├── components/ # 該 feature 專用元件
│ │ │ ├── LoginForm.tsx
│ │ │ └── LoginForm.test.tsx
│ │ ├── hooks/ # 該 feature 專用 hooks
│ │ │ └── useAuth.ts
│ │ ├── api/ # API 呼叫
│ │ │ └── authApi.ts
│ │ ├── types/ # 該 feature 型別
│ │ │ └── index.ts
│ │ ├── utils/ # 該 feature 工具函式
│ │ └── index.ts # 公開 API(barrel export)
│ ├── users/
│ │ ├── components/
│ │ │ ├── UserList.tsx
│ │ │ ├── UserCard.tsx
│ │ │ └── UserList.test.tsx
│ │ ├── hooks/
│ │ │ └── useUsers.ts
│ │ ├── api/
│ │ │ └── usersApi.ts
│ │ └── index.ts
│ └── dashboard/
│ ├── components/
│ ├── hooks/
│ └── index.ts
├── components/ # 全域共用 UI 元件
│ ├── Button/
│ │ ├── Button.tsx
│ │ ├── Button.test.tsx
│ │ └── index.ts
│ ├── Modal/
│ ├── Form/
│ └── Layout/
├── hooks/ # 全域共用 hooks
│ ├── useDebounce.ts
│ ├── useLocalStorage.ts
│ └── useMediaQuery.ts
├── lib/ # 第三方整合與封裝
│ ├── axios.ts # HTTP client 設定
│ ├── queryClient.ts # TanStack Query 設定
│ └── analytics.ts
├── types/ # 全域型別定義
│ └── index.ts
├── utils/ # 全域工具函式
│ ├── format.ts
│ └── validation.ts
├── styles/ # 全域樣式
│ └── globals.css
├── constants/ # 全域常數
│ └── index.ts
└── main.tsx # 進入點
每個元件一個資料夾,包含相關檔案:
components/
└── Button/
├── Button.tsx # 元件本體
├── Button.test.tsx # 測試
├── Button.stories.tsx # Storybook(選用)
├── Button.module.css # 樣式(選用)
└── index.ts # barrel export
index.ts 範例:
export { Button } from './Button';
export type { ButtonProps } from './Button';
packages/
├── web/ # 主要 Web 應用
│ ├── src/
│ ├── package.json
│ └── vite.config.ts
├── ui/ # 共用 UI 元件庫
│ ├── src/
│ │ ├── Button/
│ │ ├── Modal/
│ │ └── index.ts
│ └── package.json
├── shared/ # 共用邏輯(hooks、utils、types)
│ ├── src/
│ └── package.json
├── api-client/ # API client(自動產生或手動)
│ ├── src/
│ └── package.json
├── package.json # workspace root
└── turbo.json # Turborepo 設定
使用 path alias 避免深層相對路徑:
// tsconfig.json
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"],
"@/features/*": ["./src/features/*"],
"@/components/*": ["./src/components/*"]
}
}
}
匯入順序:
// 1. 外部套件
import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
// 2. 全域共用模組
import { Button } from '@/components/Button';
import { useDebounce } from '@/hooks/useDebounce';
// 3. 同 feature 內模組
import { useUsers } from '../hooks/useUsers';
import { UserCard } from './UserCard';
// features/users/index.ts - 只公開必要 API
export { UserList } from './components/UserList';
export { UserCard } from './components/UserCard';
export { useUsers } from './hooks/useUsers';
export type { User } from './types';
// 禁止:跨 feature 直接引用內部檔案
// import { something } from '@/features/auth/components/internal';
// 正確:透過 feature 的 index.ts 引用
// import { LoginForm } from '@/features/auth';
components/;feature 專用元件放 features/<name>/components/.tsx、.test.tsx、index.tsindex.ts barrel export 控制公開 APIindex.ts 公開的內容@/)避免 ../../../ 相對路徑lib/;全域工具放 utils/tools
基於 SLA/SLO 量化評估事故影響的計算模型與業務影響矩陣。適用於「SLA 影響」、「SLO 違反」、「影響評估」、「營收損失估算」、「Error Budget」、「可用性計算」、「事故成本評估」等量化事故業務影響的任務。強化 impact-assessor 的評估能力。注意:事故原因分析與改善規劃不在此技能範圍內。
research
根因分析(RCA)方法論詳細指南。提供 5 Whys、Fishbone 圖、Fault Tree Analysis、變更分析等結構化 RCA 技術,以及認知偏誤防範清單。適用於「根因分析」、「RCA」、「5 Whys」、「魚骨圖」、「Fault Tree」、「原因分析方法論」、「變更分析」等事故原因分析任務。強化 root-cause-investigator 的分析能力。注意:時間軸重建與改善規劃不在此技能範圍內。
testing
事故事後分析(Postmortem)完整流程。協調 7 個執行階段:資訊收集 → 時間軸重建 → 根因分析 → 影響評估 → 改善規劃 → 報告審查 → 整合報告,最終產出完整的 Postmortem 報告。適用於「寫事故報告」、「post-incident 分析」、「RCA 報告」、「事故時間軸整理」、「建立改善措施」等請求。注意:即時 Incident Response(on-call)、監控系統設定、告警配置不在此技能範圍內。
content-media
投影片版面模式庫。提供 20 種投影片類型的最佳版面配置、格線系統、色彩與字型設計 Token。適用於「投影片版面」、「Slide Layout」、「設計系統」、「格線」、「字型」、「色彩規範」等投影片視覺設計任務。強化 visual-designer 的設計能力。注意:PPT/Keynote 檔案直接輸出不在此技能範圍內。