بنقرة واحدة
sync-code-schema-from-db
// Mirror schema changes from a real database (SSOT) into repo artifacts (prisma/schema.prisma + db/schema/tables.json) and refresh LLM context (docs/context/db/schema.json).
// Mirror schema changes from a real database (SSOT) into repo artifacts (prisma/schema.prisma + db/schema/tables.json) and refresh LLM context (docs/context/db/schema.json).
Treat convex/schema.ts as the database Single Source of Truth, initialize Convex scaffolding, regenerate docs/context/db/schema.json and docs/context/convex/functions.json, and verify the repository stays aligned with Convex mode.
Apply schema changes from repo SSOT (prisma/schema.prisma) to a target DB via Prisma migrations, with diff preview + approval gate; then refresh LLM context (docs/context/db/schema.json).
Enable and operate the Deployment feature (ops/deploy conventions + deploy scripts) for multi-environment delivery.
Plan/apply/verify cloud environment config and secret references using env contract + policy/inventory routing; detect drift, rotate secrets, and decommission environments with approval gates. Use for staging/prod deployments and maintenance.
Maintain env contract SSOT (env/contract.yaml), validate env/values + env/secrets refs coverage, and generate env/.env.example + docs/context/env/*. Use when adding/renaming/deprecating config keys.
Bootstrap, diagnose (doctor), and reconcile local dev environment from env contract/values/secret refs; generate .env.local and redacted docs/context/env/effective-*. Use when local env is broken or needs syncing.
| name | sync-code-schema-from-db |
| description | Mirror schema changes from a real database (SSOT) into repo artifacts (prisma/schema.prisma + db/schema/tables.json) and refresh LLM context (docs/context/db/schema.json). |
Treat the real database as the schema Single Source of Truth (SSOT) and keep repo-local schema artifacts in sync so developers and LLMs can work without direct DB access.
The sync-code-schema-from-db skill is the inverse of sync-db-schema-from-code. Use the skill when DB → code is the authoritative direction.
Use the skill only when the project DB SSOT is database:
prisma/schema.prisma (derived via introspection)db/schema/tables.json (derived snapshot for LLMs)To check the mode, read:
docs/project/db-ssot.jsonIf the project uses repo-prisma SSOT, STOP and use sync-db-schema-from-code.
Use when:
Avoid when:
See ./reference/database-ssot-mechanism.md for the end-to-end pattern (including domain/repository boundaries).
dev / staging / prod) and how to connect (without exposing secrets)prisma/schema.prisma is already presentdb/schema/tables.json, db/handbook/, etc)Choose one evidence directory (no secrets):
dev-docs/active/<task-slug>/artifacts/db/ (recommended).ai/.tmp/db-sync/<run-id>/Evidence files:
00-ssot-mode-check.md01-db-pull-instructions.md02-import-prisma-log.md03-context-refresh-log.mddatabase (docs/project/db-ssot.json).
sync-db-schema-from-code.npx prisma db pullRecord the instructions and the environment assumptions in 01-db-pull-instructions.md.
Ensure the DB mirror assets are present (required for the mirror workflow):
.ai/skills/features/database/sync-code-schema-from-db/scripts/ctl-db.mjsdb/schema/tables.jsondb/schema/tables.json is missing, install the mirror skeleton:
.ai/skills/features/database/sync-code-schema-from-db/templates/ into the repo root.node .ai/skills/features/database/sync-code-schema-from-db/scripts/ctl-db.mjs init, then re-run Phase B..ai/skills/features/database/sync-code-schema-from-db/scripts/ctl-db.mjs is missing, the database feature skill is not installed in .ai/skills/. Restore it (e.g., revert deletion / copy from a fresh template checkout), then re-run Phase B.Import prisma/schema.prisma into db/schema/tables.json:
node .ai/skills/features/database/sync-code-schema-from-db/scripts/ctl-db.mjs import-prismaRecord output in 02-import-prisma-log.md.
docs/context/db/schema.json:node .ai/scripts/ctl-db-ssot.mjs sync-to-contextRecord output in 03-context-refresh-log.md.
databaseprisma db pull against the correct environmentctl-db import-prisma updated db/schema/tables.jsonctl-db-ssot sync-to-context updated docs/context/db/schema.jsonnode .ai/tests/run.mjs --suite databaseprisma/schema.prisma as SSOT in database modedb/schema/tables.json (generated snapshot)db/handbook/ before asking humans to change DB