• AI coding agents के Postgres को सही तरीके से हैंडल न कर पाने की समस्या को हल करने के लिए, database rules को स्पष्ट रूप से उपलब्ध कराने वाले Agent Skills जारी किए गए हैं
  • Postgres में दशकों से जमा फीचर्स, edge cases, और performance characteristics हैं, इसलिए एजेंट काम तो कर लेते हैं लेकिन ऐसा code बना सकते हैं जो full table scan कराए या security policies को छोड़ दे
  • यह कुल 8 categories और 30 rules से बना है, और query performance, connection management, security व RLS, schema design आदि को impact के आधार पर priority के अनुसार व्यवस्थित करता है
  • इसे इंसानों के पढ़ने वाले document के रूप में नहीं, बल्कि AI agents द्वारा सीधे refer किए जाने वाले rule set के रूप में दिया गया है
  • MCP server के साथ जोड़ने पर, execution capability और decision criteria दोनों से लैस व्यावहारिक database agent तैयार किया जा सकता है

समस्या की पहचान: AI code लिखता है, लेकिन system को समझता नहीं

  • AI coding agents syntactically सही code बना लेते हैं, लेकिन Postgres की internal characteristics और operational risks को ध्यान में न रख पाने की सीमा बनी रहती है
  • full table scan कराने वाली queries, write performance को गिराने वाले index suggestions, और Row Level Security छूट जाने जैसी समस्याएं बार-बार सामने आती हैं
  • production environment में महत्वपूर्ण performance, security, और stability factors को agents द्वारा miss करने के कई मामले देखे गए हैं

Postgres Agent Skills का परिचय

  • यह rules-based knowledge repository है, जिसे AI agents के लिए बनाया गया है ताकि वे Postgres code लिखते समय इसका संदर्भ ले सकें
  • इसमें कुल 30 rules हैं, जो impact के आधार पर क्रमबद्ध 8 categories में संगठित हैं
  • हर rule में title, priority, महत्व का विवरण, और सही/गलत code examples शामिल हैं

8 rule categories की संरचना

  • हर rule एक consistent format का पालन करता है, जिसमें title, impact, description, और tags शामिल होते हैं
  • Query Performance (Critical): full table scan रोकने और efficient queries लिखने के नियम
  • Connection Management (Critical): connection pooling, client lifecycle management, resource limits
  • Security and RLS (Critical): Row Level Security policies, access control patterns
  • Schema Design (High): table structure, data types, normalization पर निर्णय
  • Concurrency and Locking (Medium-High): transaction isolation, deadlock prevention, lock management
  • Data Access Patterns (Medium): pagination, bulk operations, access pattern design
  • Monitoring and Diagnostics (Low-Medium): query analysis, performance tracking, debugging
  • Advanced Features (Low): CTE, window functions, extensions जैसी Postgres-विशिष्ट सुविधाएं

Row Level Security rule का उदाहरण

  • गलत तरीका: अगर केवल application-level filtering पर निर्भर रहें, तो bug या bypass की वजह से पूरा data उजागर होने का जोखिम रहता है
    • select * from orders where user_id = $current_user_id; जैसे लिखने पर bypass होने की स्थिति में सभी orders लौट सकते हैं
  • सही तरीका: database स्तर पर RLS को enforce करना
    • alter table orders enable row level security; से RLS सक्रिय करना
    • create policy से ऐसी policy बनाना कि user केवल अपना data देख सके
    • alter table orders force row level security; से table owner पर भी RLS लागू करना
  • authenticated role के लिए policy example: create policy orders_user_policy on orders for all to authenticated using (user_id = auth.uid());

Agent Skills format और ecosystem

  • Agent Skills एक open standard format में AI agents के लिए विशेष document format है, जो agents को domain expertise देता है और जरूरत पड़ने पर agent इसे सीधे पढ़कर लागू कर सकता है
    • Claude Code, Cursor, GitHub Copilot, VS Code, Gemini CLI आदि के साथ compatible
    • यह ऐसे folder के रूप में आता है जिसमें instructions और examples होते हैं, जिन्हें agent जरूरत पड़ने पर खोजकर इस्तेमाल कर सकता है
    • training data से सही patterns सीख लेने की उम्मीद करने के बजाय explicit rules उपलब्ध कराता है
  • यह Anthropic द्वारा परिभाषित open standard है, जिसे पूरे industry में अपनाया जा रहा है
    • Vercel ने 10 वर्षों के React और Next.js optimization knowledge को 40 rules में पैकेज करके react-best-practices जारी किया
    • Cloudflare ने Workers, Pages, D1, R2 सहित 40 से अधिक services के लिए Skills जारी किए

Supabase ने ये rules क्यों बनाए

  • Supabase सैकड़ों हजार projects में Postgres चला रहा है और उसने देखा कि वही गलतियां बार-बार दोहराई जाती हैं
    • Foreign keys पर index का न होना
    • गलती से RLS को bypass करने वाली queries
    • production में tables को lock कर देने वाली migrations
    • गलत तरीके से managed clients की वजह से connection pool exhaustion
    • ORM के पीछे छिपे full table scans
  • support team, database advisor, और documentation में पहले से मौजूद knowledge को agent-friendly format में दोबारा संगठित करके पैकेज किया गया

MCP server से संबंध

  • Supabase MCP server AI agents को Supabase projects से सीधे जोड़कर tables बनाना, queries चलाना, schema manage करना, और settings configure करना जैसी चीजें natural language में करने देता है
  • MCP server agents को database काम करने की capability देता है, जबकि best practices उन्हें यह काम सही तरीके से करना सिखाती हैं
  • उपमा: MCP server steering wheel है, best practices driving lessons हैं
  • केवल MCP access वाले agent से कहा गया कोई भी query execute कराया जा सकता है
  • MCP access और rules दोनों वाले agent index बनाने से पहले, अगर उससे table lock हो सकता हो, तो चेतावनी दे सकते हैं; unsafe code deploy होने से पहले RLS policy सुझा सकते हैं; और performance issues से बचने के लिए query को बेहतर ढंग से structure कर सकते हैं
  • MCP server connection और execution संभालता है, जबकि ये best practices judgment संभालती हैं
  • Agent Skills execution से पहले risks की चेतावनी देते हैं और बेहतर विकल्प चुनने की ओर मार्गदर्शन करते हैं
  • execution capability और judgment criteria को अलग करके safe और reliable automation environment बनाया जा सकता है

इंस्टॉल करने का तरीका

  • repository location: github.com/supabase/agent-skills
  • Vercel के skills npm package का उपयोग करके interactive installation संभव है
    • npx skills add supabase/agent-skills
  • Claude Code इस्तेमाल करने पर plugin के रूप में install किया जा सकता है
    • /plugin marketplace add supabase/agent-skills
    • /plugin install postgres-best-practices@supabase-agent-skills

अभी कोई टिप्पणी नहीं है.

अभी कोई टिप्पणी नहीं है.