component-anatomy

Enforces naming, file layout, and barrel conventions for components in libs directories.

23|5|Updated Apr 3, 2025
One-click install
npx skills add https://github.com/LedgerHQ/lumen --skill component-anatomy-ledgerhq
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: component-anatomy
Source: https://github.com/LedgerHQ/lumen/tree/main/.claude/skills/component-anatomy
Command: npx skills add https://github.com/LedgerHQ/lumen --skill component-anatomy-ledgerhq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When creating or restructuring components in a multi-library Nx monorepo, inconsistent naming, misplaced barrels, and missing required files cause review churn and broken public APIs. This Skill encodes the exact folder layout, casing rules, and per-lib file requirements so new code matches the codebase on the first pass. ## Core Features & Use Cases - Naming conventions: PascalCase folders for components, camelCase for utilities and hooks, with one responsibility per file. - Barrel rules: Defines when an index.ts barrel is required (public components, package layers) and when it is an anti-pattern (single-file internal helpers). - Per-lib file matrix: Specifies which files (impl, types, tests, stories, MDX docs, Figma Code Connect) are required for ui-react, ui-rnative, design-core, and utils-shared, including chart exceptions under Components/visualization/. - Use Case: Before scaffolding a new TextInput component in ui-react, load this Skill to generate the correct folder structure with all required files and re-export it from the parent Components barrel. ## Quick Start Ask the assistant to scaffold a new component in libs/ui-react following the component anatomy conventions and verify the folder layout and barrel exports.

Frequently Asked Questions about component-anatomy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a new React component folder in a design system monorepo?▼

Create a PascalCase folder containing the implementation file, a types.ts file, co-located tests, stories, an MDX docs file, and an index.ts barrel exposing the public API. Also re-export the component from the parent Components barrel so it ships from the package root.

When should a folder have an index.ts barrel file?▼

Add a barrel when the folder exposes a public API or re-exports several modules, such as component folders and package layer entry points. Skip it for internal helpers with a single implementation file, where consumers import the file directly.

What files are required for a component in ui-react versus ui-rnative?▼

Both require the implementation, types.ts, tests, co-located stories, and an MDX docs file, plus a .figma.tsx file when the component exists in Figma. React Native stories use an rnative-* ID prefix and charts under Components/visualization have exceptions for stories location and Figma coverage.

Should utility hooks use PascalCase or camelCase folder names?▼

Utilities and hooks use camelCase folders split by responsibility, while only components use PascalCase. A public utility like useControllableState gets a barrel, but a single-file internal helper like useBaseInputValue does not.

Why is importing from a deep path like Button/Button a problem?▼

Deep imports bypass the component's public barrel and couple consumers to internal file structure. When a Button/index.ts barrel exists, always import from the folder barrel so the internal layout can change without breaking consumers.