Manage DB Module Slices
Purpose
Enforce module-level DB boundaries (owns/uses) without modifying DB SSOT, and generate per-module DB slices for LLM context.
This skill does not change the database or schema SSOT. It only validates and syncs module slices.
Required Inputs
- Module manifests:
modules/<module_id>/MANIFEST.yaml - DB contract:
docs/context/db/schema.json
Outputs
modules/<module_id>/interact/db-slice.json(default output)- Updated module registry:
modules/<module_id>/interact/registry.json
Procedure
Phase 0 — Contract readiness (mandatory)
- Confirm
docs/context/db/schema.jsonexists and reflects the latest DB SSOT. - If DB SSOT changed, refresh the contract first:
node .ai/scripts/ctl-db-ssot.mjs sync-to-context --repo-root .
- If the contract is missing or refresh fails, STOP and resolve DB SSOT issues first.
Phase 1 — Declare module boundaries
- In
modules/<module_id>/MANIFEST.yaml, add or update:
db:
owns:
- table: users
columns: [id, email]
uses:
- table: orders
columns: "*"
Rules:
- Use schema-qualified names if ambiguous (e.g.,
public.users). - Use
columns: "*"or omitcolumnsto mean full table.
Phase 2 — Preflight validation (mandatory)
- Run strict validation:
node .ai/scripts/modules/ctl-db-ssot-module.mjs verify- Optional:
node .ai/scripts/modules/ctl-db-ssot-module.mjs verify --strict
- Check ownership conflicts:
node .ai/scripts/modules/ctl-db-ssot-module.mjs conflicts
- If any errors or conflicts are reported, STOP and resolve:
- Fix invalid table/column references.
- Resolve ownership conflicts (one owner per table).
Phase 3 — Preview slice (recommended)
- Export a preview slice for review:
node .ai/scripts/modules/ctl-db-ssot-module.mjs export-slice --module-id <module_id>
- Ask for confirmation before writing slices, especially if updating multiple modules.
Checkpoint: request explicit approval before writing slices.
[APPROVAL REQUIRED]
I am ready to generate and write module slices.
- Command: sync-slices
- Scope: all modules (or a single module if --module-id is used)
Type "approve slices" to proceed.
Phase 4 — Sync module slices (writes)
- Generate slices for all modules (requires explicit approval):
node .ai/scripts/modules/ctl-db-ssot-module.mjs sync-slices
- Or target a single module:
node .ai/scripts/modules/ctl-db-ssot-module.mjs sync-slices --module-id <module_id>
- To avoid registry updates, add
--no-registry.
Verification
-
verifypasses with no errors -
conflictsreports no ownership collisions -
modules/<module_id>/interact/db-slice.jsonexists and matches declared owns/uses - Module registry updated with
db-sliceartifact (unless--no-registry)
Boundaries
- MUST NOT modify DB SSOT or run migrations in this skill.
- MUST NOT treat module slices as SSOT.
- MUST resolve ownership conflicts before syncing slices.
- MUST obtain explicit approval before running
sync-slicesfor all modules.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.