Communitygithub.com

alfathafp/portofolio-web-design

可擴展的 React 組合模式。用於重構有大量布林屬性的元件、建立彈性的元件庫,或設計可重複使用的 API。在處理複合元件、渲染屬性、Context Provider 或元件架構的任務時觸發。包含 React 19 API 變更。

portofolio-web-design 是什麼?

這個技能提供了一套 React 組合模式,用於建立靈活且可維護的元件,避免因過度使用布林屬性而導致的混亂。它專注於透過複合元件、狀態提升和內部組合等技巧來提升程式碼的可擴展性,讓程式碼庫對人類開發者和 AI 代理都更友善。技能涵蓋了四個優先級別的模式:高優先級的元件架構(如避免布林屬性和使用複合元件)、中等優先級的狀態管理(如解耦實作和定義 Context 介面)、中等優先級的實作模式(如使用明確的變體元件和 Children 組合),以及針對 React 19 以上的 API 變更(如不再使用 forwardRef,改用 use())。每個模式都包含詳細的規則文件,解釋其重要性、不正確與正確的程式碼範例,適合在重構大型元件庫或設計新 API 時參考。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/vercel-composition-patterns

在你喜歡的 AI 中提問

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

說明文件

React 組合模式

用於建立靈活、可維護的 React 元件的組合模式。避免透過使用複合元件、狀態提升和內部組合來過度擴張布林屬性。這些模式能讓程式碼庫在擴展時,對人類和 AI 代理都更易於理解與操作。

何時套用

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

  • 重構包含許多布林屬性的元件時
  • 建立可重複使用的元件庫時
  • 設計彈性的元件 API 時
  • 審查元件架構時
  • 處理複合元件或 Context Provider 時

按優先級分類的規則

優先級類別影響前綴
1元件架構高architecture-
2狀態管理中state-
3實作模式中patterns-
4React 19 API中react19-

快速參考

1. 元件架構(高優先級)

  • architecture-avoid-boolean-props - 不要為了自訂行為而新增布林屬性;請使用組合
  • architecture-compound-components - 使用共享 Context 來結構化複雜元件

2. 狀態管理(中優先級)

  • state-decouple-implementation - Provider 是唯一知道狀態如何管理的地方
  • state-context-interface - 定義包含 state、actions、meta 的通用介面,以支援依賴注入
  • state-lift-state - 將狀態移至 Provider 元件中,方便兄弟元件存取

3. 實作模式(中優先級)

  • patterns-explicit-variants - 建立明確的變體元件,而非使用布林模式
  • patterns-children-over-render-props - 使用 children 進行組合,而非 renderX 屬性

4. React 19 API(中優先級)

⚠️ 僅限 React 19+。 若使用 React 18 或更早版本,請跳過此節。

  • react19-no-forwardref - 不要使用 forwardRef;請使用 use() 代替 useContext()

如何使用

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

rules/architecture-avoid-boolean-props.md
rules/state-context-interface.md

每個規則檔案包含:

  • 為何重要的簡要說明
  • 不正確的程式碼範例及說明
  • 正確的程式碼範例及說明
  • 其他相關資訊與參考資料

完整彙整文件

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

Individual skills in this repo

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

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

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".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

相關技能