# Package Scripts Cleanup Audit

## Scope

- reviewed `package.json`
- reviewed `scripts/**`
- reviewed `src/db/seeds/**`
- reviewed `docs/operations/system-bootstrap.md`
- cross-checked historical references in `docs/implementation/**` and setup copy

## Decision Summary

| Script Name | Current Command | Status | Reason | Replacement Command |
| --- | --- | --- | --- | --- |
| `dev` | `next dev` | keep | core runtime entrypoint | - |
| `build` | `npm run verify:encoding && next build` | keep | build already guards encoding drift | - |
| `start` | `next start` | keep | production runtime entrypoint | - |
| `lint` | `oxlint` | keep | active lint entrypoint | - |
| `lint:fix` | `oxlint --fix && bun format` | keep | active fix workflow | - |
| `lint:strict` | `oxlint --deny-warnings` | keep | stricter CI-style lint path | - |
| `format` | `oxfmt --write .` | keep | active formatter entrypoint | - |
| `format:check` | `oxfmt --check .` | keep | active formatter verification | - |
| `prepare` | `husky` | keep | install hook bootstrap | - |
| `typecheck` | `tsc --noEmit` | add | required by task and docs verification flow | - |
| `gen` | `npm run verify:encoding && npx drizzle-kit generate` | remove | duplicate of `db:generate` with unclear shorthand | `npm run db:generate` |
| `db:generate` | `npx drizzle-kit generate` | keep | canonical drizzle generate command | - |
| `db:migrate` | `npx drizzle-kit migrate` | keep | canonical drizzle migrate command | - |
| `db:studio` | `npx drizzle-kit studio` | keep | canonical drizzle studio command | - |
| `db:reset` | `node --experimental-strip-types scripts/db/reset-database.ts` | keep | guarded destructive operation with env safety | - |
| `db:setup` | `npm run db:migrate && npm run seed:system` | keep | still referenced by setup flow and valid | - |
| `db:setup:uat` | `npm run db:setup && npm run seed:uat` | keep | valid setup composition for UAT | - |
| `db:fresh` | `npm run db:reset && npm run db:migrate && npm run seed:system` | keep | clean local bootstrap path | - |
| `db:fresh:uat` | `npm run db:fresh && npm run seed:uat` | keep | clean UAT bootstrap path | - |
| `migrate` | `npm run db:migrate` | remove | duplicate shorthand | `npm run db:migrate` |
| `studio` | `npm run db:studio` | remove | duplicate shorthand | `npm run db:studio` |
| `setup:db` | `npm run db:setup` | keep | compatibility alias still referenced by setup wizard copy | `npm run db:setup` |
| `seed:super-admin` | `node scripts/seed-super-admin.js` | keep | useful low-level bootstrap step | - |
| `seed:foundation` | `node --experimental-strip-types src/db/seeds/foundation.seed.ts` | keep | useful low-level seed for troubleshooting | - |
| `seed:crm-uat` | `node --experimental-strip-types src/db/seeds/crm-uat.seed.ts` | keep | useful low-level data-only seed for troubleshooting | - |
| `seed:system` | old direct seed file | replace | now routes through `scripts/seed-system.ts` wrapper and includes PDF template reseed | `npm run seed:system` |
| `seed:uat` | old direct seed file | replace | now routes through `scripts/seed-uat.ts` wrapper and seeds users before CRM data | `npm run seed:uat` |
| `seed:reset` | not present | add | task-required guarded reset + migrate + reseed orchestration | `npm run seed:reset -- --allow-db-reset` |
| `seed:pdf-template` | `node --experimental-strip-types scripts/reseed-pdf-template-version.ts` | keep | canonical operator-facing PDF template sync | - |
| `seed:pdf-template-version` | same as `seed:pdf-template` | keep | compatibility alias for historical docs and task lineage | `npm run seed:pdf-template` |
| `pdf:reseed` | duplicate reseed alias | remove | overlapping alias with no added behavior | `npm run seed:pdf-template` |
| `pdf:activate:product` | targeted activation command | keep | still useful for product-v1 operator flow | - |
| `migrate:membership-business-roles` | migration utility | keep | one-off but still valid migration helper | - |
| `seed:task-h1-fixture` | fixture utility | keep | still referenced by historical PDF verification docs | - |
| `legacy:seed:task-h1-fixture` | duplicate legacy alias | remove | duplicate of active fixture command | `npm run seed:task-h1-fixture` |
| `verify:task-h1` | fixture verification utility | keep | still referenced by historical docs | - |
| `legacy:verify:task-h1` | duplicate legacy alias | remove | duplicate of active verification command | `npm run verify:task-h1` |
| `verify:task-h3` | historical verification utility | keep | still valid and referenced | - |
| `legacy:verify:task-h3` | duplicate legacy alias | remove | duplicate of active verification command | `npm run verify:task-h3` |
| `verify:encoding` | `node scripts/verify-encoding.mjs` | keep | build safety prerequisite | - |
| `verify:crm-access` | CRM access audit | keep | task-required verification | - |
| `audit:pdf:*` | PDF audit suite | keep | active verification foundation | - |

## Changes Applied

- added `typecheck`
- added `seed:reset`
- moved `seed:system` to `scripts/seed-system.ts`
- moved `seed:uat` to `scripts/seed-uat.ts`
- kept `seed:pdf-template-version` only as compatibility alias
- removed duplicate shorthand and legacy aliases:
  - `gen`
  - `migrate`
  - `studio`
  - `pdf:reseed`
  - `legacy:seed:task-h1-fixture`
  - `legacy:verify:task-h1`
  - `legacy:verify:task-h3`

## Seed Architecture Notes

- `seed:system` now guarantees:
  - super admin
  - foundation data
  - active PDF template reseed
- `seed:uat` now guarantees:
  - deterministic UAT users and memberships
  - CRM role profiles and role assignments
  - CRM demo dataset
- `seed:reset` now guarantees:
- explicit `--allow-db-reset` confirmation or `ALLOW_DB_RESET=true`
  - database reset safety guard
  - migrations reapplied before seeding
  - `seed:system` then `seed:uat`
