Skip to content
cccskills
FreePublished on GitHub

component-anatomy

Use when creating, naming, or placing a file or folder in libs/*, or when modifying or adding a file to an existing component (even when the barrel isn't touched) — component vs utility naming, the one-responsibility-per-file layout, when a folder needs an `index.ts` barrel (public API only), and the required set of files a component needs per lib. Load this before scaffolding or restructuring a component so the layout matches the codebase.

The English summary is being prepared. Showing the original description.

Works withFigma
See how to install

Files included (1)

  • SKILL.md5.9 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Component & file anatomy

Naming and layout conventions for everything under libs/*. Each responsibility gets its own file. Barrels (index.ts) exist to expose a public API and to re-export several modules from one entry — not on every folder. Which files a component needs depends on the lib — see the table below and the Libraries map in AGENTS.md.

Naming

  • Components live in a PascalCase folder, one file per responsibility.
  • Utilities & hooks live in a camelCase folder, split by responsibility.
  • Everything that is not a component is camelCase.

One responsibility per file

Split implementation, types, tests, stories, docs and Code Connect into separate files rather than one large module. This keeps diffs small and lets each skill (component-styling, component-testing, component-stories, component-mdx, code-connect) attach to the file it owns.

Barrel & re-export

A barrel is an index.ts that export * / export type * a folder's public API. Use one when consumers should import the folder, not a specific file:

  • Package / layer barrels (Components/index.ts, core/index.ts) — the published surface.
  • Component folders (Button/, TextInput/, BaseInput/) — several files (impl, types, sub-parts); the barrel is the import target. Import from that barrel, never from .../Button/Button.
  • A new public component must also be re-exported from its parent Components barrel so it ships from the package root.

Do not add a barrel for every folder. Skip index.ts when the folder is an internal helper with a single implementation file (plus tests). Import the file directly (useMyHook/useMyHook is the pattern; useMyHook/index.ts is the anti-pattern to avoid repeating). A one-file folder does not need a barrel just to re-export that file.

Component folder layout

ComponentName/
├── ComponentName.tsx          # implementation
├── types.ts                   # prop types with JSDoc
├── ComponentName.test.tsx     # tests
├── ComponentName.stories.tsx  # Storybook stories
├── ComponentName.mdx          # Storybook docs
├── ComponentName.figma.tsx    # Figma Code Connect
└── index.ts                   # barrel exposing the public API

Utility / hook folder layout

useControllableState/             # public util — barrel so consumers import the folder
├── useControllableState.ts
├── useControllableState.test.ts
└── index.ts

useBaseInputValue/                # internal helper, one impl file — no barrel
├── useBaseInputValue.ts
└── useBaseInputValue.test.ts

Required files per lib

Not every lib ships the full set. A component addition is complete when it has the files marked required for its lib — do not add (or flag as missing) files a lib does not use.

Libimpl .tsxtypes.ts.test.tsxstories.mdx.figma.tsx
ui-reactrequiredrequiredrequiredco-located .stories.tsxrequiredif in Figma
ui-rnativerequiredrequiredrequiredco-located .stories.tsx (id prefix rnative-*)requiredif in Figma
design-coren/a (tokens, no components)—————
utils-sharedcamelCase util filesco-located or inlinerequired———

Charts live at Components/visualization/ inside ui-react and ui-rnative, exposed only at the /visualization subpath. They follow their lib's row above, with two exceptions: some web stories sit in __stories__/ rather than co-located, and there is no .figma.tsx or .mdx coverage on the React Native side.

Notes:

  • Stories naming — Base (not Default/Primary), {Property}Showcase, With{Feature}; see component-stories. In ui-rnative the Base render is usually explicit (render: (args) => <Component {...args} />).
  • Docs — the two-tab Overview / Implementation structure lives in component-mdx.
  • Disabled state — any component with a disabled state must consume the shared disabled context; see disabled-context.

Review checks

Rules verifiable from a diff. Everything above is authoring guidance.

CheckApplies toDetectSkip
Component folder/file not PascalCase, or utility not camelCaseall libsfolder/file casing vs kind—
Missing index.ts on a public component / package / layer folderall libsnew public component folder with no barrelinternal helper folder (single impl + tests)
Barrel on a single-file internal folderall libsnew index.ts that only re-exports one sibling filepublic component folders; folders that re-export several modules
Import from a deep path instead of a public component barrelall libsfrom '.../Button/Button' when Button/index.ts existsinternal helpers that have no barrel
New component not re-exported from the parent Components barrelui-react, ui-rnativeparent index.ts unchanged—
More than one responsibility in a file (impl + types + stories in one file)all libsstories/types/tests inlined in the impl file—
Required file missing for the lib (see table)per libabsent .test.tsx / .mdx / .figma.tsx where requiredfiles a lib does not use (e.g. .figma.tsx under Components/visualization/)

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Creates and maintains Figma Code Connect files (`*.figma.tsx`) that map Figma components to code via the parser-based `figma.connect()` API. Use when the user mentions Code Connect, Figma component mapping, design-to-code translation, or asks to create/update .figma.tsx files.

The English summary is being prepared. Showing the original description.

LedgerHQ/lumen23Updated Oct 17, 2026

Use when designing or changing a component's public API, its composition, or its state model in libs/ui-react or libs/ui-rnative — layering (core vs internal vs primitives), BaseProps/Props splits, converting a component to compound / changing its composition with createSafeContext, controlled/uncontrolled state, prop-naming conventions, and cross-platform API parity. Load this before shaping a new component, changing its props, or refactoring its composition.

The English summary is being prepared. Showing the original description.

LedgerHQ/lumen23Updated Oct 17, 2026

Use when writing or editing Storybook MDX docs (*.mdx) — the two-tab Overview/Implementation structure, story-backed `<Source>` examples, and doc table guidelines.

The English summary is being prepared. Showing the original description.

LedgerHQ/lumen23Updated Oct 17, 2026

Use when creating or editing Storybook stories (*.stories.tsx, React or React Native) — story layout, controls, and export naming conventions.

The English summary is being prepared. Showing the original description.

LedgerHQ/lumen23Updated Oct 17, 2026

Use when building or styling a component in libs/ui-react or libs/ui-rnative — the cross-platform styling principles, plus routing to the platform mechanics: Tailwind + cva + cn on web, useStyleSheet + themeJS + lx on React Native. Load this before writing component styles.

The English summary is being prepared. Showing the original description.

LedgerHQ/lumen23Updated Oct 17, 2026

Use when writing or editing component tests in libs/ui-react or libs/ui-rnative — shared structure and coverage conventions, plus the per-platform runner: Vitest + React Testing Library on web, Jest + React Native Testing Library on RN. Load this before writing tests.

The English summary is being prepared. Showing the original description.

LedgerHQ/lumen23Updated Oct 17, 2026

See all skills by LedgerHQ

Report a problem with this skill