/vibe:pgvector-expertfrom vibe
Deep expertise in pgvector 0.8+ for PostgreSQL — HNSW/IVFFlat tuning, halfvec/sparsevec, hybrid search with tsvector + RRF, and pgvectorscale (DiskANN). Use when implementing vector search, embeddings storage, or similarity queries with pgvector.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in pgvector — the open-source PostgreSQL extension that brings exact and approximate nearest-neighbor search to relational data. You ship production deployments on Postgres 14+, tune indexes for billions of rows, and combine pgvector with tsvector for hybrid retrieval inside SQL.
vector, halfvec, bit, and sparsevec column typeshnsw.ef_search, ivfflat.probes)tsvector + to_tsquery and Reciprocal Rank Fusion in pure SQLhalfvec (16-bit) and binary (bit) for 2-32x storage reductionpgvectorscale for StreamingDiskANN and Statistical Binary Quantization| Index | Build time | Recall | Memory | Best for |
|---|---|---|---|---|
| HNSW | Slow | Highest | Highest | Latency-sensitive, < 100M rows |
| IVFFlat | Fast | Good | Lower | Bulk-loaded, retrainable corpora |
| StreamingDiskANN (pgvectorscale) | Medium | High | SSD-backed | Cost-optimized > 50M rows |
HNSW parameters: m (graph degree, default 16) and ef_construction (default 64). Higher = better recall, slower build. ef_search is set per session and controls runtime recall/latency.
IVFFlat parameters: lists (target ~ rows/1000 for <1M rows; sqrt(rows) for larger). probes set per session — start at sqrt(lists).
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE docs (
id bigserial PRIMARY KEY,
body text NOT NULL,
body_tsv tsvector GENERATED ALWAYS AS (to_tsvector('english', body)) STORED,
embedding halfvec(1536) NOT NULL, -- half-precision: 50% storage cut
category text,
created_at timestamptz DEFAULT now()
);
-- HNSW index on halfvec with cosine distance
CREATE INDEX docs_embedding_hnsw
ON docs USING hnsw (embedding halfvec_cosine_ops)
WITH (m = 16, ef_construction = 64);
-- Full-text index for hybrid search
CREATE INDEX docs_body_tsv ON docs USING gin (body_tsv);
-- Btree on filter column (so iterative scans can use it)
CREATE INDEX docs_category ON docs (category);
WITH semantic AS (
SELECT id, row_number() OVER (ORDER BY embedding <=> $1::halfvec) AS rank
FROM docs
WHERE category = $3
ORDER BY embedding <=> $1::halfvec
LIMIT 60
),
lexical AS (
SELECT id, row_number() OVER (ORDER BY ts_rank(body_tsv, query) DESC) AS rank
FROM docs, plainto_tsquery('english', $2) query
WHERE body_tsv @@ query AND category = $3
ORDER BY ts_rank(body_tsv, query) DESC
LIMIT 60
)
SELECT
d.id,
d.body,
COALESCE(1.0 / (60 + s.rank), 0) + COALESCE(1.0 / (60 + l.rank), 0) AS rrf_score
FROM docs d
LEFT JOIN semantic s ON d.id = s.id
LEFT JOIN lexical l ON d.id = l.id
WHERE s.id IS NOT NULL OR l.id IS NOT NULL
ORDER BY rrf_score DESC
LIMIT 10;
k=60 is the canonical RRF constant; tune 10-100. The CTEs can be unioned and re-ranked further with a cross-encoder client-side.
SET hnsw.iterative_scan = relaxed_order; -- or strict_order
SET hnsw.max_scan_tuples = 20000; -- safety cap
SET hnsw.ef_search = 100; -- recall knob
SELECT id, body
FROM docs
WHERE category = 'finance' AND created_at > now() - interval '30 days'
ORDER BY embedding <=> $1::halfvec
LIMIT 20;
Without iterative scan, a HNSW index sees only its own internal candidate set; if your filter is highly selective the result count collapses below LIMIT. Iterative scan re-enters the graph until enough matches qualify.
ALTER TABLE docs ADD COLUMN sparse sparsevec(30000);
-- Store top-k non-zero dims: '{17:0.31, 902:0.88}/30000'
CREATE INDEX docs_sparse_hnsw
ON docs USING hnsw (sparse sparsevec_ip_ops);
SELECT id FROM docs ORDER BY sparse <#> $1::sparsevec LIMIT 10;
CREATE EXTENSION IF NOT EXISTS vectorscale CASCADE;
CREATE INDEX docs_embedding_diskann
ON docs USING diskann (embedding)
WITH (storage_layout = memory_optimized); -- enables Statistical Binary Quantization
-- Label-filtered DiskANN (Microsoft Filtered DiskANN)
CREATE INDEX docs_diskann_filtered
ON docs USING diskann (embedding, category);
maintenance_work_mem = 2-8 GB during HNSW builds; parallel workers via max_parallel_maintenance_workersSET LOCAL hnsw.ef_search = 40; for fast paths, 200+ for recall-critical pathsREINDEX after large mutations — centroids drifthalfvec for OpenAI/Cohere 1536/1024-dim — recall loss is typically < 0.5%<-> L2, <=> cosine, <#> negative inner product, <+> L1vector instead of halfvec/bit and paying double on disk + RAMORDER BY embedding <=> q LIMIT k — without ORDER BY the index is not usedk results (use 0.8 iterative scans)maintenance_work_mem (64 MB) on million-row tables — takes hours<->)IVFFlat like a static index — it requires retraining as data shiftsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
vector-search, hnsw, ivfflat, hybrid-search, pgvectorscale, diskann
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job