From 5b8703ba0e7e779b7675fb8cd365f3afa03f96f6 Mon Sep 17 00:00:00 2001 From: gaboesquivel Date: Sat, 5 Sep 2026 14:58:17 -0600 Subject: [PATCH 1/3] chore: install frontend design skills and use-frontend --- .../skills/composition-patterns-v1/README.md | 11 + .../skills/composition-patterns-v1/SKILL.md | 113 +++ .../composition-patterns-v1/metadata.json | 11 + .../references/compiled.md | 946 ++++++++++++++++++ .../rules/_sections.md | 29 + .../rules/_template.md | 24 + .../rules/architecture-avoid-boolean-props.md | 100 ++ .../rules/architecture-compound-components.md | 112 +++ .../patterns-children-over-render-props.md | 87 ++ .../rules/patterns-explicit-variants.md | 100 ++ .../rules/react19-no-forwardref.md | 42 + .../rules/state-context-interface.md | 191 ++++ .../rules/state-decouple-implementation.md | 113 +++ .../rules/state-lift-state.md | 125 +++ .agents/skills/frontend-design-v1/SKILL.md | 11 + .../references/product-ui.md | 35 + .../skills/web-design-guidelines-v1/SKILL.md | 82 ++ .agents/skills/workflow/SKILL.md | 2 + .../skills/workflow/references/completion.md | 1 + .agents/skills/workflow/use-frontend/SKILL.md | 35 + .agents/skills/workflow/use-shadcn/SKILL.md | 1 + .cursor/rules/frontend/design.mdc | 1 + _first/basilic/JOURNEYS.md | 6 +- _first/basilic/QUALITY.md | 1 + _first/basilic/WORKFLOW.md | 2 +- .../content/docs/architecture/frontend.mdx | 4 +- .../content/docs/development/ai-workflow.mdx | 1 + .../docs/development/cursor-skills.mdx | 8 +- packages/ui/README.md | 2 +- 29 files changed, 2189 insertions(+), 7 deletions(-) create mode 100644 .agents/skills/composition-patterns-v1/README.md create mode 100644 .agents/skills/composition-patterns-v1/SKILL.md create mode 100644 .agents/skills/composition-patterns-v1/metadata.json create mode 100644 .agents/skills/composition-patterns-v1/references/compiled.md create mode 100644 .agents/skills/composition-patterns-v1/rules/_sections.md create mode 100644 .agents/skills/composition-patterns-v1/rules/_template.md create mode 100644 .agents/skills/composition-patterns-v1/rules/architecture-avoid-boolean-props.md create mode 100644 .agents/skills/composition-patterns-v1/rules/architecture-compound-components.md create mode 100644 .agents/skills/composition-patterns-v1/rules/patterns-children-over-render-props.md create mode 100644 .agents/skills/composition-patterns-v1/rules/patterns-explicit-variants.md create mode 100644 .agents/skills/composition-patterns-v1/rules/react19-no-forwardref.md create mode 100644 .agents/skills/composition-patterns-v1/rules/state-context-interface.md create mode 100644 .agents/skills/composition-patterns-v1/rules/state-decouple-implementation.md create mode 100644 .agents/skills/composition-patterns-v1/rules/state-lift-state.md create mode 100644 .agents/skills/frontend-design-v1/references/product-ui.md create mode 100644 .agents/skills/web-design-guidelines-v1/SKILL.md create mode 100644 .agents/skills/workflow/use-frontend/SKILL.md diff --git a/.agents/skills/composition-patterns-v1/README.md b/.agents/skills/composition-patterns-v1/README.md new file mode 100644 index 00000000..adb3b2ea --- /dev/null +++ b/.agents/skills/composition-patterns-v1/README.md @@ -0,0 +1,11 @@ +# React Composition Patterns + +Vendored from `composition-patterns` in [vercel-labs/agent-skills](https://github.com/vercel-labs/agent-skills) (MIT). Catalog folder is `composition-patterns-v1`. Basilic overlays live in `SKILL.md` Constraints; rule bodies are upstream. + +## Structure + +- `rules/` — one file per rule +- `metadata.json` — upstream document metadata +- `references/compiled.md` — compiled guide (not `AGENTS.md`; Cursor always-loads that name) + +Upstream update: copy `skills/composition-patterns` from vercel-labs/agent-skills, keep the Basilic `SKILL.md` wrapper, and place compiled output at `references/compiled.md`. diff --git a/.agents/skills/composition-patterns-v1/SKILL.md b/.agents/skills/composition-patterns-v1/SKILL.md new file mode 100644 index 00000000..c2daaf52 --- /dev/null +++ b/.agents/skills/composition-patterns-v1/SKILL.md @@ -0,0 +1,113 @@ +--- +name: composition-patterns-v1 +description: React composition patterns that scale. Use when refactoring boolean-prop APIs, building reusable component libraries, or reviewing compound components, render props, and context. Includes React 19 API changes. +license: MIT +metadata: + author: vercel + version: "1.0.0" +--- + +# React Composition Patterns + +Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. Upstream: `composition-patterns` in [vercel-labs/agent-skills](https://github.com/vercel-labs/agent-skills). + +## Scope + +- Applies to: reusable component APIs, compound components, explicit variants, React 19 ref/`use()` changes +- Does NOT cover: visual direction ([frontend-design-v1](../frontend-design-v1/SKILL.md)); Next.js caching or RSC data fetching ([next-v16](../next-v16/SKILL.md), [vercel-react-v1](../vercel-react-v1/SKILL.md)) + +## Assumptions + +- React 19+ in typical Basilic apps; skip the React 19 rule section on React 18 +- Server/client boundaries already exist; composition must not move server data into client-only providers + +## Principles + +- Prefer composition over boolean configuration for reused components +- Lift client UI state only when siblings need it; keep server data on the server +- Extract shared primitives after a second call site, not for one-off route UI + +## Constraints + +### MUST + +- Extract compound components only for a shared UI package or 2+ call sites, not a single route leaf +- Keep React Server Components fetching their own data; pass server-rendered children into client leaves instead of lifting that data into a client provider +- Leave URL-shareable state, async server state, and grouped local UI state on the libraries the project already uses (query-string parsers, TanStack Query, grouped-state hooks)—do not replace them with a generic context DI layer + +### SHOULD + +- Skip `forwardRef` unless a parent must attach a ref +- Use explicit variant components instead of `isX` boolean modes on reused APIs +- Prefer `children` over `renderX` props + +### AVOID + +- Premature abstractions around a one-off screen +- Client providers whose only job is to re-export RSC-fetched props +- Breaking existing `'use client'` placement to “compose” everything + +## Interactions + +- App Router / RSC: [next-v16](../next-v16/SKILL.md) +- React performance: [vercel-react-v1](../vercel-react-v1/SKILL.md) +- shadcn primitives: [shadcn-v3](../shadcn-v3/SKILL.md) +- URL state: [nuqs-v2](../nuqs-v2/SKILL.md) +- Client async: [tanstack-query-v5](../tanstack-query-v5/SKILL.md) +- Grouped local state: [ahooks-v3](../ahooks-v3/SKILL.md) + +## When to apply + +- Refactoring components with many boolean props +- Building reusable component libraries +- Designing flexible component APIs +- Reviewing component architecture +- Working with compound components or context providers + +## Rule categories by priority + +| Priority | Category | Impact | Prefix | +| --- | --- | --- | --- | +| 1 | Component Architecture | HIGH | `architecture-` | +| 2 | State Management | MEDIUM | `state-` | +| 3 | Implementation Patterns | MEDIUM | `patterns-` | +| 4 | React 19 APIs | MEDIUM | `react19-` | + +## Quick reference + +### 1. Component Architecture (HIGH) + +- `architecture-avoid-boolean-props` — Don't add boolean props to customize behavior; use composition +- `architecture-compound-components` — Structure complex components with shared context + +### 2. State Management (MEDIUM) + +- `state-decouple-implementation` — Provider is the only place that knows how state is managed +- `state-context-interface` — Define generic interface with state, actions, meta for dependency injection +- `state-lift-state` — Move state into provider components for sibling access + +Apply these only where the Constraints above allow. Do not lift server-owned data. + +### 3. Implementation Patterns (MEDIUM) + +- `patterns-explicit-variants` — Create explicit variant components instead of boolean modes +- `patterns-children-over-render-props` — Use children for composition instead of renderX props + +### 4. React 19 APIs (MEDIUM) + +React 19+ only. Skip this section on React 18 or earlier. + +- `react19-no-forwardref` — Don't use `forwardRef`; use `use()` instead of `useContext()` + +## How to use + +Read individual rule files for detailed explanations and code examples: + +``` +rules/architecture-avoid-boolean-props.md +rules/state-context-interface.md +``` + +Each rule file contains why it matters, incorrect and correct examples, and extra context. + +Full compiled guide (do not name this `AGENTS.md`; Cursor always-loads that filename): [references/compiled.md](references/compiled.md) diff --git a/.agents/skills/composition-patterns-v1/metadata.json b/.agents/skills/composition-patterns-v1/metadata.json new file mode 100644 index 00000000..3470b744 --- /dev/null +++ b/.agents/skills/composition-patterns-v1/metadata.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0", + "organization": "Engineering", + "date": "January 2026", + "abstract": "Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale.", + "references": [ + "https://react.dev", + "https://react.dev/learn/passing-data-deeply-with-context", + "https://react.dev/reference/react/use" + ] +} diff --git a/.agents/skills/composition-patterns-v1/references/compiled.md b/.agents/skills/composition-patterns-v1/references/compiled.md new file mode 100644 index 00000000..558bf9aa --- /dev/null +++ b/.agents/skills/composition-patterns-v1/references/compiled.md @@ -0,0 +1,946 @@ +# React Composition Patterns + +**Version 1.0.0** +Engineering +January 2026 + +> **Note:** +> This document is mainly for agents and LLMs to follow when maintaining, +> generating, or refactoring React codebases using composition. Humans +> may also find it useful, but guidance here is optimized for automation +> and consistency by AI-assisted workflows. + +--- + +## Abstract + +Composition patterns for building flexible, maintainable React components. Avoid boolean prop proliferation by using compound components, lifting state, and composing internals. These patterns make codebases easier for both humans and AI agents to work with as they scale. + +--- + +## Table of Contents + +1. [Component Architecture](#1-component-architecture) — **HIGH** + - 1.1 [Avoid Boolean Prop Proliferation](#11-avoid-boolean-prop-proliferation) + - 1.2 [Use Compound Components](#12-use-compound-components) +2. [State Management](#2-state-management) — **MEDIUM** + - 2.1 [Decouple State Management from UI](#21-decouple-state-management-from-ui) + - 2.2 [Define Generic Context Interfaces for Dependency Injection](#22-define-generic-context-interfaces-for-dependency-injection) + - 2.3 [Lift State into Provider Components](#23-lift-state-into-provider-components) +3. [Implementation Patterns](#3-implementation-patterns) — **MEDIUM** + - 3.1 [Create Explicit Component Variants](#31-create-explicit-component-variants) + - 3.2 [Prefer Composing Children Over Render Props](#32-prefer-composing-children-over-render-props) +4. [React 19 APIs](#4-react-19-apis) — **MEDIUM** + - 4.1 [React 19 API Changes](#41-react-19-api-changes) + +--- + +## 1. Component Architecture + +**Impact: HIGH** + +Fundamental patterns for structuring components to avoid prop +proliferation and enable flexible composition. + +### 1.1 Avoid Boolean Prop Proliferation + +**Impact: CRITICAL (prevents unmaintainable component variants)** + +Don't add boolean props like `isThread`, `isEditing`, `isDMThread` to customize + +component behavior. Each boolean doubles possible states and creates + +unmaintainable conditional logic. Use composition instead. + +**Incorrect: boolean props create exponential complexity** + +```tsx +function Composer({ + onSubmit, + isThread, + channelId, + isDMThread, + dmId, + isEditing, + isForwarding, +}: Props) { + return ( +
+
+ + {isDMThread ? ( + + ) : isThread ? ( + + ) : null} + {isEditing ? ( + + ) : isForwarding ? ( + + ) : ( + + )} +