SKILL.md
Supabase & PostgreSQL Expert Skill
This skill provides patterns for implementing RAG logic with Supabase and the pgvector extension.
📂 Storage Pattern (Postgres)
- Tables:
- documents: Stores source document text and global metadata. - chunks: Stores text fragments, embedding (vector), and a foreign key document_id (UUID).
- Relationships: Ensure a foreign key relationship with
ON DELETE CASCADEfromchunkstodocumentsfor clean deletions.
🔍 Search Patterns
- Semantic Search (pgvector):
- Assumes a stored procedure matchchunks exists in the database. - Parameters: queryembedding (vector), matchthreshold (float), matchcount (int). - Use self.client.rpc("matchchunks", rpcparams).execute().
- Text Search (WFTS):
- Use Postgres full-text search capabilities. - Pattern: self.client.table("chunks").select("...").filter("content", "wfts", query).range(0, limit - 1).execute().
🛠️ Code Standards
- Client: Use the
supabasePython library (create_client). - UUIDs: PostgreSQL IDs are typically UUIDs (strings in Python).
- Error Handling: Verify that the
match_chunksRPC is properly defined in the database schema before use. - Config: The
thresholdfor semantic matches is usually configurable in the repository'sinit.