vercel-composition-patterns — скилл для Claude Code: React-композиция
Свод правил, по которым агент переводит React-компоненты с Boolean props на compound components и общий контекст.
npx skills add vercel-labs/agent-skills --skill vercel-composition-patterns -a claude-code
npx skills add vercel-labs/agent-skills --skill composition-patterns -a claude-codeЧто делает vercel-composition-patterns
Скилл даёт агенту четыре категории правил по композиции React-компонентов, разложенные по приоритету и помеченные префиксами: architecture-, state-, patterns-, react19-. Наверху архитектура, потому что расползание boolean-пропсов начинается именно там.
Каждое правило лежит отдельным файлом в rules/, например rules/architecture-avoid-boolean-props.md и rules/state-context-interface.md. Внутри — зачем это нужно, пример плохого кода с разбором и правильный вариант. Есть собранный документ AGENTS.md со всеми правилами сразу: его проще отдать агенту, чем гонять его по отдельным файлам.
Категория react19- работает только на React 19 и выше: там отказ от forwardRef и замена useContext() на use(). На React 18 её пропускают. Ставить стоит, если у компонентов уже выросли флаги вида isCompact, withHeader и hideFooter, а API библиотеки приходится перекраивать под каждый новый случай. Если в проекте пара простых форм, можно обойтись без него.
Какие задачи решает
- разобрать компонент с десятком Boolean props и разложить его на части
- собрать compound component с общим контекстом для селекта или модалки
- вынести состояние в провайдер, чтобы соседние компоненты его видели
- заменить render props на children в существующем API
- убрать forwardRef после перехода на React 19
Примеры запросов агенту
- Отрефактори `Modal`: у него семь boolean-пропсов, разложи на compound components
- Проверь компоненты в `src/components/ui` и убери `forwardRef`, проект на React 19
- Спроектируй API для `Tabs` так, чтобы состояние жило в провайдере
Как установить vercel-composition-patterns
1Через Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill vercel-composition-patterns -a claude-codenpx skills add vercel-labs/agent-skills --skill composition-patterns -a claude-code2Вручную: положить файлы
~/.claude/skills/composition-patterns/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/composition-patterns/
1Через Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a codex2Вручную: положить файлы
.agents/skills/composition-patterns/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a cursor2Вручную: положить файлы
.cursor/skills/composition-patterns/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install vercel-labs/agent-skills composition-patterns2Вручную: положить файлы
.github/skills/composition-patterns/SKILL.md1Через Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a gemini-cli2Командой платформы
gemini skills install https://github.com/vercel-labs/agent-skills --path skills/composition-patternsВручную: положить файлы
.devin/skills/composition-patterns/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add vercel-labs/agent-skills --skill composition-patterns -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Из того же набора6
Весь набор →Похожие
Вопросы о vercel-composition-patterns
Как установить vercel-composition-patterns в Claude Code?
Командой npx skills add vercel-labs/agent-skills --skill composition-patterns -a claude-code. Файл появится в ~/.claude/skills/composition-patterns/SKILL.md. Для Codex, Cursor, Gemini CLI и OpenCode в той же команде меняется значение флага -a.
Что делает vercel-composition-patterns?
Даёт агенту правила архитектуры React-компонентов: уход от boolean-пропсов, compound components на общем контексте, состояние в провайдере, явные варианты вместо режимов.
Нужен ли React 19 для этого скилла?
Только для категории react19- с правилами про forwardRef и use(). Остальные три категории применимы и на более старых версиях React.
Исходный текст
SKILL.md · MIT
--- name: vercel-composition-patterns description: React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. 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. These patterns make codebases easier for both humans and AI agents to work with as they scale. ## When to Apply Reference these guidelines when: - 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 ### 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 if using 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: - Brief explanation of why it matters - Incorrect code example with explanation - Correct code example with explanation - Additional context and references ## Full Compiled Document For the complete guide with all rules expanded: `AGENTS.md`
© vercel · MIT · vercel-labs/agent-skills