forge-database: Database design
Engine: Hybrid — Forge + Supabase, wshobson, Google
Purpose
Inspect schema integrity, migrations, constraints, tenancy, lifecycle, recovery, and production-safe evolution.
Deterministic runtime composition
Before loading any provider procedure, run:
Resolve ../../runtime/cli/src/composition-entry.js relative to this SKILL.md, then run:
node "<resolved-absolute-runner-path>" database compose --workflow audit --root "<repository-root>" --dry-run --json
Add one repeatable --request <provider-or-source> flag for each explicit user request. Add
--condition <task-condition> or --risk-surface <surface> only for a task fact you directly
proved; never infer one from generic wording. The command above is the default for this
audit-oriented module; for implementation use --workflow build, and for a fix, retest, or
release gate use --workflow fix, verify, or ship respectively. Read the JSON response,
keep the Forge contract at index zero, and resolve paths against the absolute runtime_root
reported in that response. Read eager[].runtimePath when entering the module. The full
selected[] list is availability/provenance; load only deferred[].runtimePath when the task
reaches that concern, in tier order. Refuse any path that escapes the root. Respect every reported
suppression and context budget. If missing is non-empty, stop and report the installation as
damaged; do not improvise a prose fallback. The runner and specialist content may live in a plugin
cache or global installation; never assume they are inside the audited repository.
Resolve and read ../fullstack-forge/references/shared/module-contract.md (applicability,
execution, mutation, verification, completion) and
../fullstack-forge/references/shared/evidence-rules.md (statuses, standards, tools, findings via
../fullstack-forge/references/PROTOCOL.md) relative to this module SKILL.md before reporting.
Never hide failed checks or claim that an operation ran when it did not.
Automatic activation signals
Activate when a request or direct repository evidence involves database design, when
the user explicitly names forge-database, or when discovery proves an applicable boundary.
- Applications with a database or durable structured store
When not to activate
- Stateless applications proven to store no durable data
Automated support
Relevant discovery inputs are:
- schema and migrations
- ORM metadata
- database configuration and tests
Deterministic support, bounded evidence only:
Agent inspection procedure
- Read the schema (migrations, ORM models, or live catalog) and verify primary keys, foreign keys, unique constraints, and nullability against the domain rules.
- Check types for money (integer minor units or decimal), timestamps (time-zone aware), enums (evolution path), and identifiers.
- Trace referential integrity and cascade behavior for deletion paths, including soft-deletion consistency.
- Review the migration history for destructive operations, lock-heavy changes on large tables, and reversibility.
- Verify tenant-scoping columns and indexes, audit fields, and database-level permissions against least privilege.
Manual inspection requirements:
- Review applied production migration state and large-table risk with operators
- Confirm restore objectives and managed-database settings
Stack-specific guidance:
- Inspect generated SQL and actual constraints, not ORM declarations alone
Evidence to collect
Standards used as criteria:
- PostgreSQL current documentation
- OWASP Database Security Cheat Sheet
Common production failures
- Inspect keys, types, nullability, defaults, foreign keys, uniqueness, checks, indexes, and cascade behavior
- Review migration ordering, transactional safety, locks, backfills, expand-contract compatibility, and rollback or forward-fix strategy
- Trace tenant isolation, encryption, retention, audit fields, soft deletion, and backup expectations
Missing-control checks
Each item needs direct evidence or one reasoned status.
- Primary keys
- Foreign keys
- Unique constraints
- Check constraints
- Nullability
- Normalization
- Intentional denormalization
- Cascade behavior
- Data types
- Money representation
- Date representation
- Time zones
- Enum evolution
- Audit fields
- Soft deletion
- Tenant scoping
- Migration history
- Referential integrity
- Database permissions
- Data retention
- Large-table evolution
- Migration safety
- Rollback implications
Commands and tools
- Run
forge database audit --json or fullstack-forge database audit --json when
an explicit audit is requested and the CLI is installed. Normal feature work does not require it.
Safe fixes
- Add documentation and tests for existing constraints
- Create a new unapplied safe migration when lock and compatibility risk is understood
Approval-required changes
- Editing applied migrations, dropping data, changing ownership, or rewriting architecture
Verification
- Apply migrations to an empty and representative upgraded database
- Run integrity and rollback/forward-fix tests
Completion contract
Follow fullstack-forge/references/shared/completion.md and the limitations below.
Known limitations
- Production row counts, locks, and plans cannot be inferred
1---2name: forge-database-33description: Inspect schema integrity, migrations, constraints, tenancy, lifecycle, recovery, and production-safe evolution.4---56# forge-database: Database design78Engine: Hybrid — Forge + Supabase, wshobson, Google910## Purpose1112Inspect schema integrity, migrations, constraints, tenancy, lifecycle, recovery, and production-safe evolution.131415## Deterministic runtime composition1617Before loading any provider procedure, run:1819Resolve `../../runtime/cli/src/composition-entry.js` relative to this `SKILL.md`, then run:2021`node "<resolved-absolute-runner-path>" database compose --workflow audit --root "<repository-root>" --dry-run --json`2223Add one repeatable `--request <provider-or-source>` flag for each explicit user request. Add24`--condition <task-condition>` or `--risk-surface <surface>` only for a task fact you directly25proved; never infer one from generic wording. The command above is the default for this26audit-oriented module; for implementation use `--workflow build`, and for a fix, retest, or27release gate use `--workflow fix`, `verify`, or `ship` respectively. Read the JSON response,28keep the Forge contract at index zero, and resolve paths against the absolute `runtime_root`29reported in that response. Read `eager[].runtimePath` when entering the module. The full30`selected[]` list is availability/provenance; load only `deferred[].runtimePath` when the task31reaches that concern, in tier order. Refuse any path that escapes the root. Respect every reported32suppression and context budget. If `missing` is non-empty, stop and report the installation as33damaged; do not improvise a prose fallback. The runner and specialist content may live in a plugin34cache or global installation; never assume they are inside the audited repository.353637Resolve and read `../fullstack-forge/references/shared/module-contract.md` (applicability,38execution, mutation, verification, completion) and39`../fullstack-forge/references/shared/evidence-rules.md` (statuses, standards, tools, findings via40`../fullstack-forge/references/PROTOCOL.md`) relative to this module `SKILL.md` before reporting.4142Never hide failed checks or claim that an operation ran when it did not.4344## Automatic activation signals4546Activate when a request or direct repository evidence involves database design, when47the user explicitly names `forge-database`, or when discovery proves an applicable boundary.4849- Applications with a database or durable structured store5051## When not to activate5253- Stateless applications proven to store no durable data5455## Automated support5657Relevant discovery inputs are:5859- schema and migrations60- ORM metadata61- database configuration and tests6263Deterministic support, bounded evidence only:6465- `inspect-database-schema`6667## Agent inspection procedure68691. Read the schema (migrations, ORM models, or live catalog) and verify primary keys, foreign keys, unique constraints, and nullability against the domain rules.702. Check types for money (integer minor units or decimal), timestamps (time-zone aware), enums (evolution path), and identifiers.713. Trace referential integrity and cascade behavior for deletion paths, including soft-deletion consistency.724. Review the migration history for destructive operations, lock-heavy changes on large tables, and reversibility.735. Verify tenant-scoping columns and indexes, audit fields, and database-level permissions against least privilege.7475Manual inspection requirements:7677- Review applied production migration state and large-table risk with operators78- Confirm restore objectives and managed-database settings7980Stack-specific guidance:8182- Inspect generated SQL and actual constraints, not ORM declarations alone8384## Evidence to collect8586Standards used as criteria:8788- PostgreSQL current documentation89- OWASP Database Security Cheat Sheet9091## Common production failures9293- Inspect keys, types, nullability, defaults, foreign keys, uniqueness, checks, indexes, and cascade behavior94- Review migration ordering, transactional safety, locks, backfills, expand-contract compatibility, and rollback or forward-fix strategy95- Trace tenant isolation, encryption, retention, audit fields, soft deletion, and backup expectations9697## Missing-control checks9899Each item needs direct evidence or one reasoned status.100101- Primary keys102- Foreign keys103- Unique constraints104- Check constraints105- Nullability106- Normalization107- Intentional denormalization108- Cascade behavior109- Data types110- Money representation111- Date representation112- Time zones113- Enum evolution114- Audit fields115- Soft deletion116- Tenant scoping117- Migration history118- Referential integrity119- Database permissions120- Data retention121- Large-table evolution122- Migration safety123- Rollback implications124125## Commands and tools126127- Run `forge database audit --json` or `fullstack-forge database audit --json` when128 an explicit audit is requested and the CLI is installed. Normal feature work does not require it.129130## Safe fixes131132- Add documentation and tests for existing constraints133- Create a new unapplied safe migration when lock and compatibility risk is understood134135## Approval-required changes136137- Editing applied migrations, dropping data, changing ownership, or rewriting architecture138139## Verification140141- Apply migrations to an empty and representative upgraded database142- Run integrity and rollback/forward-fix tests143144## Completion contract145146Follow `fullstack-forge/references/shared/completion.md` and the limitations below.147148## Known limitations149150- Production row counts, locks, and plans cannot be inferred