Skip to documentation

Design system / Sources & standards

Current repository source

SKILL.md

.opencode/skills/frontend-component-architecture/SKILL.md

This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.

---
name: frontend-component-architecture
description: Classify, implement, refactor, or review React frontend components, instances, hooks, Context, and client state under CreativeXHub's atomic-design and server-first rules. Use when adding or changing frontend components, reviewing frontend PRs, or preparing frontend work for /shipit.
metadata:
  author: creativexhub
  version: "1.1"
---

# Frontend Component Architecture

## Canonical decisions

Follow ADR-0030 for design tokens, ADR-0031 for component taxonomy and instances, and ADR-0032 for client behavior and state escalation. If an existing implementation conflicts, preserve behavior and make the smallest migration that moves it toward these decisions.

## Component change workflow

This is the canonical before-and-after workflow for every requested frontend component addition, change or refactor. It includes atoms, molecules, organisms and product instances, regardless of their directory.

### Before implementation

1. Read the applicable accepted ADRs, repository instructions, theming rules and frontend development guidance.
2. Check the proposed change against component ownership, composition, server boundaries and state rules below.
3. Reuse canonical components and theme tokens. Check typography, reading rhythm, spacing and interaction conventions where affected.
4. Resolve architectural or theming conflicts before implementation. Use `architecture-decision-log-entry` only when an architectural decision changes; component work alone does not require a new ADR.

### Before completion

1. Compare the implemented components with their public documentation under `src/app/(public)/design-system/`. Include affected parent molecules and organisms, not only directly edited files.
2. Document new components at the appropriate design-system level. Internal helpers may be explained through their owning composition instead of receiving standalone pages.
3. Update existing pages and live examples to display the current implementation. Use actual component imports, not copied markup or outdated approximations.
4. Update affected usage guidelines, supported props, composition, styling notes, state ownership, accessibility and interaction descriptions.
5. Keep public examples fictional and safe. Where a real workflow requires authorization or external operations, explain that boundary and use the established read-only or context-required presentation. Do not add tenant requests or expose private configuration to complete a specimen.
6. Load and apply `asd-ste100` before writing or revising documentation. Apply additional writing skills when the relevant project guidance requires them. Preserve exact identifiers and behavior; do not claim formal style certification.
7. Verify documentation against source and select focused checks through `quality-gate`. A changelog or README entry alone does not replace public design-system documentation.
8. Report each affected component as **Updated**, **Already accurate**, or **Not applicable**. Include its source path, documentation routes/files, writing skills used, and a reason for either no-update status.

Do not declare the work complete with unresolved architectural/theming violations, materially stale examples or missing required usage documentation. Material writing-guide violations must also be corrected; minor wording suggestions are not automatic merge blockers.

## Required classification

Before creating or materially changing frontend code, state the answers to these questions in the work summary or PR review:

1. What is the component taxonomy: foundation, atom, molecule, organism, template, page/route, or product instance?
2. Who owns it: shadcn-derived foundation, navigation, a named feature, or a route?
3. Is it product-neutral enough for `src/components/ui/`?
4. What is the server/authorization boundary, and how does client behavior receive its initial data and mutation contract?
5. Which state hierarchy level applies: URL, server, local state, behavior hook, reducer, Context, or client store?

## Placement rules

- Keep tokens, typography, motion, icons, and layout rules in `src/theming/`; they are design foundations, not atoms.
- Use `src/components/ui/` only for shadcn-derived or shadcn-quality generic components with no domain vocabulary, API paths, tenant assumptions, or business rules.
- Put feature-owned UI, hooks, contracts, and view adapters together under that feature. Do not promote a component merely because it is currently reused twice; promote it when its cross-feature API is stable.
- Use templates for layout and slots only. Do not add fetching, authorization, or business policy to templates.
- Keep pages and layouts as server and authorization boundaries. They set rendering intent and supply authorized initial data.

## Product instance rules

- An instance is a named adapter that binds an abstract component to product copy, navigation, Context, domain-to-view adapters, and product behavior hooks.
- Keep a durable or cross-route instance beside the abstract component in `instances/`.
- Keep a one-route assembly with route-specific data or transient composition in the owning route or feature.
- An instance must not duplicate the abstract component's markup or styles, perform route authorization, or call raw API endpoints.
- Make changes to shared visual structure and styling in the abstract component so every instance receives them.

## State and hook rules

- Use URL state for shareable navigation state and server boundaries for authorized initial data. A server boundary may call a domain module or an internal API contract.
- Keep trivial view state in its component.
- Create a colocated `use...` hook from the first implementation for external effects/subscriptions, asynchronous request or mutation lifecycle, or coordinated multi-step interactions. Return state and commands; never JSX.
- Use a reducer for related event-driven transitions that are clearer than multiple independent setters.
- Use Context only for a stable value many descendants of one bounded subtree need. Do not use it as a feature store, for server data, or to bypass one or two prop levels.
- Do not introduce a client store unless disconnected branches or routes must coordinate one client domain with persistence, undo, or cross-surface optimistic updates. Escalate that decision to a new ADR.

## Review checklist

- [ ] The component's layer and owner match its responsibility.
- [ ] `components/ui` contains no product/domain behavior.
- [ ] An instance adapts an abstract component instead of copying its structure or styles.
- [ ] Route authorization and initial server loading remain outside client instances and hooks.
- [ ] Request lifecycle, subscriptions, or multi-step interactions have a behavior hook.
- [ ] Context is bounded and ambient rather than a hidden feature store.
- [ ] No new global client store was added without a dedicated ADR.
- [ ] Token-backed semantic classes and existing shadcn accessibility conventions are used.
- [ ] Targeted tests cover behavior hooks and affected interactive UI.
- [ ] The component change workflow is complete, including source-verified public documentation, current live examples and writing-skill evidence.

## Trigger points

- Load this skill before any requested React component addition, change or refactor, including visual-only changes.
- Load it when reviewing a PR that changes `src/components/`, client components under `src/app/`, `src/hooks/`, or frontend state boundaries.
- Load it during `/shipit` when the current diff includes those paths.

## References

- `docs/decisions/ADR-0030-design-token-architecture-for-cxhub-base-theme.md`
- `docs/decisions/ADR-0031-frontend-component-taxonomy-and-product-instances.md`
- `docs/decisions/ADR-0032-client-behavior-and-state-escalation.md`
All sources and standards
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.