No. 112 Shape the design

Database Best Practices

Use when you need the shape and the files named before anyone edits

  • Claude Code
  • Codex
  • Cursor
  • Shape the design

Prompt

# Database Best Practices

## Prisma Setup
- Use proper schema design
- Implement proper migrations
- Use proper relation definitions
- Configure proper connection
- Implement proper seeding
- Use proper client setup

## Prisma Models
- Use proper model naming
- Implement proper relations
- Use proper field types
- Define proper indexes
- Implement proper constraints
- Use proper enums

## Prisma Queries
- Use proper query optimization
- Implement proper filtering
- Use proper relations loading
- Handle transactions properly
- Implement proper pagination
- Use proper aggregations

## Supabase Setup
- Configure proper project setup
- Implement proper authentication
- Use proper database setup
- Configure proper storage
- Implement proper policies
- Use proper client setup

## Supabase Security
- Implement proper RLS policies
- Use proper authentication
- Configure proper permissions
- Handle sensitive data properly
- Implement proper backups
- Use proper encryption

## Supabase Queries
- Use proper query optimization
- Implement proper filtering
- Use proper joins
- Handle real-time properly
- Implement proper pagination
- Use proper functions

## Database Design
- Use proper normalization
- Implement proper indexing
- Use proper constraints
- Define proper relations
- Implement proper cascades
- Use proper data types

## Performance
- Use proper connection pooling
- Implement proper caching
- Use proper query optimization
- Handle N+1 queries properly
- Implement proper batching
- Monitor performance metrics

## Security
- Use proper authentication
- Implement proper authorization
- Handle sensitive data properly
- Use proper encryption
- Implement proper backups
- Monitor security issues

## Best Practices
- Follow database conventions
- Use proper migrations
- Implement proper versioning
- Handle errors properly
- Document schema properly
- Monitor database health

When to use

“Database Best Practices” fits when you need the shape and the files named before anyone edits, because it says “Database Best Practices”, and it is written to stay in force on later turns rather than to finish one task.

With “Database Best Practices” loaded, the user message can be as small as “fix the empty-cart total in src/cart.js and do not touch the test runner”, because “Database Best Practices” is already in force.

When not to use

Leave “Database Best Practices” unused when a test is already red and you need the cause, not a new diagram, because “Database Best Practices” points the other way

How to run it

Claude Code

Claude Code loads “Database Best Practices” from .claude/rules on later sessions, so “Database Best Practices” survives a new chat, which a one-off paste does not.

Codex

Codex keeps “Database Best Practices” only if you put “Database Best Practices” in AGENTS.md, or in AGENTS.override.md beside the directory that should inherit it. A paste that is not saved is gone next thread.

Cursor

Cursor keeps “Database Best Practices” by saving “Database Best Practices” as .cursor/rules. The chat transcript alone will not reload it tomorrow.

Comparison

对比待补

This before-and-after was not run on this machine.

Related

来源:PatrickJS awesome-cursorrules · https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/database.mdc · CC0-1.0 · 2026-12-01