Configure pgvector extension for vector search in Supabase - includes embedding storage, HNSW/IVFFlat indexes, hybrid search setup, and AI-optimized query patterns. Use when setting up vector search, building RAG systems, configuring semantic search, creating embedding storage, or when user mentions pgvector, vector database, embeddings, semantic search, or hybrid search.
View on GitHubFebruary 1, 2026
Select agents to install to:
npx add-skill https://github.com/vanman2024/ai-dev-marketplace/blob/main/plugins/supabase/skills/pgvector-setup/SKILL.md -a claude-code --skill pgvector-setupInstallation paths:
.claude/skills/pgvector-setup/# pgvector-setup ## Instructions This skill provides complete pgvector setup for Supabase databases, enabling vector search capabilities for AI applications, RAG systems, and semantic search. ### Phase 1: Enable pgvector Extension 1. Run the setup script to enable pgvector: ```bash bash scripts/setup-pgvector.sh [SUPABASE_DB_URL] ``` This creates the pgvector extension and sets up basic embedding tables. 2. Choose your embedding dimensions based on your model: - OpenAI text-embedding-3-small: 1536 dimensions - OpenAI text-embedding-3-large: 3072 dimensions - Cohere embed-english-v3.0: 1024 dimensions - Custom models: Check model documentation ### Phase 2: Create Embedding Tables 1. Use the embedding table template: ```bash # Copy template and customize for your use case cat templates/embedding-table-schema.sql ``` 2. Customize the schema: - Adjust vector dimensions to match your model - Add metadata columns (tags, timestamps, user_id, etc.) - Configure RLS policies for security 3. Apply the schema: ```bash psql $SUPABASE_DB_URL < templates/embedding-table-schema.sql ``` ### Phase 3: Create Vector Indexes **Choose index type based on your data size:** **HNSW (Recommended for most cases):** - Best for: < 1M vectors, high recall requirements - Pros: Fast queries, good recall, works well with small-medium datasets - Cons: Slower inserts, higher memory usage - Run: `bash scripts/create-indexes.sh hnsw [TABLE_NAME] [DIMENSION]` **IVFFlat:** - Best for: > 1M vectors, write-heavy workloads - Pros: Faster inserts, lower memory - Cons: Requires training, lower recall - Run: `bash scripts/create-indexes.sh ivfflat [TABLE_NAME] [DIMENSION]` **Performance Tuning:** - HNSW m parameter (default 16): Higher = better recall, more memory - HNSW ef_construction (default 64): Higher = better quality, slower builds - IVFFlat lists (default sqrt(rows)): More lists = faster queries, lower recall ### Phase 4: Implement Se