agentleFS
AvinavaAvinava/agentic-react-express-ts/AGENTS.md

agentic-react-express-ts

AGENTS.md0 starsChanged 6 months agoMITView on GitHub

Canonical guide for AI coding agents (Claude Code, Codex, Cursor, Aider, GitHub Copilot, Gemini CLI) working in this repo. CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md all point here. agentic-react-express-ts is a production-ready full-stack TypeScript template designed for the agentic era. It's meant to be: Keep this template simple, clean, and well-documented. When in doubt: fewer features, clearer code. Boundary rules (enforced by ESLint no-restricted-imports): Why: this is how the template makes the server bundle small and prevents secrets/business-logic leaks into the client.

  • Reads credentials
  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository7 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep this template simple, clean, and well-documented.

    line 13
  2. Very specific:

    No any: Use unknown and narrow.

    line 82
  3. Very specific:

    Never modify a test to make it pass: If a test fails, the code is wrong.

    line 99
  4. Very specific:

    Never use --no-verify: If pre-commit hooks fail, read the errors and fix them.

    line 113

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md 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
AGENTS.md

AGENTS.md

Canonical guide for AI coding agents (Claude Code, Codex, Cursor, Aider, GitHub Copilot, Gemini CLI) working in this repo. CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md all point here.

Mission

agentic-react-express-ts is a production-ready full-stack TypeScript template designed for the agentic era. It's meant to be:

  1. Type-safe end-to-end — tRPC carries types from server to client; nothing untyped crosses the wire.
  2. Guardrailed — every commit runs ESLint + TypeScript + Prettier + Knip + Vitest + Gitleaks + Commitlint in parallel (~3s). Failed commits are rejected. See skills/self-correcting-loop/SKILL.md.
  3. Skill-driven — common workflows (add a resource, remove the demo, deploy) live as skills/<name>/SKILL.md files you can read step-by-step.

Keep this template simple, clean, and well-documented. When in doubt: fewer features, clearer code.

Stack

LayerTool
LanguageTypeScript 5.x (strict: true, noUncheckedIndexedAccess)
ClientReact 19 + Vite 7 + MUI 7 + React Router 7
ServerExpress 5 + tRPC 11 (Express adapter)
DataPrisma 7 + PostgreSQL
ValidationZod (via tRPC .input(…))
FormsReact Hook Form + Zod resolver
Server stateTanStack Query (via @trpc/react-query)
TestsVitest 4 + React Testing Library + jsdom
CommitsConventional Commits (commitlint)
Pre-commitLefthook (parallel)

Architecture

src/
├── client/    React app (UI only, no business logic)
├── server/    Express + tRPC routers (all I/O and DB access)
└── shared/    Zod schemas + types reused by both

Boundary rules (enforced by ESLint no-restricted-imports):

  • src/server/** must NOT import from src/client/**.
  • src/client/** must NOT import values from src/server/**. The only allowed cross-tier import is import type { AppRouter } from '@/server/routers' for tRPC's type inference.
  • src/shared/** is the safe shared zone — both sides may import from it freely.

Why: this is how the template makes the server bundle small and prevents secrets/business-logic leaks into the client.

Setup

nvm use                   # Node 22
npm install               # installs deps + lefthook hooks
cp example.env .env       # edit DATABASE_URL
npm run setup             # generate Prisma client
npm run db:setup          # apply migrations
npm run db:seed           # load demo CRM data
npm run dev               # client :3000 + server :3001

Scripts

ScriptWhat it does
npm run devClient + server in parallel (concurrently)
npm run clientVite dev server (:3000)
npm run serverExpress + tRPC via nodemon + tsx (:3001)
npm run buildBuild client (vite build) and server (tsc)
npm run typechecktsc --noEmit for client and server configs
npm run lint / lint:fixESLint
npm run lint:unusedKnip — unused exports/deps
npm run format / format:checkPrettier
npm run test / test:run / test:coverageVitest
npm run db:setup / db:migrate / db:seed / db:studio / db:resetPrisma

Conventions

  • ESM only. import/export, never require. File extensions in imports (.js) — see verbatimModuleSyntax semantics.
  • Functional components only.
  • Custom hooks for data — never call fetch/axios directly in pages; use tRPC hooks (trpc.contact.list.useQuery()).
  • MUI for UI — @mui/material components, sx prop for one-off styling, theme tokens for everything else.
  • Server validation — never trust inputs. Every mutation must define .input(zodSchema).
  • Errors — throw TRPCError({ code, message }). Don't return ad-hoc { success: false } shapes.
  • No any. Use unknown and narrow.
  • Type-only imports. import type { … } for types. ESLint enforces.

Adding a feature

  1. Always start by reading skills/add-resource/SKILL.md — it has the exact, ordered steps for adding a new full-stack CRUD resource.
  2. For one-off changes, mirror an existing resource. The contact resource is the simplest reference (prisma/schema.prisma → src/shared/schemas/contact.ts → src/server/routers/contact.ts → src/client/pages/ContactsPage.tsx).

Testing

npm test            # watch mode
npm run test:run    # one-shot (CI)
  • Client tests use jsdom + RTL. Setup in src/client/__tests__/setup.ts.
  • Server tests use tRPC createCallerFactory with a mocked Prisma client.
  • Never modify a test to make it pass. If a test fails, the code is wrong. See skills/self-correcting-loop/SKILL.md.

Commit style

Conventional Commits. <type>(<scope>): <subject>.

feat(contact): add email validation
fix(server): handle empty body in tRPC mutations
chore(deps): bump prisma to 7.4.1

Types: feat, fix, refactor, docs, test, chore, style, perf, ci.

Never use --no-verify. If pre-commit hooks fail, read the errors and fix them. The whole point of the guardrails is to catch bad commits before they land.

Skills (read these when relevant)

SkillWhen
skills/onboard-an-agent/SKILL.mdFirst time opening this repo
skills/add-resource/SKILL.mdAdding any new CRUD resource
skills/self-correcting-loop/SKILL.mdWhenever a commit is rejected
skills/remove-demo-code/SKILL.mdWhen stripping the demo for a real project
skills/deploy-checklist/SKILL.mdBefore pushing to a deployed env

Key files (quick map)

FilePurpose
src/server/index.tsExpress boot, helmet, CORS, rate limit, tRPC mount, graceful shutdown
src/server/routers/index.tsappRouter — composes contact/task/project routers
src/server/trpc.tsinitTRPC, publicProcedure, createCallerFactory
src/server/context.tsPer-request context (prisma, req, res)
src/client/main.tsxReact entry — providers, router
src/client/trpc.tsxtRPC client + TanStack Query provider
src/shared/schemas/*Zod schemas reused on both sides
prisma/schema.prismaDatabase schema
eslint.config.jsFlat config — strict TS, import order, boundary rules
lefthook.ymlPre-commit pipeline
tsconfig.json / tsconfig.server.jsonClient (bundler) vs server (NodeNext) TS configs

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.