agentleFS
zdanovichnickzdanovichnick/dotnet-pilot/skills/react-typescript/SKILL.md

react-typescript

Skill5 starsChanged 22 days agoMITView on GitHub

Working in an existing React + TypeScript client of an ASP.NET API — detecting its framework, package manager, test runner and conventions, and the Next.js / Vite gotchas at the API boundary.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Read package.json and the lockfile first.

    line 14
  2. Distinctive:

    Read two or three neighbouring components and one test before writing.

    line 30
  3. Very specific:

    fetch does not reject on 4xx/5xx: Check response.ok, and read the error body as ProblemDetails.

    line 46
  4. Distinctive:

    Test behaviour through the rendered output: query by role and label, act as a user would, assert on what the user sees.

    line 62
  5. Distinctive:

    Never change an existing test to make it pass.

    line 67

≈ “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

React + TypeScript

The frontend counterpart of convention-learner: learn what the app already does, then match it. An existing choice always wins over a default from this file.

Detection

Read package.json and the lockfile first. They answer most of it.

QuestionWhere to look
Frameworknext dependency → Next.js; an app/ folder → App Router, pages/ → Pages Router. vite + react and no next → Vite SPA
Package managerpnpm-lock.yaml → pnpm, yarn.lock → yarn, bun.lock/bun.lockb → bun, package-lock.json → npm. Never mix them: a second lockfile is a broken install for the next person
Scriptsscripts in package.json: the real names for test, lint, typecheck, type generation. Run those, not a guessed command
Test runnervitest or jest dependency; @testing-library/react; playwright/cypress for end-to-end; msw for network mocks
TypeScript strictnesstsconfig.json: strict, noUncheckedIndexedAccess, path aliases (@/*)
Data fetching@tanstack/react-query, swr, RTK Query, or plain fetch in Server Components. Follow the one in use
API clientA generated schema.d.ts, openapi-fetch, orval, NSwag output, or a hand-written wrapper. Find the wrapper and call through it
Forms and validationreact-hook-form, zod, yup, formik
StylingTailwind config, CSS Modules, styled-components/emotion, a component library (shadcn/ui, MUI, Mantine, Ant)
Folder styleFeature folders (features/orders/…) or type folders (components/, hooks/). File naming: OrderList.tsx or order-list.tsx
Repo rulesThe frontend's own CLAUDE.md / AGENTS.md, ESLint and Prettier config. In a two-repository setup the session did not load them

Read two or three neighbouring components and one test before writing. State what was detected in one line, then match it.

References

Load only the one that matches the framework:

FileCovers
references/nextjs.mdServer/client boundary, env variables, rewrites to the API, what unit tests cannot cover
references/vite-spa.mdDev proxy vs production, VITE_ env variables, CORS

Gotchas at the API boundary

  1. Types come from the seam module, not from the component. See skills/api-contract/SKILL.md. A component that declares its own copy of a response type hides contract drift.
  2. fetch does not reject on 4xx/5xx. Check response.ok, and read the error body as ProblemDetails. A wrapper that calls response.json() on a 204 throws.
  3. as is not validation. (await res.json()) as Order asserts; it does not check. The generated types are the check at build time. Add a runtime schema only where the project already uses one.
  4. Every request needs its loading, empty and error path. The contract lists the error statuses; each one is a branch in the UI, not a console.error.
  5. Cancel what the user left. Pass the AbortSignal the data library gives you; a late response must not overwrite newer state.
  6. Auth follows the existing wrapper. A cookie session needs credentials: 'include' and server-side CORS with credentials; a bearer token belongs in the wrapper, never in a component.
  7. Do not start the dev server to check work. Use the typecheck, test and lint scripts; a dev server does not exit.

Tests

  • Test behaviour through the rendered output: query by role and label, act as a user would, assert on what the user sees. No assertions on component internals or state.
  • Mock at the network (msw, or the project's fetch mock) with payloads that match the contract exactly. A mock that returns a shape the API does not is a green test for a broken screen.
  • One test per state the contract creates: success, empty, each error status that has its own UI.
  • Never change an existing test to make it pass.

Do / Don't

DoDon't
Use the scripts and package manager the repo already hasAdd a second lockfile, generator, data library or component library
Keep strict type errors at zero; fix the typeSilence with any, as unknown as, // @ts-ignore
Reuse the shared components and tokensHard-code a colour, spacing value or one-off button
Put contract types in one seam moduleRe-declare response types per component

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.