agent-stack-template
AGENTS.md31 starsChanged 3 months agoMITView on GitHub
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in node_modules/next/dist/docs/ before writing any code. Heed deprecation notices. <!-- END:nextjs-agent-rules --> Rename this product in src/lib/app-config.ts, package.json and this file. Everything else is already generic. A production-shaped starting point for a multi-tenant web application, built so that coding agents produce consistent work without being told the same things twice. Conventions live in files an agent reads automatically,…
- Reads credentials
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,843 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 repository20 other files it gives its agents.
- .agents/skills/react-hook-form/AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/git-flow.mdcCursor rule
- .cursor/rules/performance.mdcCursor rule
- .cursor/rules/prisma-schema.mdcCursor rule
- .cursor/rules/project.mdcCursor rule
- .cursor/rules/server-actions.mdcCursor rule
- .cursor/rules/tdd-domain.mdcCursor rule
- .cursor/rules/ui-design-system.mdcCursor rule
- better-auth-best-practicesSkill
- better-auth-security-best-practicesSkill
- changelog-automationSkill
- frontend-designSkill
- interface-designSkill
- marketing-psychologySkill
- organization-best-practicesSkill
- react-hook-formSkill
- shadcnSkill
- vercel-react-best-practicesSkill
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
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
- Distinctive: line 68
If a rule is missing, the spec is Draft, or an ADR would reverse, stop and ask.
- Distinctive: line 73
Leave scope, missing rules and stack changes to the user.
- Very specific: line 127
TDD for business logic only: Test first, in domain/. If the change has no domain rule, TDD does not apply — do not invent a function to …
- Distinctive: line 129
Never test React components, CSS or snapshots.
- Very specific: line 130
Every Server Action re-checks auth: Use defineAction / defineWorkspaceAction from src/lib/action.ts.
- Very specific: line 136
Semantic colour tokens only: No hex, no zinc-* / blue-* in product UI.
- Distinctive: line 138
Money is integer minor units: if the product handles money (ADR-005).
≈ “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.
Files
<!-- BEGIN:nextjs-agent-rules -->This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in node_modules/next/dist/docs/ before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->Agent guide
Rename this product in
src/lib/app-config.ts,package.jsonand this file. Everything else is already generic.
What this repository is
A production-shaped starting point for a multi-tenant web application, built so that coding agents produce consistent work without being told the same things twice. Conventions live in files an agent reads automatically, not in a person's head.
The included projects feature is a reference vertical slice, not a
product. Read it, copy its shape, then delete it.
Every turn
Classify before opening a file. Open one matching guide. Do not read the other playbooks, and do not start from the layer walkthrough until the type is known.
| The request is… | Do this | Do not |
| A problem, audience or outcome, no spec | product-manager → spec Draft | write product code |
| Spec exists but is Draft, or has open questions | resolve with the user; domain-architect if the rules are non-trivial | write product code |
| Spec Accepted or Shipped, new behaviour with a domain rule | new-feature.md | skip the spec |
| Spec Accepted or Shipped, new behaviour with no domain rule (wiring, copy, layout only) | new-feature.md, skip domain tests and domain/ | invent a domain/ function so TDD has a target |
| Spec and code disagree | say which is wrong; fix that one | invent a third rule |
| Current behaviour is wrong | bugfix.md | start a feature |
| Same behaviour, new shape | refactor.md | change a spec rule |
| Tooling, deps, CI, env, docs-only | chore.md | sneak in behaviour; write a domain test |
| Copy, layout, existing actions | ui-ux-developer | put rules in React; TDD the markup |
| Infra, migrations, deploy, secrets | devops-engineer | run destructive commands unasked |
The change does not touch domain/ and adds no business rule | TDD does not apply. npm run verify is the gate | invent a test or a domain wrapper |
If a feature spec is Draft, do not write product code. Accepted and Shipped are the implementable states.
What to open after classify
The matching guide names the next files. Stop there.
| Type | Open | Leave closed |
| Feature with a domain rule | The spec, new-feature.md, tdd-workflow.md | Other guides |
| Feature, no domain rule | The spec, new-feature.md (skip steps 2–3) | tdd-workflow.md |
| Bugfix | bugfix.md, the spec rule that should hold | new-feature.md |
| Refactor | refactor.md | Specs (they do not move with files) |
| Chore / docs | chore.md | Specs, TDD, architecture, stack, DESIGN |
| UI copy / layout | DESIGN.md | tdd-workflow.md |
Open architecture.md only when the work moves a layer, auth, data or performance boundary. Open stack.md only when adding or substituting a dependency. Open an ADR when that decision already exists, or when you must propose a new one.
Small or local models
You implement against a closed contract. You do not invent product.
- Classify, then open the matching guide. Do not skip it. Do not open the others.
- If a rule is missing, the spec is Draft, or an ADR would reverse, stop and ask.
- Copy
src/features/projects/. Do not invent a parallel shape. - TDD only when there is a domain rule. Do not invent a function to test.
npm run verifyis the gate. A red verify is not a suggestion.- Tick the docs DoD row in this file before the hand-off.
- Leave scope, missing rules and stack changes to the user.
Documentation map
Index: docs/README.md. Open the files the router above names, not a reading list.
When sources disagree
A spec beats architecture for a business rule. An ADR beats stack.md for a
decision already taken. Code that contradicts a spec is a bug in one of them —
say which. Never invent a third rule. If a spec is missing detail, update the
spec first, then write the code.
Stack
Details in docs/stack.md. Do not substitute these without an ADR and explicit approval:
- Next.js App Router, React, TypeScript strict, Tailwind, shadcn/ui
- Better Auth for authentication
- Prisma + PostgreSQL
- Zod + React Hook Form, TanStack Query, Zustand (UI state only)
- Vitest for domain tests
Layers
New behaviour with a domain rule (not every turn):
spec → domain tests → domain → services → actions → UIsrc/
domain/ shared pure logic (no framework imports)
features/<name>/ domain/ services/ actions/ schemas/ components/
lib/ env, auth, prisma, session, action helpers
app/ thin routes
components/ui/ shadcn primitives| Layer | May import | Must not |
domain | other domain modules | Next, React, Prisma, Date.now() |
services | domain, Prisma | React, decide user-facing copy |
actions | services, schemas | contain business rules |
components | actions, UI primitives | contain business rules |
Business rules live in domain/. If a calculation or an invariant is written
anywhere else, it is in the wrong place.
Non-negotiables
- TDD for business logic only. Test first, in
domain/. If the change has no domain rule, TDD does not apply — do not invent a function to test. Never test React components, CSS or snapshots. - Every Server Action re-checks auth. Use
defineAction/defineWorkspaceActionfromsrc/lib/action.ts; they enforce session, Zod and workspace membership. A Server Action is a public endpoint. - Every business row carries
workspaceIdand every query filters by it (ADR-003). process.envis read insrc/lib/env.tsonly.- Semantic colour tokens only. No hex, no
zinc-*/blue-*in product UI. - Mobile-first. Base styles target a phone; enrich upward with
sm:/md:. - Money is integer minor units if the product handles money (ADR-005).
- Git Flow. Branch from
develop; never commit tomainordevelop. - Commit only when asked.
Definition of Done — docs
verify green is not the close. Tick the row for this work type. Mark N/A;
do not skip the row.
| After… | Review (N/A if untouched) |
| Feature | Spec still true; add it to docs/README.md if new. Status stays Accepted until the develop → main release PR sets it to Shipped. domain-model.md if a table or rule moved. An ADR only if there was a trade-off. architecture.md only if a documented boundary moved. |
| Bugfix | Spec only if it was wrong or silent. No new spec for a typo. |
| Refactor | architecture.md / domain-model.md only if a documented boundary moved. Do not edit a spec to match a file move. |
| Chore | The document this change made untrue. No new spec. No ADR for a linter version. |
Feature checklist
- Work type classified; matching guide followed
- For new behaviour: spec Accepted or Shipped; acceptance criteria covered
- Domain tests written first and passing if this change adds or breaks a domain rule; otherwise the PR says there is none
- Docs DoD row above ticked (or N/A)
- No business logic in UI, actions or services
- No UI tests
- Every action goes through
defineAction/defineWorkspaceAction - Every new table has
workspaceId+ index +onDelete: Cascade - No
process.envoutsidesrc/lib/env.ts loading.tsxpresent for new(app)segments- New nav destinations added to
nav-config.tsso they get prefetched npm run verifygreen- Branch
feat|fix|chore|refactor|docs/*fromdevelop; PR targetsdevelop
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.

