Communitygithub.com

PhuongDeveloper/landingpage

可扩展的 React 组合模式。适用于重构具有大量布尔属性的组件、构建灵活的组件库或设计可复用的 API。当任务涉及复合组件、渲染属性、上下文提供者或组件架构时触发。包含 React 19 API 变更。

landingpage 是什么?

该技能提供了构建灵活、可维护的 React 组件的关键组合模式。它旨在帮助开发者和 AI 代理避免因大量布尔属性导致的组件膨胀,转而使用复合组件、状态提升和组合内部实现等更优雅的架构方式。技能涵盖组件架构(高优先级)、状态管理、实现模式以及 React 19 的新 API(如用 `use()` 替代 `forwardRef` 和 `useContext()`)。每条规则都包含详细说明、错误/正确代码示例,并按照优先级和类别组织,方便在重构、构建组件库或审查代码架构时快速参考和应用。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/PhuongDeveloper/landingpage/tree/HEAD/.agents/skills/vercel-composition-patterns

在你喜欢的 AI 中提问

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

文档

React 组合模式

用于构建灵活、可维护的 React 组件的组合模式。避免使用大量布尔属性,转而采用复合组件、状态提升和组合内部实现。这些模式使得代码库在扩展时,对人类和 AI 代理都更易于协作。

何时应用

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

  • 重构具有许多布尔属性的组件
  • 构建可复用的组件库
  • 设计灵活的组件 API
  • 审查组件架构
  • 处理复合组件或上下文提供者

按优先级分类的规则类别

优先级类别影响前缀
1组件架构高architecture-
2状态管理中state-
3实现模式中patterns-
4React 19 API中react19-

快速参考

1. 组件架构(高优先级)

  • architecture-avoid-boolean-props - 不要添加布尔属性来自定义行为;使用组合
  • architecture-compound-components - 使用共享上下文构建复杂组件

2. 状态管理(中优先级)

  • state-decouple-implementation - 只有 Provider 知道状态是如何管理的
  • state-context-interface - 定义包含状态、操作、元数据的通用接口,用于依赖注入
  • 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 4 individual skills — each has its own dedicated page.

PhuongDeveloper/landingpage

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

PhuongDeveloper/landingpage

Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector/semantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.

PhuongDeveloper/landingpage

Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies, getSession, getUser, getClaims, RLS); Supabase CLI or MCP server; schema changes, migrations, declarative schemas, security audits, Postgres extensions (pg_graphql, pg_cron, pg_vector); debugging and troubleshooting errors or unexpected behavior on Supabase projects (HTTP errors, Postgres errors, RLS surprises, permission denied, schema cache issues, timeouts, Edge Function crashes, Realtime drops, Storage failures) and reading or querying logs (Logs Explorer, ClickHouse).

PhuongDeveloper/landingpage

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

相关技能