nextjs-fullstack-ai-toolkit
AGENTS.md0 starsChanged 3 months agoMITView on GitHub
Canonical rulebook for every AI coding assistant working in this repository — Claude Code, Cursor, Copilot, Codex, Gemini, or anything else that reads AGENTS.md. Read this first, then .ai/rules/project-rules.md. Companion documents: - .ai/rules/ — the enforceable rules, including auto-loaded .mdc rules (also mirrored into .cursor/rules/ for Cursor) - .ai/skills/ — the workflows (plan → build → review → audit → debug → PR) - DESIGN.md — the design-system contract (tokens, typography, component contracts) Adopting this toolkit into an existing project?…
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 33,398 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 repository9 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/code-review.mdcCursor rule
- .cursor/rules/debug-systematically.mdcCursor rule
- .cursor/rules/design-audit.mdcCursor rule
- .cursor/rules/generate-pr-description.mdcCursor rule
- .cursor/rules/project-development.mdcCursor rule
- .cursor/rules/project-rules.mdcCursor rule
- .cursor/rules/task-brief.mdcCursor rule
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 0 are common, 6 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
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
- Very specific: line 56
Always verify hook dependency arrays.
- Very specific: line 63
Check components/ui/ before building a new primitive.
- Distinctive: line 64
Prefer composition over deeply nested components and prop drilling.
- Distinctive: line 65
Prefer explicit props over "magic" behavior and hidden side effects.
- Very specific: line 71
Every data-backed route ships loading.tsx and error.tsx.
- Very specific: line 76
Use the singleton DB accessor, never new PrismaClient().
- Very specific: line 77
Every response resolves to the standard ApiResponse<T> envelope.
- Very specific: line 89
No secret is ever exposed behind a NEXT_PUBLIC_ prefix.
- Very specific: line 93
Add it to the theme and DESIGN.md first.
- Distinctive: line 106
No fetching inside loops — batch or filter.
- Distinctive: line 112
Read before editing. Grep for a symbol instead of guessing.
- Distinctive: line 114
Run the gates and report the real output.
- Distinctive: line 116
Don't reintroduce commented-out or dead code as a "quick win" without confirming intent first — it may be deliberately superseded.
- Very specific: line 118
When a symptom is unexplained, get a direct observation of the actual computed value before trying a second speculative fix.
- Very specific: line 126
If this app deploys to a serverless/edge runtime, background work needs the platform's execution extension API (not fire-and-forget), and …
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 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
Project Rules for AI Assistants
Canonical rulebook for every AI coding assistant working in this repository — Claude Code, Cursor,
Copilot, Codex, Gemini, or anything else that reads AGENTS.md. Read this first, then
.ai/rules/project-rules.md.
Companion documents:
.ai/rules/— the enforceable rules, including auto-loaded.mdcrules (also mirrored into.cursor/rules/for Cursor).ai/skills/— the workflows (plan → build → review → audit → debug → PR)DESIGN.md— the design-system contract (tokens, typography, component contracts)
Adopting this toolkit into an existing project? Follow
README.md, then edit the stack section below to describe your actual repo. Everything else works as-is.
Stack assumptions
This toolkit targets a Next.js fullstack application:
- Next.js (App Router) + React + TypeScript in strict mode
- PostgreSQL via Prisma (or an equivalent server-only data layer)
- TanStack React Query for server state; Redux Toolkit (optional) for client UI state
- React Hook Form + Zod for forms and payload validation
- Material UI + Tailwind CSS driven by shared design tokens, with dark mode
- pnpm, ESLint, husky + lint-staged
Adjust the names, keep the boundaries.
Architecture
Client Component
└─ React Query hook (hooks/queries/)
└─ Fetcher (lib/api/fetchers/)
└─ axiosClient / typed HTTP client
↓
proxy.ts | middleware.ts ← session guard, explicit public allow-list
↓
app/api/**/route.ts ← withHandler(schema) only, no logic
↓
server/<domain>/*.controller.ts ← orchestration, authorization, mapping
↓
server/<domain>/*.service.ts ← the ONLY place the DB client is called
↓
getPrisma() → PostgreSQLServer Components (page.tsx) own metadata/SEO. Client Components (Client*.tsx) own
interactive UI. Full lifecycle and a new-module checklist:
.ai/skills/project-development/references/architecture-overview.md.
TypeScript & React
- TypeScript everywhere, strict mode, no
anywithout an inline justification. - Functional components and hooks only;
constoverlet. useMemo/useCallback/memoonly when there is a measurable reason.- Always verify hook dependency arrays. Never use an array index as a
keyfor dynamic lists. - Data fetching goes through React Query hooks — never
fetchinsideuseEffect. - Guard API data with
Array.isArray()before mapping.
Components & Architecture
- Soft limit ~400 lines per file, hard limit ~500 — split before exceeding it.
- Rendering components stay focused on UI; orchestration moves to hooks, business logic to services.
- Check
components/ui/before building a new primitive. Used in 2+ places → extract it. - Prefer composition over deeply nested components and prop drilling.
- Prefer explicit props over "magic" behavior and hidden side effects.
Server / Client Boundary
"use client"only for state, hooks, browser APIs, or event handlers — never on apage.tsx.- Database clients, secrets, mail transports and session signing are server-only and must never be reachable from the browser bundle.
- Every data-backed route ships
loading.tsxanderror.tsx.
API & Data
- Route handlers are thin wrappers around the standard handler, with a Zod schema for every mutating method. Controllers orchestrate. Services own all queries.
- Use the singleton DB accessor, never
new PrismaClient(). - Every response resolves to the standard
ApiResponse<T>envelope. Never swallow an error into a log line and return success. - Select columns explicitly when a row holds secrets. Avoid N+1; batch or
include. Multi-step writes go in a transaction.
No Hardcoded Strings
- Endpoints →
constants/apiEndpoints.ts - Routes →
constants/routes.ts - Query keys →
constants/queryKeys.ts - Env vars →
constants/env.ts(ENVserver-side,CLIENT_ENVforNEXT_PUBLIC_*) - Colors, spacing, radius, fonts → design tokens (see
DESIGN.md)
No secret is ever exposed behind a NEXT_PUBLIC_ prefix.
Styling & Design System
- Theme tokens only — no hex literals, no arbitrary values for themed properties. Missing token?
Add it to the theme and
DESIGN.mdfirst. - Headings use
font-heading; body copy usesfont-sans. - Loading, empty, error and disabled states are part of the UI, not optional extras.
- Accessible by default: real interactive elements, labelled inputs, visible focus, keyboard paths, colour never the only signal.
- Responsive by default; verified in both light and dark themes.
Forms & Validation
react-hook-form+@hookform/resolvers/zod. No complex form state in rawuseState.- Zod schemas live in
lib/validations/schemas.ts; user-facing copy inlib/validations/messages.ts. - The same schema validates the client form and the server payload.
Performance
- No fetching inside loops — batch or filter.
- Siblings needing the same data: lift the fetch to a shared hook or parent.
- Lazy-load heavy views. Avoid unstable object/function references that force re-renders.
Working Discipline
- Implement what was asked; do not widen scope or refactor adjacent code in the same pass.
- Read before editing. Grep for a symbol instead of guessing. Never invent a file, export, column or migration.
- Run the gates and report the real output. "Should work" is not a result.
- Report what you changed and what you skipped, including risky assumptions.
- Don't reintroduce commented-out or dead code as a "quick win" without confirming intent first — it may be deliberately superseded.
- When a symptom is unexplained, get a direct observation of the actual computed value before
trying a second speculative fix. See
.ai/skills/debug-systematicallyand.ai/rules/common-pitfalls.mdc. - See
.ai/rules/agent-discipline.mdcfor the full version.
Rendering & Data
- Render a component, section, or element only when the specific field it depends on is present —
never on the parent object merely existing. See
.ai/rules/data-presence-rendering.mdc. - If this app deploys to a serverless/edge runtime, background work needs the platform's execution
extension API (not fire-and-forget), and nothing may assume in-memory state survives between
invocations. See
.ai/rules/serverless-safe-patterns.mdc. - A credential or role always uses the narrowest scope for what it acts on; a permission at a
narrower scope is capped to the broader baseline, never additive. See
.ai/rules/least-privilege-scoping.mdc.
Which Skills to Use
| Situation | Skill |
| Non-trivial feature, refactor, or architectural change | task-brief |
| Implementing anything | project-development |
| Behavior doesn't match expectation, a bug report, prod-only failure | debug-systematically |
| Before declaring work done | code-review |
| The change touched UI | design-audit |
| Branch is ready for a PR | generate-pr-description |
Definition of Done
- The code implements the requirement without breaking existing patterns.
- It has been validated against
.ai/rules/project-rules.md. code-reviewhas been run; all[BLOCKING]findings are fixed and[HUMAN REVIEW]findings surfaced. UI changes also passeddesign-audit. A bug fix went throughdebug-systematicallyand was verified against the original reproduction, not just against the new code.- The type-check gate passes.
- The lint gate passes (also enforced by husky + lint-staged on commit).
- What changed — and anything skipped — is reported honestly.
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.

