architecture-avoid-boolean-props — Claude Code rule
The architecture-avoid-boolean-props rule keeps component variants out of boolean props and moves them into composition. Use it when conditional UI branches start spreading across a component.
MIT ★ 7,191 updated 2026-10-24
.claude/rules/architecture-avoid-boolean-props.mdWhat architecture-avoid-boolean-props does
The rule advises against props such as isThread, isEditing, and isDMThread as switches for component behavior. Every added boolean expands the state space and makes the conditions harder to maintain. Separate compositions make each variant explicit instead of hiding several modes inside one parent.
The example keeps shared pieces in Composer.Frame, Composer.Header, Composer.Input, and Composer.Footer. ChannelComposer, ThreadComposer, and EditComposer then choose their own children and actions. Shared internals remain reusable, while the rendered structure is visible in each variant.
A component built around conflicting flags will accumulate branching logic, so this rule is a direct warning against that architecture choice.
What it helps with
- remove boolean switches from components
- split UI variants into explicit compositions
- replace nested conditional branches
- show each component state through its structure
Example prompts for the agent
- Review
Composerand replaceisThread,isEditing, andisDMThreadwith composition. - Refactor
ChannelComposer,ThreadComposer, andEditComposerso each one declares its own parts. - Find conflicting boolean props in this component and suggest a structure without mode switches.
How to install architecture-avoid-boolean-props
Manually: put the files in place
.claude/rules/architecture-avoid-boolean-props.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/architecture-avoid-boolean-props.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/architecture-avoid-boolean-props.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/architecture-avoid-boolean-props.mdManually: put the files in place
.clinerules/architecture-avoid-boolean-props.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about architecture-avoid-boolean-props
How do I install architecture-avoid-boolean-props in Claude Code?
Copy the rule to .claude/rules/architecture-avoid-boolean-props.md.
What does architecture-avoid-boolean-props do?
It guides Claude Code away from boolean props that select component modes. The rule favors separate compositions built from shared pieces.
Why avoid boolean props in a component?
Each boolean adds more possible states, and conditional branches become harder to maintain as flags accumulate. Composition keeps each variant explicit.
Source text
architecture-avoid-boolean-props.md · MIT
---
title: Avoid Boolean Prop Proliferation
impact: CRITICAL
impactDescription: prevents unmaintainable component variants
tags: composition, props, architecture
---
## Avoid Boolean Prop Proliferation
Don't add boolean props like `isThread`, `isEditing`, `isDMThread` to customize
component behavior. Each boolean doubles possible states and creates
unmaintainable conditional logic. Use composition instead.
**Incorrect (boolean props create exponential complexity):**
```tsx
function Composer({
onSubmit,
isThread,
channelId,
isDMThread,
dmId,
isEditing,
isForwarding,
}: Props) {
return (
<form>
<Header />
<Input />
{isDMThread ? (
<AlsoSendToDMField id={dmId} />
) : isThread ? (
<AlsoSendToChannelField id={channelId} />
) : null}
{isEditing ? (
<EditActions />
) : isForwarding ? (
<ForwardActions />
) : (
<DefaultActions />
)}
<Footer onSubmit={onSubmit} />
</form>
)
}
```
**Correct (composition eliminates conditionals):**
```tsx
// Channel composer
function ChannelComposer() {
return (
<Composer.Frame>
<Composer.Header />
<Composer.Input />
<Composer.Footer>
<Composer.Attachments />
<Composer.Formatting />
<Composer.Emojis />
<Composer.Submit />
</Composer.Footer>
</Composer.Frame>
)
}
// Thread composer - adds "also send to channel" field
function ThreadComposer({ channelId }: { channelId: string }) {
return (
<Composer.Frame>
<Composer.Header />
<Composer.Input />
<AlsoSendToChannelField id={channelId} />
<Composer.Footer>
<Composer.Formatting />
<Composer.Emojis />
<Composer.Submit />
</Composer.Footer>
</Composer.Frame>
)
}
// Edit composer - different footer actions
function EditComposer() {
return (
<Composer.Frame>
<Composer.Input />
<Composer.Footer>
<Composer.Formatting />
<Composer.Emojis />
<Composer.CancelEdit />
<Composer.SaveEdit />
</Composer.Footer>
</Composer.Frame>
)
}
```
Each variant is explicit about what it renders. We can share internals without
sharing a single monolithic parent.
© tech-leads-club · MIT · tech-leads-club/agent-skills