How to get an agent to write a production-grade Postgres schema
Когда использовать: You want generated SQL that actually survives a code review.
Предварительные требования
- Add the pg-aiguide MCP — Point client at https://mcp.tigerdata.com/docs or install the Claude plugin
Поток
-
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.✓ Скопировано→ Agent cites view_skill output
-
Review constraints + indexesShow me every constraint you added and why. Any redundant indexes?✓ Скопировано→ 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.✓ Скопировано→ Modern idioms applied
Итог: Schema with sensible constraints, right identity columns, and indexes you can defend.
Подводные камни
- Agent overuses indexes — write-heavy tables slow down — Ask for workload-aware indexing — tell it the expected reads/writes ratio