naman10parikh/acorn/pgvector-rag
Claude Code and agent skill by naman10parikh/acorn
- community
Checking that the SKILL.md file is still in the repository.
Store and search embeddings / add semantic search over Postgres with pgvector. Use when the ask is "add semantic search", "store embeddings", "build RAG over this table", "vector search is slow", or "tenant-scoped similarity search". Encodes HNSW default, halfvec for ≥1536-dim, measure-recall-first, and iterative_scan for tenant-filtered ANN.
Install
npx vskill@latest install naman10parikh/acorn/pgvector-ragSKILL.md
The same SKILL.md was published earlier as naman10parikh/acorn/pgvector-rag.
pgvector-rag
Brain source:brain/OPINIONS.md§pgvector ·brain/KNOWN-PITFALLS.md§pgvector (P24-P27) ·brain/BATTLE-TESTED-SCENARIOS.md#9 (filtered-ANN over-filter), #10 (halfvec storage blowup) ·brain/EXPERTISE-MAP.mdJTBD 4. energy stores no embeddings in Postgres today — acorn owns the vector playbook.
Trigger
"Add semantic search over documents", "store OpenAI embeddings in Postgres", "RAG scoped to the current tenant", "our vector queries got slow", "which index for pgvector".
Steps
- Index choice: default HNSW. Higher QPS, lower p99, builds incrementally on an empty/growing table (no retrain). Reach for IVFFlat only when memory-constrained and data is static (must be built AFTER data loads; degrades as data drifts).
- Storage: default `halfvec` for ≥1536-dim. A 1536-dim
float4vector = 6,148 bytes/row before the graph;halfvec(float16) is an exact 50% cut + ~23% faster build with matching recall — "an obvious choice." Fullvector()only if you MEASURED a recall regression. Binary quantization (1-bit) only behind a re-rank stage (it tanks recall on 1536-dim alone). - Tune by measuring recall FIRST. Raise query-time
hnsw.ef_search(default 40 → too low; raise to 200–800) — it is free, no rebuild. Only after measuring a recall gap, raise build-timem/ef_construction(they double build time + memory for a marginal gain). - Tenant-filtered ANN: enable `hnsw.iterative_scan`.
WHERE tenant_id = ? AND embedding <=> ? LIMIT 10on pre-0.8 pgvector over-filters (HNSW returns k candidates, the filter drops most, you get <k).SET hnsw.iterative_scan = 'relaxed_order';keeps scanning until enough rows pass. Confirm the provider ships pgvector ≥ 0.8 (acorn doctorreports it). For very large tenants, a partial HNSW index per tenant. - Match the op-class to the operator:
vector_cosine_ops↔<=>,vector_l2_ops↔<->,vector_ip_ops↔<#>(halfvec variants for halfvec columns). - Record the embedding model + dimension in a column — the only way to detect model drift on re-embed.
Output
The CREATE TABLE (with halfvec/vector chosen by dimension + a tenant_id + an embedding_model column) and the CREATE INDEX (HNSW + the tenant index + the iterative_scan/ef_search settings), via acorn vector plan --dim <n> --provider <supabase|neon> → src/gen/vector-plan.ts. Boundary reminder: acorn stores/indexes/searches embeddings; generating the vectors (OpenAI/Cohere/Voyage calls) is app code, not acorn's.
Worked example
Ask: "Add semantic search over `documents`, scoped to the current tenant. 1536-dim OpenAI embeddings, millions of rows, on Supabase." (Scenarios #9 + #10)
acorn emits (`acorn vector plan --dim 1536 --provider supabase`):
acorn then says: "Run `acorn doctor` first to confirm Supabase ships pgvector ≥ 0.8 — without `iterative_scan` a tenant with 1000 matches will return <10. Measure recall@10 before touching `m`/`ef_construction`." The halfvec switch alone drops table+index size ~50% with no recall regression at the same ef_search (Scenario #10).
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/pgvector-rag/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/naman10parikh/acorn/pgvector-rag)