Agent SkillsAgent Skills
Jasrags

component-patterns

@Jasrags/component-patterns
Jasrags
1
1 forks
Updated 5/5/2026
View on GitHub

Guidelines for organizing React components in Shadow Master. Use when creating new components, deciding between single-file vs subfolder structure, or understanding the component architecture.

Installation

$npx agent-skills-cli install @Jasrags/component-patterns
Claude Code
Cursor
Copilot
Codex
Antigravity

Details

Path.claude/skills/component-patterns/SKILL.md
Branchmain
Scoped Name@Jasrags/component-patterns

Usage

After installing, this skill will be available to your AI coding assistant.

Verify installation:

npx agent-skills-cli list

Skill Instructions


name: component-patterns description: Guidelines for organizing React components in Shadow Master. Use when creating new components, deciding between single-file vs subfolder structure, or understanding the component architecture. allowed-tools: Read, Grep, Glob

Component Organization Patterns

Guidelines for structuring React components in the Shadow Master codebase.

Component Directory Overview

/components/                    # 130+ components total
β”œβ”€β”€ index.ts                    # Root exports (DiceRoller only)
β”œβ”€β”€ *.tsx                       # 6 standalone utility components
β”œβ”€β”€ action-resolution/          # 3 components - dice pool building
β”œβ”€β”€ auth/                       # 1 component - email verification
β”œβ”€β”€ character/                  # 12 components - character sheet display
β”œβ”€β”€ combat/                     # 4 components - combat tracking UI
β”œβ”€β”€ creation/                   # 83 components - character creation
β”‚   β”œβ”€β”€ *.tsx                   # 14 top-level cards
β”‚   β”œβ”€β”€ shared/                 # 14 reusable utilities
β”‚   └── {feature}/              # 17 feature subfolders
β”œβ”€β”€ cyberlimbs/                 # 6 components - augmentation UI
β”œβ”€β”€ sync/                       # 2 components - ruleset sync status
└── ui/                         # 2 components - BaseModal, Tooltip

Decision Flowchart

Does the component have modals?
β”œβ”€ Yes β†’ Create subfolder, extract modals
└─ No β†’ Does it have reusable Row/ListItem components?
        β”œβ”€ Yes, used elsewhere β†’ Create subfolder
        └─ No β†’ Keep as single file with internal helpers

When to Use a Subfolder

Create a subfolder with index.ts when:

  • Component has one or more modals (selection dialogs, forms, etc.)
  • Component has reusable row/list item components used in multiple places
  • Component exceeds ~600 lines with clear separable concerns
  • Component has distinct UI pieces that could be tested independently

Subfolder structure:

/components/{area}/{feature}/
β”œβ”€β”€ FeatureCard.tsx           # Main component
β”œβ”€β”€ FeatureModal.tsx          # Selection/edit modal
β”œβ”€β”€ FeatureRow.tsx            # Optional: if row is complex/reusable
β”œβ”€β”€ constants.ts              # Optional: magic values, options arrays
β”œβ”€β”€ types.ts                  # Optional: feature-specific types
β”œβ”€β”€ utils.ts                  # Optional: feature-specific helpers
β”œβ”€β”€ index.ts                  # Re-exports public API

Index file pattern:

// index.ts - export only public API
export { FeatureCard } from "./FeatureCard";
export { FeatureModal } from "./FeatureModal"; // Only if used externally

When to Keep as Single File

Keep as a single file when:

  • Component is self-contained with only internal helper components
  • Internal components are tightly coupled and only make sense within the parent
  • Component is under ~400 lines with straightforward structure
  • No modals or independently reusable pieces

Component Areas

Root-Level Components (6 files)

Standalone utility components that don't fit a specific feature area:

ComponentPurpose
DiceRoller.tsxDice rolling UI with edge rerolls
AugmentationCard.tsxGeneric augmentation display
EssenceDisplay.tsxEssence tracking visualization
ThemeProvider.tsxDark/light mode context
EnvironmentBadge.tsxEnvironment indicator (dev/staging)
NotificationBell.tsxNotification center UI

/components/ui/ - Shared UI Primitives

Low-level accessible components used across the app. Built on React Aria.

ComponentExports
BaseModal.tsxBaseModal, ModalHeader, ModalBody, ModalFooter
Tooltip.tsxTooltip, TooltipTrigger, TooltipContent, InfoTooltip

When to add here: Generic UI primitives with no business logic.


/components/auth/ - Authentication Components

ComponentPurpose
EmailVerificationBanner.tsxPrompts user to verify email

/components/action-resolution/ - Dice Pool Building

Components for building and displaying action resolution dice pools.

ComponentPurpose
ActionHistory.tsxList of past action rolls
ActionPoolBuilder.tsxConstruct dice pools for actions
EdgeTracker.tsxEdge point tracking and spending

Note: No index.ts - import directly from files.


/components/character/ - Character Sheet Display

Components for viewing active characters (not creation). No index file - import directly.

ComponentPurpose
AdeptPowerList.tsxDisplay adept powers and PP
AutosoftManager.tsxManage vehicle/drone autosofts
CyberdeckConfig.tsxCyberdeck attribute configuration
DroneNetworkManager.tsxRCC drone network management
JumpInControl.tsxVehicle/drone jump-in interface
MagicSummary.tsxMagic rating, tradition, drain
MatrixActions.tsxMatrix action buttons and state
MatrixSummary.tsxMatrix attributes and programs
ProgramManager.tsxRunning programs management
RiggingSummary.tsxRigging stats and VCR mode
Spellbook.tsxSpell list with casting interface
VehicleActions.tsxVehicle action buttons

/components/combat/ - Combat Tracking

Components for running combat encounters. Has index.ts and co-located tests.

ComponentPurpose
CombatTracker.tsxInitiative order and turn management
ActionSelector.tsxAction selection with categories
ConditionMonitor.tsxHealth/damage tracking
OpposedTestResolver.tsxOpposed test dice rolling

/components/cyberlimbs/ - Cyberlimb Management

Components for cyberlimb augmentation display and modification.

ComponentPurpose
CyberlimbCard.tsxIndividual cyberlimb display
CyberlimbList.tsxList all installed cyberlimbs
CyberlimbDetailPanel.tsxDetailed cyberlimb info panel
CyberlimbInstallModal.tsxInstall new cyberlimb
CyberlimbEnhancementModal.tsxAdd attribute enhancements
CyberlimbAccessoryModal.tsxAdd accessories to limb

/components/sync/ - Ruleset Synchronization

Components for displaying ruleset sync status and migration.

ComponentPurpose
StabilityShield.tsxVisual sync status indicator
MigrationWizard.tsxGuide user through ruleset migration

/components/creation/ - Character Creation

The largest component area (83 components). Organized by feature with shared utilities.

Top-Level Cards (14 files)

Single-file cards without complex modals:

CardPurpose
PrioritySelectionCardPriority table selection
AttributesCardAttribute allocation
SkillsCardActive skills management
SpellsCardSpell selection for mages
AdeptPowersCardAdept power selection
ComplexFormsCardTechnomancer complex forms
AugmentationsCardCyberware/bioware selection
VehiclesCardVehicle/drone acquisition
WeaponsPanelWeapon purchases
GearTabsCardTabbed gear interface
DerivedStatsCardCalculated stats display
CharacterInfoCardName, background, description
EditionSelectorEdition selection dropdown
CreationErrorBoundaryError boundary for creation

Feature Subfolders (17 directories)

FolderComponentsPattern
/armor4Panel + Row + PurchaseModal + ModModal
/augmentations44 specialized modals
/contacts3Card + Modal + KarmaConfirm
/foci2Card + Modal
/gear4Panel + Row + 2 Modals
/identities6Card + Identity + 3 modal types
/knowledge-languages5Card + 2 Row types + 2 Modals
/magic-path2Card + Modal + utilities
/matrix-gear2Card + Modal
/metatype2Card + Modal
/qualities3Card + SelectionModal + DetailCard
/shared14Reusable utilities and hooks
/skills10Panel + ListItem + 8 specialized modals
/spells2ListItem + Modal
/vehicles44 specialized modals
/weapons4Row + 3 Modals

Shared Utilities (/creation/shared/)

ComponentPurpose
CreationCard.tsxStandard card wrapper
BudgetIndicator.tsxResource budget display
CardSkeleton.tsxLoading skeleton
EmptyState.tsxEmpty list state
KarmaConversionModal.tsxNuyen ↔ Karma conversion
RatingSelector.tsx1-6 rating picker
Stepper.tsx+/- increment control
SummaryFooter.tsxCard summary footer
ValidationBadge.tsxValidation status indicator
BulkQuantitySelector.tsxQuantity picker for bulk items
LifestyleModificationSelectorLifestyle mod picker
LifestyleSubscriptionSelectorLifestyle subscription picker
useKarmaConversionPrompt.tsHook for karma conversion modal

Adding Components by Area

Adding a Creation Card

  1. Determine structure using the decision flowchart
  2. Create in /components/creation/ or /components/creation/{feature}/
  3. Use CreationCard wrapper from /components/creation/shared/
  4. Add to SheetCreationLayout.tsx in appropriate column
  5. Update CreationState type in /lib/types/creation.ts if needed
  6. Export from /components/creation/index.ts

Adding a Combat Component

  1. Create in /components/combat/
  2. Export from /components/combat/index.ts
  3. Add co-located test in /components/combat/__tests__/

Adding a Character Sheet Component

  1. Create in /components/character/
  2. Import directly from file (no index.ts)
  3. Add to relevant page in /app/characters/[id]/

Adding a Cyberlimb Component

  1. Create in /components/cyberlimbs/
  2. Export from /components/cyberlimbs/index.ts
  3. Export types if needed for external use

Adding a UI Primitive

  1. Create in /components/ui/
  2. Build on React Aria for accessibility
  3. Export from /components/ui/index.ts
  4. No business logic - pure presentation

Adding a New API Endpoint

  1. Create /app/api/{path}/route.ts
  2. Export HTTP method handlers (GET, POST, PUT, DELETE)
  3. Follow authentication pattern (getSession β†’ validate user)
  4. Call storage layer functions
  5. Return JSON responses

Adding a New Ruleset Module

  1. Define module type in /lib/types/edition.ts
  2. Add module to book payload in /data/editions/{editionCode}/
  3. Update merge logic in /lib/rules/merge.ts if special handling needed
  4. Create hook in RulesetContext.tsx for easy access

Key Reference Files

  • components/ui/BaseModal.tsx - Accessible modal foundation
  • components/creation/shared/CreationCard.tsx - Card wrapper pattern
  • components/creation/SkillsCard.tsx - Modal-based editing example
  • components/combat/CombatTracker.tsx - Combat component with tests
  • components/cyberlimbs/index.ts - Feature folder export pattern
  • app/characters/create/sheet/components/SheetCreationLayout.tsx - Three-column layout

Component Diagram Generation

Mermaid diagrams are auto-generated from the component structure.

Commands

# Preview all areas to stdout
pnpm generate-diagrams

# Generate specific area
pnpm generate-diagrams --area=combat
pnpm generate-diagrams --area=creation

# Update documentation files
pnpm generate-diagrams --output=files

# Verbose mode with component counts
pnpm generate-diagrams --verbose

Output Locations

ModeLocation
--output=stdoutPrints to terminal (default)
--output=filesWrites to /docs/architecture/components/

Diagram Color Key

ColorHexComponent TypeNaming Pattern
Blue#3b82f6Container*Card.tsx, *Panel.tsx, *Tracker.tsx
Purple#8b5cf6Modal*Modal.tsx
Green#22c55eRow*Row.tsx, *ListItem.tsx
Orange#f59e0bHookuse*.ts, *Context.tsx
Gray#6b7280SharedEverything else

When to Regenerate

Run pnpm generate-diagrams --output=files after:

  • Adding a new component folder
  • Adding/removing modals or cards
  • Reorganizing component structure
  • Before major documentation updates

Validation

# Validate creation docs structure (doesn't regenerate)
pnpm validate-creation-docs --verbose

Documentation Structure

Hand-Written (detailed)

/docs/architecture/creation-components/ - Detailed creation component docs with:

  • Component descriptions
  • Props documentation
  • Usage patterns
  • Context dependencies

Auto-Generated (overview)

/docs/architecture/components/ - Generated hierarchy diagrams:

  • Mermaid component trees
  • Summary tables
  • Color-coded by type

Index File Conventions

AreaHas index.ts?Reason
/uiYesStable public API
/combatYesCohesive feature set
/cyberlimbsYesCohesive feature set
/syncYesCohesive feature set
/creationYesOrganized by phases
/characterNoLoosely coupled, import directly
/action-resolutionNoLoosely coupled, import directly
/authNoSingle component