joabgonzalez/ai-agents-skills/composition-pattern
Claude Code and agent skill by joabgonzalez/ai-agents-skills
- community
Checking that the SKILL.md file is still in the repository.
Composition Over Configuration for flexible component design. Trigger: When building reusable UI components with flexible, consumer-controlled APIs.
Install
npx vskill@latest install joabgonzalez/ai-agents-skills/composition-patternSKILL.md
The same SKILL.md was published earlier as joabgonzalez/ai-agents-skills/composition-pattern.
Composition Pattern
Build flexible, reusable UI by accepting dynamic content instead of configuration props. Components define structure; consumers provide content.
When to Use
- Building reusable component libraries or design systems
- Layout components (cards, modals, tabs, accordions) with variable content
- Components that need flexible content slots
- Reducing prop drilling through composition
Don't use for:
- Simple one-off components with fixed content
- Components with no content variation between uses
Critical Patterns
✅ REQUIRED: Children/Slots Over Configuration Props
Accept content dynamically — don't enumerate content via props.
Rule: If content varies between uses, accept children/slots instead of individual props.
Framework implementations:
- React:
childrenprop + namedReactNodeprops for slots - Vue/Svelte/Astro/Web Components:
<slot>elements withnameattribute - Angular:
<ng-content select="[slot-name]">
✅ REQUIRED: Named Slots for Multiple Content Areas
When a component has distinct content regions, use named slots.
✅ REQUIRED: Compound Components (Shared State)
Related components that share implicit state — attach sub-components to parent.
Internal state flows through Context (React) or provide/inject (Vue) — consumers never manage it explicitly.
✅ REQUIRED: Headless Components
Separate behavior from styling. Export logic; consumer provides all UI.
✅ REQUIRED: Polymorphic Components (as/tag Prop)
Let consumers control the rendered HTML element or component type.
Use when the component's visual style is fixed but the HTML element varies by context (semantic correctness, accessibility, SEO). Never hard-code the element when it varies across use sites.
❌ NEVER: Prop Explosion
Decision Tree
Example
Building a composable Card component with named slots for header, body, and footer.
Patterns applied: children as default slot, named ReactNode props for distinct regions, optional slots (header && ...), consumer controls all content.
Edge Cases
Render props vs children: Use render props when consumer needs access to internal state (e.g., renderItem={(item) => <Item data={item} />}).
Compound without Context: For 2-3 immediate children, React.Children.map works. For 4+ or deeply nested, use Context.
Type-safe generics: Parameterize render callbacks with generics (List<T>) to preserve type safety on the content consumer provides.
Resources
- react/references/composition.md — React implementation: children, compound, headless, polymorphic
- astro/references/composition.md — Astro implementation: named slots, fallback content, conditional slots
- react/references/context-patterns.md — Context API + compound components deep dive
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/composition-pattern/SKILL.md
Popularity
- Repository stars
- 9
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/joabgonzalez/ai-agents-skills/composition-pattern)