agentleFS
rgaddargadda/frontend-eng-team/skills/component-conventions/SKILL.md

component-conventions

Skill8 starsChanged 4 months agoMITView on GitHub

Load this when creating or modifying a React component, hook, or feature module. Covers functional-only React 18, TS strict (no any, interfaces over types, explicit return types), CSS Modules with variables from src/styles/variables.css, Axios via src/api/client.ts, feature-colocated file layout, and co-located Jest+RTL tests. Triggers — "new component", "add component", "create hook", "refactor component", "modify feature", "build a form".

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. JasonPaff/clarify★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository6 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    No any: Use unknown and narrow it.

    line 12
  2. Distinctive:

    Functional components only: No class components.

    line 20
  3. Distinctive:

    No prop mutation: Treat props as readonly. Same for external state.

    line 23
  4. Distinctive:

    No CSS-in-JS, no Tailwind.

    line 56
  5. Very specific:

    Never: call fetch directly. Never import axios directly.

    line 60
  6. Very specific:

    Use the shared Axios instance: import { client } from 'src/api/client'.

    line 61
  7. Very specific:

    Every new hook: a co-located .test.tsx is required.

    line 68
  8. Very specific:

    Every new interactive component: a co-located .test.tsx is required.

    line 69
  9. Distinctive:

    Test contracts and behavior: what renders, what handlers fire, what API call is made.

    line 70
  10. Distinctive:

    Do not: test internal state. Do not snapshot whole component trees.

    line 71
  11. Very specific:

    Add an e2e/[feature].spec.ts only for new critical user flows.

    line 76
  12. Distinctive:

    If the requested change requires any of these, STOP and flag it to the user before writing:

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “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

Component Conventions — playbook

Apply these rules to any component or hook you write or modify in this repo. Run in the main context — these are convention reminders, not a delegated task.

TypeScript

  • No any. Use unknown and narrow it. If a type is genuinely uncertain at a boundary, type the boundary, not the consumer.
  • interface over type for object shapes (props, API payloads, domain entities).
  • Explicit return types on every exported function and hook. Internal helpers can infer.
  • Enums for finite state, not string literal unions. enum OrderStatus { Pending = 'pending', ... }.
  • Props interface named [ComponentName]Props, colocated in the same file as the component.

React

  • Functional components only. No class components.
  • Custom hooks for any logic that touches state or effects. Hook file: [feature].hook.ts.
  • No component file over 250 lines. Split into subcomponents or extract a hook.
  • No prop mutation. Treat props as readonly. Same for external state.
  • No inline anonymous components inside render — define them at module scope.

File layout (feature-colocated)

src/features/[feature-name]/
  index.ts              # public API of the feature (named exports only, NOT a barrel)
  [Feature].tsx         # main component
  [Feature].test.tsx    # co-located unit test
  [Feature].module.css  # co-located styles
  [feature].hook.ts     # extracted stateful logic
  [feature].types.ts    # feature-local types
  • Shared building blocks go in src/shared/components/, src/shared/hooks/, src/shared/styles/, src/shared/types/.
  • API resources live in src/api/[resource].api.ts.
  • E2E tests live in e2e/[feature].spec.ts.

Naming

  • Components: PascalCase.tsx.
  • Hooks: useCamelCase inside [feature].hook.ts.
  • Files: kebab-case except components (PascalCase.tsx).
  • CSS Modules: [Component].module.css.

Styling — CSS Modules only

  • Co-locate [Component].module.css next to the component.
  • Pull colors, spacing, typography from CSS custom properties defined in src/styles/variables.css. Do not hardcode hex values or px spacing for theme tokens.
  • Semantic class names: .container, .actionBar, .errorMessage — never .blueBox, .mt-20.
  • No inline style={{ ... }} unless the value is computed at runtime (e.g., a transform driven by drag position). Static styling goes in the CSS Module.
  • Media queries live inside the component's CSS Module.
  • No CSS-in-JS, no Tailwind.

HTTP

  • Never call fetch directly. Never import axios directly.
  • Use the shared Axios instance: import { client } from 'src/api/client'.
  • Wrap each resource in src/api/[resource].api.ts and export typed functions. Interfaces for request and response — never any.
  • Components never call Axios directly. Go through an API module or a custom hook that wraps it.
  • Endpoint-specific error handling lives in try/catch at the call site; cross-cutting concerns (auth, retries) live in Axios interceptors.

Testing (Jest + React Testing Library)

  • Every new hook: a co-located .test.tsx is required.
  • Every new interactive component: a co-located .test.tsx is required.
  • Test contracts and behavior: what renders, what handlers fire, what API call is made.
  • Do not test internal state. Do not snapshot whole component trees.
  • Mock at the module boundary: jest.mock('../api/orders.api').

E2E (Playwright)

  • Add an e2e/[feature].spec.ts only for new critical user flows.
  • Selectors: data-testid="..." — never CSS classes or DOM structure.
  • Each test is independent. No shared state.

What to refuse / flag (hard non-negotiables)

If the requested change requires any of these, STOP and flag it to the user before writing:

  • any type anywhere.
  • Raw fetch(...) in feature code.
  • Inline static styles.
  • New barrel re-exports.
  • A new npm dependency.
  • Mutating props or external state.
  • console.log in code intended for commit.
  • Leaving the file in a state that does not type-check.

Before you finish

  • Ran the typecheck mentally — every exported function has an explicit return type.
  • Co-located test is in place for any new hook or interactive component.
  • CSS Module exists; no inline static styles; variables from src/styles/variables.css.
  • HTTP goes through src/api/client.ts via an [resource].api.ts module.
  • File is under 250 lines.

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.