Imported from ERP-PreFg-Admin/ERP-Prefg-Tool (
erp_project/AGENTS.md). Install upstream withnpx skills add ERP-PreFg-Admin/ERP-Prefg-Tool --skill erp_project. Copyright stays with the author.
ERP Project Agent Instructions
Next.js 16 App Router + React 19 + TypeScript + Tailwind CSS v4, on MySQL 8.0
(AWS RDS) via mysql2. Prisma 7 is present but schema-only.
CLAUDE.md is the detailed reference. This file is the short version; where
the two disagree, CLAUDE.md wins.
What matters here
- Keep changes aligned with the App Router structure in
app/and the SQL inlib/queries/. - Database access goes through
query/execute/poolfromlib/db.ts. Prisma Client is never used at runtime — there is no Prisma singleton. - Do not edit generated files under
app/generated/prisma/. - Table names were renamed in 2026-08 and
prisma/schema.prismawas not updated. Checklib/queries/*.tsfor the real name, or the mapping in CLAUDE.md — never the Prisma schema. - API routes live under
app/api/v1/./api/authand/api/healthstay unversioned; external systems address them by URL.
Commands to use
npm run dev— start the appnpm run build— verify production buildnpm run lint— full ESLint (~220 pre-existing problems)npm run lint:changed— ESLint on changed files only; this is the gatenpm test— unit tests (node:test, no DB, no credentials)npm run test:db— DB tests, each rolled back
Two gotchas worth knowing before you trust a green check:
npx tsc --noEmitcan report clean on a filenpm run buildthen rejects —tsconfig.jsonhas"incremental": trueand a staletsconfig.tsbuildinfoskips it. Use--incremental falsewhen it matters.npm run buildrefuses to start whilenpm run devis running; Next 16 takes a single lock on.next.- A unit test may only import pure modules. Anything reaching
lib/db,lib/s3orlib/mail/mailerthrows at import without credentials, which is why logic worth testing gets extracted (lib/po-split.ts,lib/invoice/invoice-merge.ts,lib/invoice/invoice-mail-step.ts,lib/mail/recipients.ts,lib/mail/mail-limits.ts,lib/po/po-rules.ts,lib/masters/kit-sku.ts,lib/masters/variant-rm-lock.ts,app/po-tracking/mfg-overview/mapping-state.ts).
There is no db:test / db:generate / db:migrate / db:push / db:seed
npm alias, despite older docs referencing them. Prisma is invoked as raw
npx prisma …, and migrations in practice are the hand-written prisma/*.sql
files applied directly to RDS.
Working conventions
- Prefer TypeScript and existing Next.js patterns over ad-hoc scripts.
- Verify a table or column name against
lib/queries/before using it — the rename left four columns deliberately spelledbom_*. - Keep database access centralized in
lib/db.ts; never import fromapp/generated/prisma/clientin application code. - DB config comes from
DB_HOST/DB_USER/DB_PASSWORD/DB_NAME_TEST|DB_NAME_PROD(seelib/env.ts), notDATABASE_URL.
This project uses a newer Next.js stack than older training examples. If you encounter unexpected behavior, consult the local Next.js docs in node_modules/next/dist/docs/ before making assumptions.