design-system-compound-components — Claude Code rule
design-system-compound-components is a Claude Code rule that forbids raw string children in non-text components. It enforces compound structures like ButtonText and ButtonIcon across the design system.
AGPL-3.0 ★ 88 updated 2026-11-17
.claude/rules/design-system-compound-components.mdWhat design-system-compound-components does
This rule stops the coding agent from creating elements that take raw strings unless the element is explicitly built as a dedicated text node. Whenever an interface block combines containers, icons, and labels, the agent must construct them as compound components.
Rather than typing props as string | React.ReactNode and inspecting the child type at runtime, the guideline requires dedicated subcomponents such as ButtonText and ButtonIcon. This structure keeps props explicit and prevents ambiguous markup.
The rule lives as a standalone Markdown file inside your project settings. It operates without external dependencies or build tools.
What it helps with
- stop ambiguous string children in container components
- split complex UI elements into compound parts
- remove runtime type checking inside children
- keep button and card APIs consistent across a design system
Example prompts for the agent
- Create a button with an icon and label following design system guidelines
- Refactor this card component into compound parts with dedicated text nodes
How to install design-system-compound-components
Manually: put the files in place
.claude/rules/design-system-compound-components.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/design-system-compound-components.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/design-system-compound-components.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/design-system-compound-components.mdManually: put the files in place
.clinerules/design-system-compound-components.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about design-system-compound-components
How to install design-system-compound-components in Claude Code?
Add the rule contents to .claude/rules/design-system-compound-components.md in your project repository.
What does design-system-compound-components do?
It prevents polymorphic child props by requiring raw text to sit inside dedicated subcomponents like ButtonText instead of generic container wrappers.
Which UI frameworks does this rule target?
It primarily targets React and React Native codebases where native containers like Pressable must not receive bare strings.