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