Skip to content

Commit 25dd0b4

Browse files
committed
docs(ai): add Prisma application best practices to Cursor rule
1 parent b907926 commit 25dd0b4

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

apps/docs/content/docs/ai/tools/cursor.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ alwaysApply: false
6262
- When creating or managing Prisma Postgres databases, prefer the Prisma MCP server tools instead of guessing CLI/API steps.
6363
- Before changing Prisma setup, inspect `package.json`, `prisma.config.*`, `schema.prisma`, existing generated client imports, and the installed Prisma version.
6464
- Preserve existing Prisma Accelerate usage unless explicitly asked to migrate it.
65+
66+
## Prisma application best practices
67+
68+
- Validate inputs at API boundaries before calling Prisma Client.
69+
- Use `select` or scoped `include` to avoid over-fetching data.
70+
- Use transactions for multi-step writes that must succeed or fail together.
71+
- Handle known Prisma errors intentionally, especially constraint and validation errors.
72+
- Prefer integration tests against the same database provider used in production when testing Prisma behavior.
73+
- Mock Prisma Client only for isolated unit tests where database behavior is not under test.
74+
- Review generated migrations before applying them to shared or production environments.
75+
- Avoid exposing database-specific errors directly to end users.
76+
- Keep Prisma-related database access separate from unrelated business logic when it improves maintainability.
6577
```
6678

6779
For a simpler repo-wide setup, you can paste the same guidance into `AGENTS.md`.

0 commit comments

Comments
 (0)