How to get an agent to write a production-grade Postgres schema
Wann einsetzen: You want generated SQL that actually survives a code review.
Voraussetzungen
- Add the pg-aiguide MCP — Point client at https://mcp.tigerdata.com/docs or install the Claude plugin
Ablauf
-
State the domainI need a schema for a multi-tenant SaaS with orgs, users, projects, invites. Before writing SQL, consult pg-aiguide for schema design and identifier best practices.✓ Kopiert→ Agent cites view_skill output
-
Review constraints + indexesShow me every constraint you added and why. Any redundant indexes?✓ Kopiert→ Per-index justification
-
Check modern featuresUse search_docs to verify you're using GENERATED ALWAYS AS IDENTITY (not SERIAL), and NULLS NOT DISTINCT where appropriate.✓ Kopiert→ Modern idioms applied
Ergebnis: Schema with sensible constraints, right identity columns, and indexes you can defend.
Fallstricke
- Agent overuses indexes — write-heavy tables slow down — Ask for workload-aware indexing — tell it the expected reads/writes ratio