agentleFS
gabriellstgabriellst/codm/.claude/skills/component/SKILL.md

component

Skill4 starsChanged 2 months agoMITView on GitHub

Create a route-scoped component that owns its own data. Lives in <route>/-components/, reads URL/store state directly, fetches via SDK hooks. Routes through a react / astro child based on the working directory.

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the file path is ambiguous, ask the user once and don't proceed until they answer.

    line 19
  2. Distinctive:

    Every component is responsible for the data it renders.

    line 23

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Create Route-Scoped Component (parent)

A component in this codebase is the unit one step above primitives and one step below routes: it composes primitives, owns its data, and reads its own params. The two platforms (react web app, astro landing/blog) share the same mental model — they differ in how params come in and what they render against.

Platform routing (READ FIRST)

Detect platform from the working directory and load only the matching child:

Working file pathUse
packages/app/react/**/*.tsx./react/SKILL.md + ./react/registry.yaml — TanStack Router routeApi.useSearch(), Base UI primitives
packages/app/astro/**/*.astro or *.tsx./astro/SKILL.md + ./astro/registry.yaml — .astro components, React islands with client:*

If the file path is ambiguous, ask the user once and don't proceed until they answer. Never duplicate platform-specific guidance into this parent file.

Core mental model (cross-platform)

Every component is responsible for the data it renders. The component reads params, fetches data, and handles mutations internally. The parent route does NOT push data into it via props.

NeedSourceHow
URL state (filters, selected ID, page)Route's URL params APIReact: routeApi.useSearch() · Astro: Astro.url.searchParams (frontmatter)
Update URL stateRoute navigation APIReact: routeApi.useNavigate() · Astro: <a href> / full reload
Client state (UI toggles, selections)Zustand storeuseStore(s => ...) — react only; Astro components are stateless unless on a React island
Server dataReact Query / SDK hookuseListX(...) / useGetX(...) — react; Astro fetches in frontmatter (build-time or SSR)
MutationsReact Query / SDK hookuseMutation(...) — react; Astro is read-only (forms POST to an api route or React island)

No prop drilling of data, search params, or callbacks on the interactive platform. React Query deduplicates — if multiple components call the same query, only one network request fires. On Astro, props flow top-down at render time but no client state survives navigation.

Decision rule: owns query vs receives props

"Am I rendered N times in a .map()?"

  • No → component owns its query. Reads IDs from store/params, calls SDK hook.
  • Yes → component receives a single item as a prop. Parent owns the list query and maps items.
ProductList (owns query — rendered once)
  └── ProductCard ({ product } — rendered N times)

Leaf components (cards, rows, badges) are reusable + testable because they only depend on their props. They CAN own mutations (a delete button on a card) but should NOT re-fetch the item they already received.

Shared principles (apply on ALL platforms)

  1. Component owns data — fetches what it renders, never receives data= as a prop from a route.
  2. Two param sources only — URL state or client state. No useState for things a user could share via deep link.
  3. Primitive first — check the platform's components/ui/ folder before reaching for raw HTML / RN primitives / Astro tags.
  4. Open/Closed Principle — never hardcode lists of options in JSX. Derive options from SDK Enums + a labels map.
  5. DRY local — repeated JSX in the same file → extract a local component (don't ship it as a primitive unless reused elsewhere).
  6. Accessibility / testability — icon-only triggers need an accessible label (react: aria-label, astro: aria-label on the rendered HTML). Form fields connect their input to their label by ID.
  7. Folder per component — ComponentName/index.tsx (NOT ComponentName.tsx) for react; ComponentName.astro (single file) is acceptable for astro components that don't have subleaves.
  8. Stories / previews are private — -stories/ (or equivalent) only; never export a XSkeleton.

Folder structure (shared convention)

<route>/                       # react: route folder; astro: pages/ folder
├── (route entry)              # react: index.tsx; astro: index.astro
├── -components/                # react: route-private components; astro: relative imports
│   ├── ComponentName/
│   │   ├── index.tsx          # react
│   │   └── SubLeaf/index.tsx
│   └── ComponentName.astro    # astro
├── -stores/                    # react only (Zustand)
└── -hooks/                     # react only

Platform differences (deep dive in each child)

ConcernReactAstro
Read URL stateconst routeApi = getRouteApi('/(app)/products/'); routeApi.useSearch()const { searchParams } = Astro.url (frontmatter)
Navigate / update URLrouteApi.useNavigate()<a href>; client islands navigate via window.location
Primitive folder@codm/app-ui/ (lowercase-kebab files)src/components/ (.astro files; islands as .tsx)
Modal patternsDialog, AlertDialog global storesn/a — landing pages don't host modals; use a React island
Icons@tabler/icons-react (IconX)Inline <svg> or astro-icon
Empty state primitiveEmpty / EmptyHeader / EmptyTitle / EmptyMediaStatic markup
Skeleton primitiveSkeleton from @codm/app-ui/skeletonn/a — Astro is render-time; no skeletons
Interactivity boundaryAlways interactiveStateless by default; opt into client:* on a React island

When to use this skill

  • Building any route-specific UI component (list, panel, card, dialog shell, filter bar, landing section).
  • Adding inline skeleton loading states (react).
  • Extracting repeated JSX into a local or nested component.

When NOT to use this skill

  • Reusable design system component → /primitive
  • New page / screen / astro page → /route
  • Form with validation → /form (react only)
  • State management → /store (react only)

Modal with data input (react): use /form for the form. This skill covers the shell and layout.

Checklist (parent-level, before reading the child)

  • Platform identified from working directory (or asked the user).
  • Reading only the matching child SKILL + registry.
  • Component goes in <route>/-components/ (react) or the appropriate src/components/ location (astro).
  • Decided owns-query-vs-receives-prop based on "Am I rendered N times in a .map()?".

Once the platform is settled, jump to the matching child for the full guide.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.