/db-audit — Database Audit (Drizzle ORM + PostgreSQL)
Skill for database projects focused on Drizzle ORM and PostgreSQL. Automatically detects the DB configuration, checks schema design, migrations, connection setup, security, and performance. Patterns are general enough for other ORMs/DBs, but checks and templates are PostgreSQL-optimized.
Complementary to /audit and /project-audit: This skill checks exclusively database-specific topics. Generic code quality, SEO, a11y, etc. belong to /audit or /project-audit.
Modes
Detect the mode from user input:
- start -> Mode 1 (Scan project, identify areas)
- continue -> Mode 2 (Process next areas/fixes)
- status -> Mode 3 (Show progress)
- report -> Mode 4 (Structured Markdown report)
- refresh -> Mode 5 (Check for new Drizzle/PostgreSQL releases)
- auto -> Mode 6 (Fully autonomous run)
Mode 1: /db-audit start — Scan Project
Auto-Detection (in this order)
- package.json ->
drizzle-orm, drizzle-kit, pg, postgres, @neondatabase/serverless, other DB packages
- drizzle.config.ts/js -> Dialect, schema path, migrations directory, connection config
- Schema directory ->
src/lib/server/db/, src/db/, db/, src/schema/ — tables, relations, enums
- Docker Compose -> PostgreSQL service, volumes, health checks, env variables
- .env / .env.example ->
DATABASE_URL pattern, credentials handling
- Framework integration -> SvelteKit (
$lib/server/db), Astro (server endpoints), Next.js (server actions)
Version Check
After detection:
- Read installed Drizzle version from
package.json
- Check latest version:
npm view drizzle-orm version + npm view drizzle-kit version
- Determine PostgreSQL version (Docker image, managed service, or
psql --version)
- Display result table
Flow After Detection
- Display result table: Drizzle version, PostgreSQL version, framework, schema path, connection type
- Prioritize areas by relevance (max 2 per session)
- Check each checkpoint against the project
- Save findings to
.db-audit-state.json
- Display summary + prioritized list
- Session end: "Start next session with
/db-audit continue"
Mode 2: /db-audit continue — Resume
- Read
.db-audit-state.json
- Generate smart recommendation:
IF open CRITICAL findings > 0:
-> "Recommendation: Fix {N} CRITICAL findings first ({IDs})"
IF open HIGH findings > 3:
-> "Recommendation: Fix HIGH findings, then continue"
ELSE IF areas open:
-> "Recommendation: Next areas ({area names})"
ELSE:
-> "Recommendation: Fix remaining findings"
- If areas open -> process next 2 areas
- If all areas done -> next 5 findings by priority
- Load fix templates (from
fix-templates.md) where applicable
- Ask user: Follow recommendation? Choose different? Skip?
- Implement fixes -> verify -> update state
Mode 3: /db-audit status — Progress
- Read
.db-audit-state.json
- Display table: Done/Open/Total per area + severity
- Next recommended action
Mode 4: /db-audit report — Markdown Report
Generate a structured Markdown report.
- Read state file
- Group all findings by area
- Report with executive summary, findings per area, recommendations
- Insert trend analysis (if history available):
Trend (recent audits):
CRITICAL: 3 -> 1 -> 0 (resolved)
HIGH: 5 -> 3 -> 2 (declining)
Total: 12 -> 8 -> 5
Assessment: Project is steadily improving.
- Save report as
DB-AUDIT-REPORT-{YYYY-MM-DD}.md in project root
- If previous reports exist: Diff section (new/resolved since last report)
Mode 5: /db-audit refresh — Check New Releases
npm view drizzle-orm version + npm view drizzle-kit version -> latest version
- If newer version than in state: check release notes via context7 or WebSearch
- Show delta:
Last checked: drizzle-orm 0.38.x / drizzle-kit 0.30.x
Current: drizzle-orm 0.39.x / drizzle-kit 0.31.x
New changes: Breaking changes, new features
-> Schema/migration review recommended
- Check PostgreSQL major version updates (Docker Hub tags)
- Inform user + recommendation
Mode 6: /db-audit auto — Autonomous Run
Fully autonomous DB audit without prompts.
Flow
- Auto-detection as in
start
- All areas processed (no 2-area limitation)
- Document findings with fix templates from
fix-templates.md
- Context management: When context runs low:
- Write state immediately
- Create task in
.tasks.json with handoff note
- "New session with
/db-audit continue"
- At end: Summary with prioritized fix list
Severity Order of Areas in Auto Mode
CRITICAL areas first:
ENV -> SCHEMA -> SEC -> CONN -> MIG -> QUERY -> PERF -> BAK -> INT -> TOOL
Areas
| Code |
Area |
Description |
| ENV |
Environment |
PostgreSQL version, connection string, Docker vs managed, .env setup |
| SCHEMA |
Schema Design |
Drizzle tables, relations, constraints, enums, naming |
| MIG |
Migrations |
drizzle-kit generate, push, migrate, migration history |
| CONN |
Connection |
Pool setup (pg Pool), connection limits, idle timeout, SSL |
| QUERY |
Query Patterns |
Select, insert, prepared statements, transactions, type safety |
| SEC |
Security |
Roles, permissions, row-level security, SSL, credential handling |
| PERF |
Performance |
Indexes, EXPLAIN ANALYZE, N+1 queries, pagination, query optimization |
| BAK |
Backup |
pg_dump, point-in-time recovery, Docker volumes, restore tests |
| TOOL |
Tooling |
drizzle-kit studio, pgAdmin, DB monitoring, health checks |
| INT |
Integration |
Framework-specific (SvelteKit server-only, Astro endpoints, env handling) |
Check Priorities + Completeness Tracking
See _shared/audit-patterns.md (MUST/SHOULD/CAN markers, completeness counting, layer status standard).
Area with <100% MUST checks cannot be marked as done.
Area Details
ENV — Environment
[MUST] Determine PostgreSQL version (Docker image tag, managed service, or psql)
[MUST] DATABASE_URL in .env/.env.example present (not hardcoded in code)
[MUST] Credentials NOT in repository (no .env in Git)
[SHOULD] .env.example with placeholders present
[SHOULD] Docker Compose health check for PostgreSQL
[CAN] Separate DB for development/testing/production
SCHEMA — Schema Design
[MUST] All tables with primary key (serial/uuid)
[MUST] Foreign keys defined for relations
[MUST] NOT NULL constraints where semantically required
[MUST] Timestamps (createdAt, updatedAt) on relevant tables
[SHOULD] Drizzle relations defined (not just FK columns)
[SHOULD] Consistent naming convention (snake_case for DB, camelCase for TypeScript)
[SHOULD] Enums via pgEnum instead of string columns
[SHOULD] Schema split into separate files (per domain/feature)
[CAN] CHECK constraints for value range validation
[CAN] Composite indexes for frequent WHERE combinations
MIG — Migrations
[MUST] Migration strategy defined (generate+migrate vs push)
[MUST] Migrations directory exists and is in Git
[MUST] drizzle.config.ts correctly configured (dialect, schema, out)
[SHOULD] Migrations not manually edited after generation
[SHOULD] Production uses migrate() (not push)
[CAN] Migration tests or seed data present
CONN — Connection
[MUST] Connection pool configured (not single connections)
[MUST] Pool limits set (max connections)
[SHOULD] Idle timeout configured
[SHOULD] Connection error handling (retry, graceful shutdown)
[SHOULD] SSL connection in production
[CAN] Connection monitoring/logging
QUERY — Query Patterns
[MUST] No raw SQL with string interpolation (SQL injection risk)
[MUST] Prepared statements or Drizzle query builder
[SHOULD] Transactions for related operations
[SHOULD] Select only needed columns (no select * equivalent)
[SHOULD] Type-safe queries (use Drizzle infer types)
[CAN] Prepared statements for recurring queries
SEC — Security
[MUST] No credentials in source code
[MUST] SSL for production connections
[MUST] Parameterized queries (no string building)
[SHOULD] Separate DB user for app (not postgres superuser)
[SHOULD] Least-privilege principle (only required permissions)
[CAN] Row-level security for multi-tenant
[CAN] Audit logging for critical tables
PERF — Performance
[MUST] Indexes on foreign keys
[MUST] Indexes on frequently queried columns (WHERE, ORDER BY)
[SHOULD] N+1 query detection (loops with DB calls)
[SHOULD] Cursor-based pagination instead of OFFSET/LIMIT for large datasets
[SHOULD] EXPLAIN ANALYZE for critical queries
[CAN] Partial indexes for filtered queries
[CAN] GIN indexes for JSONB columns
[CAN] Connection pool sizing based on load
BAK — Backup
[MUST] Backup strategy present (pg_dump or managed backups)
[MUST] Docker volumes for persistent data (not container-internal)
[SHOULD] Automated backup script
[SHOULD] Restore tested
[CAN] Point-in-time recovery (WAL archiving)
[CAN] Offsite backup
TOOL — Tooling
[SHOULD] drizzle-kit studio or pgAdmin for DB management
[SHOULD] Health check endpoint for DB connection
[CAN] DB monitoring (pg_stat_statements, Grafana)
[CAN] Seed script for development data
INT — Integration
[MUST] DB access server-side only (no DB code in client bundle)
[MUST] Environment variables loaded correctly (framework-specific)
[SHOULD] DB client as singleton (no connection leak on hot reload)
[SHOULD] Graceful shutdown (close pool on server stop)
[CAN] Type export for frontend (InferSelectModel without DB import)
Severity Definitions
| Severity |
Criteria |
Examples |
| CRITICAL |
Data loss risk, SQL injection, unencrypted credentials |
Raw SQL with interpolation, credentials in Git, no backup, container without volume |
| HIGH |
Missing indexes on hot paths, no backup, connection leaks |
Missing FK indexes, no pool limit, no SSL in production |
| MEDIUM |
Missing constraints, suboptimal schema, no migrations |
Missing NOT NULL, no updatedAt, push instead of migrate in prod |
| LOW |
Nice-to-have indexes, monitoring, documentation |
GIN indexes, pg_stat_statements, seed data |
State Schema v2.1 (.db-audit-state.json)
-> Full state schema (JSON example) + migration v1->v2.1: See state-schema.md
Rules
- Context protection: Max 2 areas OR 5 fixes per session. At limit: save state, recommend
/db-audit continue.
- Write state immediately: Update
.db-audit-state.json after every area and every fix.
- No auto-fix: Document findings, then ask user whether to fix.
- Severity rules:
- CRITICAL: Data loss risk, SQL injection, unencrypted credentials
- HIGH: Missing indexes on hot paths, no backup, connection leaks
- MEDIUM: Missing constraints, suboptimal schema, no migrations
- LOW: Nice-to-have indexes, monitoring, documentation
- Finding prefix: Always
DB-NN, not MIG/SEC like other audit skills.
- Fix templates: Load matching template from
fix-templates.md for findings.
- npm view: Run
npm view drizzle-orm version before any version statement. Never from memory.
- context7: Use for Drizzle documentation when available.
- PostgreSQL focus: Checks are PostgreSQL-specific. For SQLite/MySQL: inform user, adapt checks.
Session Strategy
| Session |
Content |
Context Protection |
| 1 |
start -> Detection + 2 areas (CRITICAL first) |
Max 2 areas |
| 2 |
continue -> next 2 areas |
Max 2 areas |
| 3+ |
continue -> Fixes (max 5/session) |
Fix -> Test -> Next |
Smart Next Steps
After completing the DB audit, recommend relevant follow-up skills:
| Condition |
Recommendation |
Reason |
| Auth tables found |
/auth-audit start |
Check auth implementation (bcrypt, sessions, CSRF) |
| SvelteKit project |
/sveltekit-audit start |
Framework-specific checks (load, form actions, hooks) |
| No .project-audit-state.json present |
/project-audit start |
Check code/CI/CD quality |
| No .audit-state.json present |
/audit start |
Check website quality (SEO, a11y, performance, privacy) |
| All areas done |
/lesson-learned session |
Extract learnings from DB audit |
Output after last area: "Next steps:" + 2-3 most relevant recommendations.
Additional Files
fix-templates.md — Quick-fix templates for common DB findings
state-schema.md — State schema v2.1 + migration v1->v2.1
As of: 2026-03-20 (State schema v2.1 migration)
1---2name: db-audit3description: Database audit for Drizzle ORM + PostgreSQL with state persistence. Use when: "db-audit", "database audit", "drizzle check", "db check", "schema audit", "migration check", "postgresql audit".4---56<!-- AI-QUICK-REF7## /db-audit — Quick Reference8- **Modes:** start | continue | status | report | refresh | auto9- **Auto-Detection:** package.json (drizzle-orm, pg, postgres), drizzle.config, db/ directory, Docker PostgreSQL, .env DATABASE_URL10- **Focus:** Drizzle ORM + PostgreSQL (extensible for other ORMs/DBs)11- **State:** .db-audit-state.json (v2.1)12- **Finding IDs:** DB-NN13- **Checkpoints:** [CHECKPOINT: decision] at setup detection, [CHECKPOINT: verify] after each area14- **Complementary to /audit and /project-audit** — this skill only checks DB-specific topics15-->1617# /db-audit — Database Audit (Drizzle ORM + PostgreSQL)1819Skill for database projects focused on Drizzle ORM and PostgreSQL. Automatically detects the DB configuration, checks schema design, migrations, connection setup, security, and performance. Patterns are general enough for other ORMs/DBs, but checks and templates are PostgreSQL-optimized.2021**Complementary to /audit and /project-audit:** This skill checks exclusively database-specific topics. Generic code quality, SEO, a11y, etc. belong to /audit or /project-audit.2223## Modes2425Detect the mode from user input:2627- **start** -> Mode 1 (Scan project, identify areas)28- **continue** -> Mode 2 (Process next areas/fixes)29- **status** -> Mode 3 (Show progress)30- **report** -> Mode 4 (Structured Markdown report)31- **refresh** -> Mode 5 (Check for new Drizzle/PostgreSQL releases)32- **auto** -> Mode 6 (Fully autonomous run)3334---3536## Mode 1: `/db-audit start` — Scan Project3738### Auto-Detection (in this order)39401. **package.json** -> `drizzle-orm`, `drizzle-kit`, `pg`, `postgres`, `@neondatabase/serverless`, other DB packages412. **drizzle.config.ts/js** -> Dialect, schema path, migrations directory, connection config423. **Schema directory** -> `src/lib/server/db/`, `src/db/`, `db/`, `src/schema/` — tables, relations, enums434. **Docker Compose** -> PostgreSQL service, volumes, health checks, env variables445. **.env / .env.example** -> `DATABASE_URL` pattern, credentials handling456. **Framework integration** -> SvelteKit (`$lib/server/db`), Astro (server endpoints), Next.js (server actions)4647### Version Check4849After detection:50511. Read installed Drizzle version from `package.json`522. Check latest version: `npm view drizzle-orm version` + `npm view drizzle-kit version`533. Determine PostgreSQL version (Docker image, managed service, or `psql --version`)544. Display result table5556### Flow After Detection57581. Display result table: Drizzle version, PostgreSQL version, framework, schema path, connection type592. Prioritize areas by relevance (max 2 per session)603. Check each checkpoint against the project614. Save findings to `.db-audit-state.json`625. Display summary + prioritized list636. Session end: "Start next session with `/db-audit continue`"6465---6667## Mode 2: `/db-audit continue` — Resume68691. Read `.db-audit-state.json`702. **Generate smart recommendation:**71 ```72 IF open CRITICAL findings > 0:73 -> "Recommendation: Fix {N} CRITICAL findings first ({IDs})"74 IF open HIGH findings > 3:75 -> "Recommendation: Fix HIGH findings, then continue"76 ELSE IF areas open:77 -> "Recommendation: Next areas ({area names})"78 ELSE:79 -> "Recommendation: Fix remaining findings"80 ```813. If areas open -> process next 2 areas824. If all areas done -> next 5 findings by priority835. **Load fix templates** (from `fix-templates.md`) where applicable846. Ask user: Follow recommendation? Choose different? Skip?857. Implement fixes -> verify -> update state8687---8889## Mode 3: `/db-audit status` — Progress90911. Read `.db-audit-state.json`922. Display table: Done/Open/Total per area + severity933. Next recommended action9495---9697## Mode 4: `/db-audit report` — Markdown Report9899Generate a structured Markdown report.1001011. Read state file1022. Group all findings by area1033. Report with executive summary, findings per area, recommendations1044. **Insert trend analysis** (if history available):105 ```106 Trend (recent audits):107 CRITICAL: 3 -> 1 -> 0 (resolved)108 HIGH: 5 -> 3 -> 2 (declining)109 Total: 12 -> 8 -> 5110 Assessment: Project is steadily improving.111 ```1125. Save report as `DB-AUDIT-REPORT-{YYYY-MM-DD}.md` in project root1136. If previous reports exist: Diff section (new/resolved since last report)114115---116117## Mode 5: `/db-audit refresh` — Check New Releases1181191. `npm view drizzle-orm version` + `npm view drizzle-kit version` -> latest version1202. If newer version than in state: check release notes via context7 or WebSearch1213. **Show delta:**122 ```123 Last checked: drizzle-orm 0.38.x / drizzle-kit 0.30.x124 Current: drizzle-orm 0.39.x / drizzle-kit 0.31.x125 New changes: Breaking changes, new features126 -> Schema/migration review recommended127 ```1284. Check PostgreSQL major version updates (Docker Hub tags)1295. Inform user + recommendation130131---132133## Mode 6: `/db-audit auto` — Autonomous Run134135Fully autonomous DB audit without prompts.136137### Flow1381391. Auto-detection as in `start`1402. **All areas** processed (no 2-area limitation)1413. Document findings with fix templates from `fix-templates.md`1424. **Context management:** When context runs low:143 - Write state immediately144 - Create task in `.tasks.json` with handoff note145 - "New session with `/db-audit continue`"1465. At end: Summary with prioritized fix list147148### Severity Order of Areas in Auto Mode149150CRITICAL areas first:151`ENV -> SCHEMA -> SEC -> CONN -> MIG -> QUERY -> PERF -> BAK -> INT -> TOOL`152153---154155## Areas156157| Code | Area | Description |158|------|------|-------------|159| **ENV** | Environment | PostgreSQL version, connection string, Docker vs managed, .env setup |160| **SCHEMA** | Schema Design | Drizzle tables, relations, constraints, enums, naming |161| **MIG** | Migrations | drizzle-kit generate, push, migrate, migration history |162| **CONN** | Connection | Pool setup (pg Pool), connection limits, idle timeout, SSL |163| **QUERY** | Query Patterns | Select, insert, prepared statements, transactions, type safety |164| **SEC** | Security | Roles, permissions, row-level security, SSL, credential handling |165| **PERF** | Performance | Indexes, EXPLAIN ANALYZE, N+1 queries, pagination, query optimization |166| **BAK** | Backup | pg_dump, point-in-time recovery, Docker volumes, restore tests |167| **TOOL** | Tooling | drizzle-kit studio, pgAdmin, DB monitoring, health checks |168| **INT** | Integration | Framework-specific (SvelteKit server-only, Astro endpoints, env handling) |169170---171172## Check Priorities + Completeness Tracking173174> See `_shared/audit-patterns.md` (MUST/SHOULD/CAN markers, completeness counting, layer status standard).175Area with <100% MUST checks cannot be marked as `done`.176177---178179## Area Details180181### ENV — Environment182183**[MUST]** Determine PostgreSQL version (Docker image tag, managed service, or psql)184**[MUST]** DATABASE_URL in .env/.env.example present (not hardcoded in code)185**[MUST]** Credentials NOT in repository (no .env in Git)186**[SHOULD]** .env.example with placeholders present187**[SHOULD]** Docker Compose health check for PostgreSQL188**[CAN]** Separate DB for development/testing/production189190### SCHEMA — Schema Design191192**[MUST]** All tables with primary key (serial/uuid)193**[MUST]** Foreign keys defined for relations194**[MUST]** NOT NULL constraints where semantically required195**[MUST]** Timestamps (createdAt, updatedAt) on relevant tables196**[SHOULD]** Drizzle relations defined (not just FK columns)197**[SHOULD]** Consistent naming convention (snake_case for DB, camelCase for TypeScript)198**[SHOULD]** Enums via pgEnum instead of string columns199**[SHOULD]** Schema split into separate files (per domain/feature)200**[CAN]** CHECK constraints for value range validation201**[CAN]** Composite indexes for frequent WHERE combinations202203### MIG — Migrations204205**[MUST]** Migration strategy defined (generate+migrate vs push)206**[MUST]** Migrations directory exists and is in Git207**[MUST]** drizzle.config.ts correctly configured (dialect, schema, out)208**[SHOULD]** Migrations not manually edited after generation209**[SHOULD]** Production uses `migrate()` (not `push`)210**[CAN]** Migration tests or seed data present211212### CONN — Connection213214**[MUST]** Connection pool configured (not single connections)215**[MUST]** Pool limits set (max connections)216**[SHOULD]** Idle timeout configured217**[SHOULD]** Connection error handling (retry, graceful shutdown)218**[SHOULD]** SSL connection in production219**[CAN]** Connection monitoring/logging220221### QUERY — Query Patterns222223**[MUST]** No raw SQL with string interpolation (SQL injection risk)224**[MUST]** Prepared statements or Drizzle query builder225**[SHOULD]** Transactions for related operations226**[SHOULD]** Select only needed columns (no `select *` equivalent)227**[SHOULD]** Type-safe queries (use Drizzle infer types)228**[CAN]** Prepared statements for recurring queries229230### SEC — Security231232**[MUST]** No credentials in source code233**[MUST]** SSL for production connections234**[MUST]** Parameterized queries (no string building)235**[SHOULD]** Separate DB user for app (not postgres superuser)236**[SHOULD]** Least-privilege principle (only required permissions)237**[CAN]** Row-level security for multi-tenant238**[CAN]** Audit logging for critical tables239240### PERF — Performance241242**[MUST]** Indexes on foreign keys243**[MUST]** Indexes on frequently queried columns (WHERE, ORDER BY)244**[SHOULD]** N+1 query detection (loops with DB calls)245**[SHOULD]** Cursor-based pagination instead of OFFSET/LIMIT for large datasets246**[SHOULD]** EXPLAIN ANALYZE for critical queries247**[CAN]** Partial indexes for filtered queries248**[CAN]** GIN indexes for JSONB columns249**[CAN]** Connection pool sizing based on load250251### BAK — Backup252253**[MUST]** Backup strategy present (pg_dump or managed backups)254**[MUST]** Docker volumes for persistent data (not container-internal)255**[SHOULD]** Automated backup script256**[SHOULD]** Restore tested257**[CAN]** Point-in-time recovery (WAL archiving)258**[CAN]** Offsite backup259260### TOOL — Tooling261262**[SHOULD]** drizzle-kit studio or pgAdmin for DB management263**[SHOULD]** Health check endpoint for DB connection264**[CAN]** DB monitoring (pg_stat_statements, Grafana)265**[CAN]** Seed script for development data266267### INT — Integration268269**[MUST]** DB access server-side only (no DB code in client bundle)270**[MUST]** Environment variables loaded correctly (framework-specific)271**[SHOULD]** DB client as singleton (no connection leak on hot reload)272**[SHOULD]** Graceful shutdown (close pool on server stop)273**[CAN]** Type export for frontend (InferSelectModel without DB import)274275---276277## Severity Definitions278279| Severity | Criteria | Examples |280|----------|----------|----------|281| **CRITICAL** | Data loss risk, SQL injection, unencrypted credentials | Raw SQL with interpolation, credentials in Git, no backup, container without volume |282| **HIGH** | Missing indexes on hot paths, no backup, connection leaks | Missing FK indexes, no pool limit, no SSL in production |283| **MEDIUM** | Missing constraints, suboptimal schema, no migrations | Missing NOT NULL, no updatedAt, push instead of migrate in prod |284| **LOW** | Nice-to-have indexes, monitoring, documentation | GIN indexes, pg_stat_statements, seed data |285286---287288## State Schema v2.1 (.db-audit-state.json)289290-> Full state schema (JSON example) + migration v1->v2.1: See **state-schema.md**291292---293294## Rules295296- **Context protection:** Max 2 areas OR 5 fixes per session. At limit: save state, recommend `/db-audit continue`.297- **Write state immediately:** Update `.db-audit-state.json` after every area and every fix.298- **No auto-fix:** Document findings, then ask user whether to fix.299- **Severity rules:**300 - CRITICAL: Data loss risk, SQL injection, unencrypted credentials301 - HIGH: Missing indexes on hot paths, no backup, connection leaks302 - MEDIUM: Missing constraints, suboptimal schema, no migrations303 - LOW: Nice-to-have indexes, monitoring, documentation304- **Finding prefix:** Always `DB-NN`, not MIG/SEC like other audit skills.305- **Fix templates:** Load matching template from `fix-templates.md` for findings.306- **npm view:** Run `npm view drizzle-orm version` before any version statement. Never from memory.307- **context7:** Use for Drizzle documentation when available.308- **PostgreSQL focus:** Checks are PostgreSQL-specific. For SQLite/MySQL: inform user, adapt checks.309310---311312## Session Strategy313314| Session | Content | Context Protection |315|---------|---------|-------------------|316| 1 | start -> Detection + 2 areas (CRITICAL first) | Max 2 areas |317| 2 | continue -> next 2 areas | Max 2 areas |318| 3+ | continue -> Fixes (max 5/session) | Fix -> Test -> Next |319320---321322## Smart Next Steps323324After completing the DB audit, recommend relevant follow-up skills:325326| Condition | Recommendation | Reason |327|-----------|---------------|--------|328| Auth tables found | `/auth-audit start` | Check auth implementation (bcrypt, sessions, CSRF) |329| SvelteKit project | `/sveltekit-audit start` | Framework-specific checks (load, form actions, hooks) |330| No .project-audit-state.json present | `/project-audit start` | Check code/CI/CD quality |331| No .audit-state.json present | `/audit start` | Check website quality (SEO, a11y, performance, privacy) |332| All areas done | `/lesson-learned session` | Extract learnings from DB audit |333334**Output after last area:** "Next steps:" + 2-3 most relevant recommendations.335336---337338## Additional Files339340- `fix-templates.md` — Quick-fix templates for common DB findings341- `state-schema.md` — State schema v2.1 + migration v1->v2.1342343As of: 2026-03-20 (State schema v2.1 migration)