Skip to main content
rule CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/design-system-compound-components.md
Open on GitHub

What 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.md

The paths frontmatter field limits the files

Step 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.

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set47

The whole set →
list-performance-images list-performance-images is a Claude Code rule for loading appropriately sized images in lists. It applies when editing interfaces that display image thumbnails. CX Codex +1 ★ 88repo stars imports-design-system-folder imports-design-system-folder is a Claude Code rule that forbids importing UI packages directly into application code. All components must pass through a local design system directory. CX Codex +1 ★ 88repo stars ui-pressable ui-pressable is a Claude Code rule for choosing touch components in React Native. It applies when an agent adds or edits buttons and list items. CX Codex +1 ★ 88repo stars ui-safe-area-scroll ui-safe-area-scroll is a Claude Code rule that enforces native iOS safe area handling in React Native ScrollViews. It stops layout jumping during keyboard transitions. CX Codex +1 ★ 88repo stars ui-expo-image ui-expo-image is a Claude Code rule that swaps React Native's default Image for expo-image. It guides code generation toward blurhash placeholders, disk caching, and list recycling. CX Codex +1 ★ 88repo stars js-hoist-intl js-hoist-intl is a Claude Code rule that moves Intl formatter creation out of renders and loops. It applies to JavaScript code that formats dates, numbers, or relative time. CX Codex +1 ★ 88repo stars react-state-fallback react-state-fallback is a Claude Code rule that enforces reactive fallbacks instead of copying props into component state. It prevents stale UI bugs during parent updates. CX Codex +1 ★ 88repo stars list-performance-virtualize list-performance-virtualize is a Claude Code rule that recommends virtualized lists for scrollable content. It applies while building list-based screens. CX Codex +1 ★ 88repo stars

Project sponsors

Companies that keep this analytics open