-
Database
Add unique constraints where duplicates are bugs
Enforces uniqueness at the database level for emails, slugs, and one-per-user records so races can't create duplicates.
Free Prompt
What This Does / How This Helps
Moves uniqueness rules out of application code and into the database, where races can't bypass them. Check-then-insert is the pattern AI tools generate by default, and it's broken by design: two requests at the same moment both see 'no existing record' and both write. That's how apps end up with two accounts on one email, duplicate charges records, or five memberships for the same user. The database constraint is the only version that holds under concurrency. The prompt handles the practical blockers too: cleaning existing duplicates first, case sensitivity on emails, and mapping violations to friendly errors instead of raw database exceptions.
Want to skip doing this by hand?
Fortivibe audits your app for all of the areas these prompts cover (and more).