Claude Cursor Skill

split-boolean-props

Use when a React component has too many boolean props, its API is a mess, or a request asks to refactor props, use compound components, or add another mode. Reshapes boolean flags into explicit variants or composed parts, adds the new case without another boolean, and verifies ev

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Download heyvhuang-copybook-skills-plugins_skills_skills_split-boolean-props-c2e4cc2.zip · 8 KB

Install

skills CLI npx skills add https://github.com/Heyvhuang/copybook-skills/tree/main/plugins/skills/skills/split-boolean-props
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install heyvhuang-copybook-skills@llmmart
Git git clone https://github.com/Heyvhuang/copybook-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole heyvhuang/copybook-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Split boolean props into variants and parts

Boolean props multiply fast on shared React components. Each added flag doubles the possible states, hides which combinations are valid, and encourages the next request to add one more flag. Auditing real call sites before editing lets you reshape the API around actual usage so invalid combinations disappear.

1. Audit boolean props and real call sites

Search the repository for every import and usage of the target component, including wrapper components, tests, and stories. Check for prop spreads that forward flags indirectly.

  • List every boolean prop alongside the exact prop combinations call sites pass today.
  • Mark flags that never appear together, flags that toggle structural sections, and combinations no call site uses.
  • Capture a baseline rendered DOM output or snapshot for each distinct call site before editing the component.

2. Group flags into variants and composed parts

Map every audited boolean prop to a clearer shape before writing code:

  • Collapse mutually exclusive appearance or layout flags into one explicit union prop (for example, size="sm" | "md" | "lg" instead of isSmall and isLarge), or split them into dedicated variant components when their markup differs sharply.
  • Replace flags that show or hide structural sections with composed children or named subcomponents (for example, <Banner.Media> and <Banner.Actions> instead of hasIcon and hasActions).
  • Keep a boolean prop only for an independent binary state that combines cleanly with every variant, such as disabled; a state that replaces the content, like loading or empty, becomes a variant value instead.

For each boolean you keep, write one call that pairs it with a variant, part or other kept flag it conflicts with and confirm the typechecker rejects it; if none conflicts, it stays a boolean.

3. Implement the reshaped API and the new case

Refactor the component around the new variant props and composed parts, removing the replaced boolean props and their nested conditional branches. Keep existing markup, class names, and accessibility attributes equivalent so existing call sites stay visually and structurally identical.

Add the newly requested mode, layout, or section as a new variant value, variant component, or composed subcomponent. Do not add another boolean prop for the new case.

4. Migrate every call site and verify parity

Update every call site, wrapper, test, and story found in step 1 to use the reshaped API. Search the codebase again to confirm no references to the removed boolean props remain.

  • Run the typechecker and existing test suite.
  • Compare the rendered DOM or snapshots of every migrated call site against the baseline from step 1, and fix any unintended markup or attribute drift instead of accepting snapshot diffs blindly.
  • Render or test the new case to confirm it works cleanly in the new shape.

Show the user the old-to-new prop mapping, the count of migrated call sites, the before-and-after render parity check, and the check proving the new case renders.

Based on vercel-labs/agent-skills (no licence file at pinned commit, ideas only), rewritten by Copybook.

Files (copybook-skills)
  • CHANGES.md 664 B
    Loading…
  • example.md 1.1 KB
    Loading…
  • LICENSE 18.2 KB · in bundle
  • SKILL.md 3.6 KB
    ---
    name: split-boolean-props
    description: "Use when a React component has too many boolean props, its API is a mess, or a request asks to refactor props, use compound components, or add another mode. Reshapes boolean flags into explicit variants or composed parts, adds the new case without another boolean, and verifies every existing call site renders the same. Not for restructuring modules across a codebase (improve-codebase-structure)."
    license: CC-BY-4.0 (see LICENSE)
    ---
    
    # Split boolean props into variants and parts
    
    Boolean props multiply fast on shared React components. Each added flag doubles the possible states, hides which combinations are valid, and encourages the next request to add one more flag. Auditing real call sites before editing lets you reshape the API around actual usage so invalid combinations disappear.
    
    ## 1. Audit boolean props and real call sites
    
    Search the repository for every import and usage of the target component, including wrapper components, tests, and stories. Check for prop spreads that forward flags indirectly.
    
    - List every boolean prop alongside the exact prop combinations call sites pass today.
    - Mark flags that never appear together, flags that toggle structural sections, and combinations no call site uses.
    - Capture a baseline rendered DOM output or snapshot for each distinct call site before editing the component.
    
    ## 2. Group flags into variants and composed parts
    
    Map every audited boolean prop to a clearer shape before writing code:
    
    - Collapse mutually exclusive appearance or layout flags into one explicit union prop (for example, `size="sm" | "md" | "lg"` instead of `isSmall` and `isLarge`), or split them into dedicated variant components when their markup differs sharply.
    - Replace flags that show or hide structural sections with composed children or named subcomponents (for example, `<Banner.Media>` and `<Banner.Actions>` instead of `hasIcon` and `hasActions`).
    - Keep a boolean prop only for an independent binary state that combines cleanly with every variant, such as `disabled`; a state that replaces the content, like loading or empty, becomes a variant value instead.
    
    For each boolean you keep, write one call that pairs it with a variant, part or other kept flag it conflicts with and confirm the typechecker rejects it; if none conflicts, it stays a boolean.
    
    ## 3. Implement the reshaped API and the new case
    
    Refactor the component around the new variant props and composed parts, removing the replaced boolean props and their nested conditional branches. Keep existing markup, class names, and accessibility attributes equivalent so existing call sites stay visually and structurally identical.
    
    Add the newly requested mode, layout, or section as a new variant value, variant component, or composed subcomponent. Do not add another boolean prop for the new case.
    
    ## 4. Migrate every call site and verify parity
    
    Update every call site, wrapper, test, and story found in step 1 to use the reshaped API. Search the codebase again to confirm no references to the removed boolean props remain.
    
    - Run the typechecker and existing test suite.
    - Compare the rendered DOM or snapshots of every migrated call site against the baseline from step 1, and fix any unintended markup or attribute drift instead of accepting snapshot diffs blindly.
    - Render or test the new case to confirm it works cleanly in the new shape.
    
    Show the user the old-to-new prop mapping, the count of migrated call sites, the before-and-after render parity check, and the check proving the new case renders.
    
    Based on vercel-labs/agent-skills (no licence file at pinned commit, ideas only), rewritten by Copybook.
    

Comments

Sign in to join the conversation.

No comments yet. Start the conversation.

Reviews (0)

No reviews yet.