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
- JasonPaff/clarifytheir own version, first seen Feb 4, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 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.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ai-dev-workflowCopilot instructions
- loop-engineeringSkill
- pm-clarifySkill
- pr-prepSkill
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
- Very specific: line 12
No
any: Use unknown and narrow it. - Distinctive: line 20
Functional components only: No class components.
- Distinctive: line 23
No prop mutation: Treat props as readonly. Same for external state.
- Distinctive: line 56
No CSS-in-JS, no Tailwind.
- Very specific: line 60
Never: call fetch directly. Never import axios directly.
- Very specific: line 61
Use the shared Axios instance: import { client } from 'src/api/client'.
- Very specific: line 68
Every new hook: a co-located .test.tsx is required.
- Very specific: line 69
Every new interactive component: a co-located .test.tsx is required.
- Distinctive: line 70
Test contracts and behavior: what renders, what handlers fire, what API call is made.
- Distinctive: line 71
Do not: test internal state. Do not snapshot whole component trees.
- Very specific: line 76
Add an e2e/[feature].spec.ts only for new critical user flows.
- Distinctive: line 82
If the requested change requires any of these, STOP and flag it to the user before writing:
≈ “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.
Files
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. Useunknownand narrow it. If a type is genuinely uncertain at a boundary, type the boundary, not the consumer. interfaceovertypefor 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:
useCamelCaseinside[feature].hook.ts. - Files:
kebab-caseexcept components (PascalCase.tsx). - CSS Modules:
[Component].module.css.
Styling — CSS Modules only
- Co-locate
[Component].module.cssnext 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
fetchdirectly. Neverimport axiosdirectly. - Use the shared Axios instance:
import { client } from 'src/api/client'. - Wrap each resource in
src/api/[resource].api.tsand export typed functions. Interfaces for request and response — neverany. - 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.tsxis required. - Every new interactive component: a co-located
.test.tsxis 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.tsonly 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:
anytype anywhere.- Raw
fetch(...)in feature code. - Inline static styles.
- New barrel re-exports.
- A new npm dependency.
- Mutating props or external state.
console.login 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.tsvia an[resource].api.tsmodule. - File is under 250 lines.
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
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.

