pg-aiguide is a knowledge and tooling project that gives AI coding assistants version-aware PostgreSQL documentation and curated database practices. Developers use it through agent skills, an MCP server, or a Claude Code plugin to help coding tools generate better PostgreSQL code. The catalogue entries are its skills, instructions, MCP integration, and rule.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add timescale/pg-aiguide --skill pgvector-semantic-searchgit clone --depth 1 https://github.com/timescale/pg-aiguideWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/timescale/pg-aiguide/pgvector-semantic-search)<a href="https://agentmods.dev/skills/timescale/pg-aiguide/pgvector-semantic-search"><img src="https://agentmods.dev/badge/skills/timescale/pg-aiguide/pgvector-semantic-search.svg" alt="Measured on agentmods" height="20"></a>- Socket pass
- Snyk pass
- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00190 | $0.03628 |
| Opus 5 | $0.00095 | $0.01814 |
| Sonnet 5 | $0.00038 | $0.00726 |
| Haiku 4.5 | $0.00019 | $0.00363 |
Grade A, and why
pgvector-semantic-search scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 345 lines — stays where its author put it; the contents beside it link to each section on GitHub.
pgvector for Semantic Search
Semantic search finds content by meaning rather than exact keywords. An embedding model converts text into high-dimensional vectors, where similar meanings map to nearby points. pgvector stores these vectors in PostgreSQL and uses approximate nearest neighbor (ANN) indexes to find the closest matches quickly—scaling to millions of rows without leaving the database. Store your text alongside its embedding, then query by converting your search text to a vector and returning the rows with the smallest distance.
This guide covers pgvector setup and tuning—not embedding model selection or text chunking, which significantly affect search quality. Requires pgvector 0.8.0+ for all features (halfvec, binary_quantize, iterative scan).
Golden Path (Default Setup)
Use this configuration unless you have a specific reason not to.
- Embedding column data type:
halfvec(N)whereNis your embedding dimension (must match everywhere). Examples use 1536; replace with your dimensionN. - Distance: cosine (
<=>) - Index: HNSW (
m = 16,ef_construction = 64). Usehalfvec_cosine_opsand query with<=>. - Query-time recall:
SET hnsw.ef_search = 100(good starting point from published benchmarks, increase for higher recall at higher latency) - Query pattern:
ORDER BY embedding <=> $1::halfvec(N) LIMIT k
This setup provides a strong speed–recall tradeoff for most text-embedding workloads.
Core Rules
- Enable the extension in each database:
CREATE EXTENSION IF NOT EXISTS vector; - Use HNSW indexes by default—superior speed-recall tradeoff, can be created on empty tables, no training step required. Only consider IVFFlat for write-heavy or memory-bound workloads.
- Use
halfvecby default—store and index ashalfvecfor 50% smaller storage and indexes with minimal recall loss. - Index after bulk loading initial data for best build performance.
- Create indexes concurrently in production:
CREATE INDEX CONCURRENTLY ... - Use cosine distance by default (
<=>): For non-normalized embeddings, use cosine. For unit-normalized embeddings, cosine and inner product yield identical rankings; default to cosine. - Match query operator to index ops: Index with
halfvec_cosine_opsrequires<=>in queries;halfvec_l2_opsrequires<->; mismatched operators won't use the index. - Always cast query vectors explicitly (
$1::halfvec(N)) to avoid implicit-cast failures in prepared statements. - Always use the same embedding model for data and queries. Similarity search only works when the model generating the vectors is the same.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 345 lines · 190 tokens per session scan A 0c23028b9bc8
pgvector-semantic-search is a skill published in the GitHub repository timescale/pg-aiguide (1,835 stars, last pushed 3d ago), licensed Apache-2.0. It adds 190 tokens to every session and 3,628 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
laravel-vector-search
Use when implementing semantic/vector search in Laravel 13 with PostgreSQL + pgvector.
azure-horizondb
Expert knowledge for Azure Horizondb development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when using azureai SQL/embeddings, pgvector tuning, Apache AGE graphs, hybrid…
030201-pgvector-embeddings
Vector search with pgvector — embedding generation (OpenAI or hash), HNSW indexing, cosine similarity search, and enriched product JOIN queries.
rag-architect
Designs and implements production-grade RAG systems by chunking documents, generating embeddings, configuring vector stores, building hybrid search pipelines, applying reranking, and evaluating retrieval quality. Use when building RAG systems, vector databases, or knowledge-grounded AI applications requiring semantic…
database-optimizer
Optimizes database queries and improves performance across PostgreSQL and MySQL systems. Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.
postgres-pro
Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.