agentleFS
krivooxkrivoox/agent-stack-template/AGENTS.md

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

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
  1. Distinctive:

    If a rule is missing, the spec is Draft, or an ADR would reverse, stop and ask.

    line 68
  2. Distinctive:

    Leave scope, missing rules and stack changes to the user.

    line 73
  3. Very specific:

    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 …

    line 127
  4. Distinctive:

    Never test React components, CSS or snapshots.

    line 129
  5. Very specific:

    Every Server Action re-checks auth: Use defineAction / defineWorkspaceAction from src/lib/action.ts.

    line 130
  6. Very specific:

    Semantic colour tokens only: No hex, no zinc-* / blue-* in product UI.

    line 136
  7. Distinctive:

    Money is integer minor units: if the product handles money (ADR-005).

    line 138

≈ “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
<!-- 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.json and 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 thisDo not
A problem, audience or outcome, no specproduct-manager → spec Draftwrite product code
Spec exists but is Draft, or has open questionsresolve with the user; domain-architect if the rules are non-trivialwrite product code
Spec Accepted or Shipped, new behaviour with a domain rulenew-feature.mdskip 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 disagreesay which is wrong; fix that oneinvent a third rule
Current behaviour is wrongbugfix.mdstart a feature
Same behaviour, new shaperefactor.mdchange a spec rule
Tooling, deps, CI, env, docs-onlychore.mdsneak in behaviour; write a domain test
Copy, layout, existing actionsui-ux-developerput rules in React; TDD the markup
Infra, migrations, deploy, secretsdevops-engineerrun destructive commands unasked
The change does not touch domain/ and adds no business ruleTDD does not apply. npm run verify is the gateinvent 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.

TypeOpenLeave closed
Feature with a domain ruleThe spec, new-feature.md, tdd-workflow.mdOther guides
Feature, no domain ruleThe spec, new-feature.md (skip steps 2–3)tdd-workflow.md
Bugfixbugfix.md, the spec rule that should holdnew-feature.md
Refactorrefactor.mdSpecs (they do not move with files)
Chore / docschore.mdSpecs, TDD, architecture, stack, DESIGN
UI copy / layoutDESIGN.mdtdd-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 verify is 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 → UI
src/
  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
LayerMay importMust not
domainother domain modulesNext, React, Prisma, Date.now()
servicesdomain, PrismaReact, decide user-facing copy
actionsservices, schemascontain business rules
componentsactions, UI primitivescontain 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 / defineWorkspaceAction from src/lib/action.ts; they enforce session, Zod and workspace membership. A Server Action is a public endpoint.
  • Every business row carries workspaceId and every query filters by it (ADR-003).
  • process.env is read in src/lib/env.ts only.
  • 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 to main or develop.
  • 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)
FeatureSpec 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.
BugfixSpec only if it was wrong or silent. No new spec for a typo.
Refactorarchitecture.md / domain-model.md only if a documented boundary moved. Do not edit a spec to match a file move.
ChoreThe 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.env outside src/lib/env.ts
  • loading.tsx present for new (app) segments
  • New nav destinations added to nav-config.ts so they get prefetched
  • npm run verify green
  • Branch feat|fix|chore|refactor|docs/* from develop; PR targets develop

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.