node-express-boilerplate
AGENTS.md36 starsChanged 4 months agoMITView on GitHub
Canonical instructions for AI coding agents working in this repository. CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md are symlinks to this file — edit only this file. Reusable workflows live in .agents/skills/ (source of truth; .claude/skills/ contains symlinks into it). Prefer a skill when the request matches one: Project workflows: Reference guidance: When no skill matches, follow this file directly. Node.js 22+ · Express 5 · TypeScript 6 (strict) · Prisma 7 + PostgreSQL 16 · Zod v4 · Pino · JWT (HttpOnly…
- Reads credentials
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 33
When no skill matches, follow this file directly.
- Distinctive: line 37
Keep edits small and localized.
- Very specific: line 39
After code changes, run pnpm full-check and the most relevant test suite before finishing.
- Very specific: line 93
Never read process.env directly.
- Very specific: line 94
Never use console.*; use src/config/logger.ts.
- Very specific: line 95
Never send ad-hoc error responses from controllers.
- Very specific: line 98
Prefer ?? over || for nullish handling.
- Very specific: line 110
Update prisma/schema.prisma, then run pnpm prisma:migrate and pnpm prisma:generate.
- Very specific: line 120
Add OpenAPI docs in src/docs/.
- Very specific: line 121
Run pnpm full-check and relevant tests.
- Very specific: line 125
Run pnpm prisma:generate after every Prisma schema change.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 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.
Files
AGENTS.md
Canonical instructions for AI coding agents working in this repository. CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md are symlinks to this file — edit only this file.
Read First
- Project overview and architecture: README.md
- Setup and contributor workflow: CONTRIBUTING.md
Skills
Reusable workflows live in .agents/skills/ (source of truth; .claude/skills/ contains symlinks into it). Prefer a skill when the request matches one:
Project workflows:
new-resource— scaffold a complete API resource end to endupdate-schema— Prisma schema change + migration + client regen + downstream updatesadd-middleware— create and wire Express middlewareadd-test— scaffold unit and integration tests for a resourceadd-openapi-docs— document endpoints insrc/docs/(schemas, paths, registration)security-audit— project-specific security review (auth, CSRF, limits, validation, secrets)
Reference guidance:
prisma-client-api,prisma-database-setup,prisma-postgres— Prismavitest— Vitest testing patternsapi-design-principles— REST API designnodejs-best-practices— Node.js patterns and decision-makingmulti-stage-dockerfile— optimized Dockerfilestypescript-magician— advanced TypeScript typingfind-skills— discover and install new skills
When no skill matches, follow this file directly.
Working Style
- Keep edits small and localized; avoid broad refactors unless explicitly requested.
- Preserve current architecture and naming conventions.
- After code changes, run
pnpm full-checkand the most relevant test suite before finishing.
Stack
Node.js 22+ · Express 5 · TypeScript 6 (strict) · Prisma 7 + PostgreSQL 16 · Zod v4 · Pino · JWT (HttpOnly cookies) · CSRF (double-submit cookie) · Vitest · pnpm
Required Commands
# Development
pnpm dev
pnpm build
pnpm start
# Quality gate (run before finalizing changes)
pnpm full-check
# Focused checks
pnpm lint
pnpm format
pnpm type-check
pnpm knip # dead code / unused deps (enforced in CI)
# Prisma
pnpm prisma:migrate
pnpm prisma:migrate:deploy
pnpm prisma:generate
pnpm prisma:db:seed
# Tests
pnpm test
pnpm test:integration
pnpm test:all
pnpm db:test:up
pnpm db:test:migrate
pnpm db:test:downPackage manager is pnpm only. Never use npm or yarn.
Architecture Contract
Layering is strict and one-directional:
Routes → Controllers → Services → Repositories → Prisma- The DI container in
src/container/index.tsis the only place to instantiate concrete classes. - Route classes resolve controllers via
this.container.get<Name>Controller(). src/index.tsbinds the port only;src/app.tshandles middleware and route mounting.
Non-Negotiable Rules
- Never read
process.envdirectly; usesrc/config/env.ts. - Never use
console.*; usesrc/config/logger.ts. - Never send ad-hoc error responses from controllers; throw typed errors from
src/errors/and let global middleware format responses. - No
any, no floating promises, and useimport typefor type-only imports. - Public class methods and properties must have explicit return types.
- Prefer
??over||for nullish handling.
Implementation Patterns
- Controller handlers should be arrow-function properties to preserve
thisbinding. - Validation should be Zod v4 in
src/validations/using helpers fromsrc/lib/validate.ts. - Repository
update/deleteoperations must wrap Prisma calls in try/catch and pass errors throughhandlePrismaError. - Apply
doubleCsrfProtectionon all mutating routes (POST,PUT,PATCH,DELETE). - Attach route-group-specific limiters from
src/middleware/limiter.middleware.ts.
New Resource Order
- Update
prisma/schema.prisma, then runpnpm prisma:migrateandpnpm prisma:generate. - Add
src/types/<name>.types.ts. - Add
src/validations/<name>.validation.ts. - Add
src/repository/<name>.repository.ts. - Add
src/services/<name>.service.ts. - Add
src/controllers/<name>.controller.ts. - Add
src/routes/<name>.route.ts. - Register in
src/container/index.ts. - Mount in
src/app.tsat${config.BASE_URL}/${config.API_VERSION}/<resource>. - Update barrel exports.
- Add OpenAPI docs in
src/docs/. - Run
pnpm full-checkand relevant tests.
Common Gotchas
- Run
pnpm prisma:generateafter every Prisma schema change. - Integration tests require test DB setup (
pnpm db:test:upandpnpm db:test:migrate). - CSRF token comes from
GET /api/v1/auth/csrf-tokenand must be sent asx-csrf-token.
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 28,693 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 repository18 other files it gives its agents.
- .cursor/rules/architecture.mdcCursor rule
- .cursor/rules/conventions.mdcCursor rule
- add-middlewareSkill
- add-openapi-docsSkill
- add-testSkill
- api-design-principlesSkill
- find-skillsSkill
- improveSkill
- multi-stage-dockerfileSkill
- new-resourceSkill
- nodejs-best-practicesSkill
- prisma-client-apiSkill
- prisma-database-setupSkill
- prisma-postgresSkill
- security-auditSkill
- typescript-magicianSkill
- update-schemaSkill
- vitestSkill
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.

