Universal AI Lib
cd ../skills

Prisma

Use this skill to make Prisma changes predictable, reversible, and aligned with repository conventions.

.github/skills/prisma/
prisma/SKILL.md
````instructions
---
name: prisma
description: 'Run Prisma schema and migration workflows safely in this repository: edit schema models, generate client artifacts, choose between migrate/dev/deploy/push flows, and debug Prisma runtime/query issues with reproducible commands. Use when requests mention Prisma, `schema.prisma`, migrations, `DATABASE_URL`, generated client updates, or database model/query changes.'
---

# Prisma

## Overview

Use this skill to make Prisma changes predictable, reversible, and aligned with repository conventions.
Always choose migration strategy before editing code that depends on schema changes.

## Follow This Workflow

### 1. Read the schema and affected query code

- Schema source: `packages/db/prisma/schema.prisma`
- Client output: `packages/db/src/generated/prisma`
- Query usage layer: `src/server/queries.ts`

### 2. Choose the correct DB change mode

| Goal                                           | Command          |
| ---------------------------------------------- | ---------------- |
| Local iterative schema development             | `migrate dev`    |
| CI or production migration apply               | `migrate deploy` |
| Prototype only, migration history not required | `db push`        |
| Inspect data manually                          | `studio`         |

### 3. Execute commands through the repo wrapper

- Direct wrapper:

```bash
pnpm tsx scripts/prisma.ts <subcommand>
```

- Or task helper:

```bash
node .github/skills/prisma/scripts/prisma-task.mjs <task>
```

Common examples:

```bash
node .github/skills/prisma/scripts/prisma-task.mjs generate
node .github/skills/prisma/scripts/prisma-task.mjs migrate-dev -- --name add_resource_fields
node .github/skills/prisma/scripts/prisma-task.mjs migrate-deploy
node .github/skills/prisma/scripts/prisma-task.mjs validate
```

### 4. Regenerate and verify

- Regenerate client after schema changes.
- Verify TypeScript usage in server query code.
- Confirm relation assumptions and enum usage still compile.

### 5. Report changes

- Include model/field changes, migration command, and validation outcomes.
- State whether migration files were created/applied or `db push` was used.

## Safety Rules

1. Do not edit generated Prisma files manually.
2. Prefer migrations over `db push` in shared environments.
3. Confirm `DATABASE_URL` target before destructive commands.
4. Keep schema and application query layer changes in sync.

## References

- Repository Prisma profile: `references/repo-profile.md`
- Migration decision and safety guide: `references/migration-playbook.md`

````

How to use this skill

  1. Click "Copy" to copy the skill content.
  2. Create a folder at .github/skills/prisma/ in your repository.
  3. Paste the content into SKILL.md inside the folder.
  4. Reference the skill name in your AI agent's instructions or copilot config.