composition-patterns
Skill39 starsChanged 8 months agoMITView on GitHub
Composition Patterns teaches agents to build flexible, maintainable React components using compound components, state lifting, internal composition, and the elimination of boolean prop proliferation.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- PracticalSwan/agent-skillstheir own version, first seen Sep 14, 2026
- excatt/superclaude-plusplustheir own version, first seen Sep 7, 2026
- sagnikmitra/skillstheir own version, first seen Jun 8, 2026
- itallstartedwithaidea/claude-googleadsagentword for word, first seen May 21, 2026
Other versions4 projects use a version of this.
Word for word · 1
- itallstartedwithaidea/claude-googleadsagent★ 2100% same
Edited · 0
None found.
Wrote their own version · 3
- PracticalSwan/agent-skills★ 18same name
- excatt/superclaude-plusplus★ 14same name
- sagnikmitra/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository74 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- continuous-learningSkill
- entity-memory-managementSkill
- knowledge-base-injectionSkill
- long-horizon-workflowsSkill
- mcp-server-creationSkill
- memory-persistenceSkill
- multi-model-routingSkill
- parallel-agent-orchestrationSkill
- proactive-intelligenceSkill
- token-optimizationSkill
- adversarial-resilienceSkill
- agent-instinct-systemSkill
- anthropic-tool-masterySkill
- cognitive-scaffoldingSkill
- context-engineeringSkill
- multi-harness-portabilitySkill
- prompt-architectureSkill
- self-healing-agentsSkill
- session-archaeologySkill
- verification-loopsSkill
- ad-copy-generationSkill
- audience-targetingSkill
- budget-optimizationSkill
- competitor-analysisSkill
- conversion-trackingSkill
- google-ads-auditSkill
- keyword-researchSkill
- landing-page-auditSkill
- pmax-optimizationSkill
- quality-score-optimizationSkill
- remarketing-strategySkill
- shopping-adsSkill
- ci-cd-pipelinesSkill
- cloudflare-workersSkill
- configuration-managementSkill
- edge-renderingSkill
- observabilitySkill
- service-discoverySkill
- ml-model-integrationSkill
- programmatic-videoSkill
- web-asset-generationSkill
- ai-chat-studioSkill
- assistant-presetsSkill
- batch-processingSkill
- knowledge-base-ragSkill
- low-code-generationSkill
- workflow-orchestrationSkill
- bioinformaticsSkill
- cheminformaticsSkill
- data-analysisSkill
- database-lookupSkill
- geospatial-analysisSkill
- machine-learningSkill
- research-methodologySkill
- scientific-writingSkill
- agent-security-scanningSkill
- codeql-semgrepSkill
- sandbox-hardeningSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 121
Use compound components when sub-elements share implicit state
- Distinctive: line 123
Keep context providers narrow—one context per concern, not one mega-context
- Distinctive: line 125
Document the compositional API with usage examples, not just prop tables
- Distinctive: line 126
Use TypeScript discriminated unions instead of boolean prop combinations
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Composition Patterns
Part of Agent Skills™ by googleadsagent.ai™
Description
Composition Patterns teaches agents to build flexible, maintainable React components using compound components, state lifting, internal composition, and the elimination of boolean prop proliferation. These patterns replace rigid, prop-heavy APIs with composable interfaces that scale gracefully as requirements evolve.
The most common agent mistake in React is building monolithic components with dozens of boolean props: showHeader, showFooter, isCompact, isLoading, hasSearch, enableDarkMode. Each boolean doubles the component's state space, creating an exponential testing surface and making the component impossible to extend without modifying its internals. Composition patterns replace these booleans with structural composition, where the consumer assembles the component from smaller pieces.
This skill addresses four complementary patterns: compound components for related UI families, state lifting for shared cross-component state, internal composition for encapsulated sub-rendering, and render delegation for maximum consumer flexibility. Applied together, these patterns produce components that are simple to use, powerful to customize, and trivial to test.
Use When
- A component has more than 3 boolean configuration props
- Related components need to share implicit state (tabs, accordions, selects)
- The consumer needs to control layout or ordering of sub-elements
- A component needs to support use cases not anticipated at design time
- Refactoring a "god component" into composable pieces
- Building a component library or design system
How It Works
graph TD
A[Component Design Request] --> B{Pattern Selection}
B --> C[Compound: Related UI Family]
B --> D[State Lifting: Shared State]
B --> E[Internal Composition: Sub-render]
B --> F[Render Delegation: Consumer Control]
C --> G[Parent provides context]
G --> H[Children consume context]
D --> I[State lives in nearest common ancestor]
E --> J[Component composes internally]
F --> K[Consumer passes render function]The agent selects the appropriate pattern based on the relationship between components, the degree of consumer control needed, and the complexity of shared state.
Implementation
Compound Components
const TabsContext = createContext<TabsState | null>(null);
function Tabs({ defaultValue, children }: TabsProps) {
const [active, setActive] = useState(defaultValue);
return (
<TabsContext.Provider value={{ active, setActive }}>
<div role="tablist">{children}</div>
</TabsContext.Provider>
);
}
function Tab({ value, children }: TabProps) {
const { active, setActive } = useContext(TabsContext)!;
return (
<button
role="tab"
aria-selected={active === value}
onClick={() => setActive(value)}
>
{children}
</button>
);
}
function TabPanel({ value, children }: TabPanelProps) {
const { active } = useContext(TabsContext)!;
if (active !== value) return null;
return <div role="tabpanel">{children}</div>;
}
Tabs.Tab = Tab;
Tabs.Panel = TabPanel;
// Usage: consumer controls structure
<Tabs defaultValue="a">
<Tabs.Tab value="a">Tab A</Tabs.Tab>
<Tabs.Tab value="b">Tab B</Tabs.Tab>
<Tabs.Panel value="a">Content A</Tabs.Panel>
<Tabs.Panel value="b">Content B</Tabs.Panel>
</Tabs>Eliminating Boolean Props
// BAD: Boolean prop explosion
<Card
showHeader={true}
showFooter={false}
isCompact={true}
hasAvatar={true}
showActions={true}
/>
// GOOD: Compositional API
<Card compact>
<Card.Header>
<Avatar src={user.avatar} />
<Card.Title>{user.name}</Card.Title>
</Card.Header>
<Card.Body>{content}</Card.Body>
<Card.Actions>
<Button>Edit</Button>
<Button>Delete</Button>
</Card.Actions>
</Card>Best Practices
- Use compound components when sub-elements share implicit state
- Expose composable APIs instead of adding boolean flags for new features
- Keep context providers narrow—one context per concern, not one mega-context
- Provide sensible defaults so simple use cases remain simple
- Document the compositional API with usage examples, not just prop tables
- Use TypeScript discriminated unions instead of boolean prop combinations
Platform Compatibility
| Platform | Support | Notes |
| Cursor | Full | Component generation + refactoring |
| VS Code | Full | TypeScript-aware refactoring |
| Windsurf | Full | React pattern recognition |
| Claude Code | Full | Component design guidance |
| Cline | Full | Pattern-based generation |
| aider | Partial | Limited compositional awareness |
Related Skills
- React Best Practices
- View Transitions
- Web Design Guidelines
- Edge Rendering
Keywords
composition compound-components react-patterns state-lifting boolean-props render-delegation design-system composable-api
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

