/frontend-react:component-structurefrom frontend-react
Use when creating, editing, restructuring, or reviewing a React frontend component — including its folder layout and file organization (tsx/scss/index), where a component or sub-component should live, BEM class naming, SCSS styling, rem sizing, i18n of user-visible strings, barrel exports, and replacing inline JS style/hover handlers (e.g. onMouseEnter toggling classes) with CSS. Covers "this component file is in the wrong place — fix the structure", moving a flat .tsx into its own folder, and any question about how a component's files, styles, or markup should be organized.
Ships in frontend-react. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
In: creating, editing, restructuring, or reviewing a React component — its folder layout, files, BEM naming, SCSS, rem sizing, i18n, error boundary, and barrel exports.
Out: a kebab-case folder with a PascalCase .tsx, a kebab-case .scss, and an index.ts barrel;
BEM naming; colours/spacing from tokens and sizes in rem; hover states in SCSS not inline handlers;
user-visible strings through i18n; fallible components wrapped in an ErrorBoundary; and a controllable
Storybook story. The checkable expectations are in evals/rubric.json.
Before writing any component code or styles, activate these skills and apply their rules throughout:
frontend-css:scss-modules skill — governs colors, spacing, file extension, variablesfrontend-css:rem skill — governs all dimensional valuesfrontend-css:responsive-layout skill — the acceptance bar that the component renders validly at every breakpoint (no overflow, readable text, discernible images, restrained borders, reflow-not-shrink)Everything in this skill assumes those are already in effect.
Every component — including sub-components — gets its own kebab-case folder with its own .tsx, .scss, and index.ts. No exceptions.
component-name/
ComponentName.tsx ← React component (PascalCase file)
component-name.scss ← BEM styles for this component only
index.ts ← barrel export
Sub-components nest as sibling folders inside the parent folder:
sidebar/
Sidebar.tsx
sidebar.scss
index.ts
sidebar-nav-item/
SidebarNavItem.tsx
sidebar-nav-item.scss
index.ts
sidebar-sub-nav-item/
SidebarSubNavItem.tsx
sidebar-sub-nav-item.scss
index.ts
The parent index.ts re-exports everything public from all sub-component folders:
// sidebar/index.ts
export { Sidebar } from './Sidebar';
export { SidebarNavItem } from './sidebar-nav-item';
export { SidebarSubNavItem } from './sidebar-sub-nav-item';
export type { NavItemData, NavSelectionEvent } from './Sidebar';
No flat sub-components. A component that has its own styles, state, or props is always a folder — never a bare .tsx file sitting alongside the parent.
Block = component root class (matches the folder name).
Element = block__element.
Modifier = block--modifier or block__element--modifier.
.card-item { // Block
&__title { ... } // Element
&__body { ... } // Element
&--active { ... } // Modifier
}
Rules:
:hover, :focus, :disabled) go inside the element or block rule via SCSS &@use '@/styles/variables' as *;
// 1. Optional component-level variables at the top
$item-height: 2.5rem;
// 2. Block
.block-name {
// base styles
// 3. Elements
&__element { ... }
// 4. Modifiers
&--modifier {
// overrides only
.block-name__element { ... }
}
// 5. State
&:hover { ... }
}
Follow frontend-css:scss-modules skill for: colors ($color-* / var(--color-*)),
spacing ($space-*, $radius-*), and file extension (.scss only).
Follow frontend-css:rem skill for: all dimensional values in rem except
border-width, box-shadow offsets, and SVG attributes.
Never use onMouseEnter/onMouseLeave to toggle styles in JS.
All hover/focus/active states must be CSS-only via &:hover etc.
// Wrong
onMouseEnter={(e) => (e.currentTarget.style.background = '#eee')}
// Correct — handled in SCSS
&:hover { background: $color-surface-hover; }
Never hardcode user-visible text in JSX or component logic — route every string through
react-i18next (const { t } = useTranslation('pages/<page>' | 'common')). Page components use the
pages/<page-name> namespace, shared ones use common; add keys to the matching JSON under
src/i18n/locales/en/ (register a new page namespace in src/i18n/index.ts). User-visible = labels,
titles, buttons, placeholders, aria-label, error/empty/loading messages. NOT translated = internal
constants, enum values, log/dev messages, and dynamic API data.
Namespace table, usage + nested-key examples, and the full "counts / doesn't count" lists →
references/i18n.md. See also the i18n:ui-strings skill.
Scope split. This section is the per-component mechanics — wrapping one fallible component in a boundary. The app-wide error-handling architecture (the single code→UX policy table as the sole classifier, the state-dispatcher, the shared error-tile renderer that owns escalation, boundary tiers
- the outer floor, framework bindings) lives in the
error:architectureskill — consult it for the overall pattern and adherence review. Use this section for the component-level wrap.
Any component that fetches data or can otherwise throw at render (a data hook that re-throws its query error, a parse, a lazy import) MUST be isolated by an error boundary, so one failing block never blanks the whole page. Wrap it at its mount site, or export it wrapped:
import { ErrorBoundary, withErrorBoundary } from '@/components/feedback/error-boundary';
// At the mount site:
<ErrorBoundary>
<DataGrid />
</ErrorBoundary>
// …or as the component's own default export (the HOC "decorator"):
export default withErrorBoundary(DataGrid);
The boundary's default fallback reads the app's unified error envelope (shared/errors/codes.ts)
and renders the matching user-friendly tile — AccessDenied for a permission denial, ErrorState
for everything else, with copy resolved by error reason/status. So you never hand-roll error copy per
component. A data hook surfaces its failure by re-throwing the query error into the wrapping boundary
(if (error) throw error).
Every component with an error/fallback (or any multi-state) path gets a Storybook story that
exercises it — but do NOT write one hardcoded export per state. Author one controllable story and
expose the state-driving prop as an argTypes select (options list), so a reviewer flips every
state from the Controls dropdown. That is the whole point of prop-/BEM-state-driven components: one
component, every state reachable through a prop.
// argTypes turns the state prop into a dropdown of every value.
argTypes: { reason: { control: 'select', options: Object.values(REASONS) } },
args: { reason: REASONS.INSUFFICIENT_ACCESS },
render: ({ reason }) => (
<ErrorBoundary>
<ThrowApiError reason={reason} />
</ErrorBoundary>
),
Model props as lists and prefer select / radio / boolean controls over duplicated story
exports. Story mechanics + the yes/no-stories decision live in the frontend-react:storybook-stories
skill.
Any component that renders a useQuery/useSoqlQuery result MUST dispatch through QueryState
(src/components/feedback/query-state/) instead of hand-rolling isLoading / isError / empty
branch trees:
import { QueryState } from '@/components/feedback/query-state';
<QueryState query={someQuery}>
{(data) => <DataGrid rows={data} />}
</QueryState>
QueryState dispatches loading → error → empty → data, rendering ErrorTile for the error branch.
It replaces the boundary's re-throw pattern for data that loads via TanStack Query — use it instead
of (not in addition to) a manual if (error) throw error. It replaces the re-throw IDIOM only — the
component still stays wrapped in its ErrorBoundary; QueryState is not a substitute for the boundary. The full error classification model
(reason/status → tile variant, retry, session-expiry escalation) is documented in
the project's error-format and design-system docs — don't duplicate it here.
Always export:
export { FeatureBlock } from './FeatureBlock';
export { FeatureBlockItem } from './FeatureBlockItem';
export type { FeatureBlockItemData } from './FeatureBlockItem';
.tsx, the style file kebab-case .scss,
and index.ts barrels the component and its public types; BEM holds (block = folder name, &__
elements, &-- modifiers) with no inline onMouseEnter/onMouseLeave — hover lives in SCSS.$color-*/var(--color-*), spacing from $space-*/$radius-*, all sizes in rem,
and it renders validly at every breakpoint (no overflow, readable text, reflow not shrink).useTranslation with keys in the correct src/i18n/locales/en/
file (a new page namespace registered in src/i18n/index.ts); every data/fallible component is
isolated by an ErrorBoundary; and Storybook exercises the error/fallback and other states via a
select-control arg — one controllable story, not per-state exports.useTranslation (and any missed hardcoded ones are fixed too),
BEM is preserved, no new inline hover or hardcoded colour/spacing is introduced, and any new
fetch/throw path sits inside an ErrorBoundary.evals/rubric.json.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub aquivalabs/bladeforge --plugin frontend-react8 skills in this plugin
/component-placementComponent Placement — search first, then decide whereEntry point BEFORE creating ANY React component, in any React codebase — search for an existing one first, decide placement (primitive / feature / layout / page-local), then route to the matching per-type skill. Framework-agnostic: governs component ARCHITECTURE, not any specific UI or styling library. Activate whenever about to add, scaffold, or hand-roll a component, panel, card, widget, or control./feature-componentsFeature Components — domain blocks built from primitivesRules for FEATURE components in a React codebase — domain-coupled blocks that compose primitives and hold business logic/data. Activate when building or editing a domain feature (a panel/table/editor tied to your business data), or adding a new domain area. Framework-agnostic. Reached via frontend-react:component-placement./hooks-registryReact Hooks Registry & ReuseUse when about to add, hand-roll, rename, move, or remove a custom React `use*` hook.