pgvector-search

pgvector-search is a skill for Claude Code, Codex from ArieGoldkin/claude-forge. It costs 32 tokens per session (1,922 once invoked), scanned A, original, MIT.

An aspirational guide to combining PostgreSQL vector search with BM25 keyword search, then merging the rankings. It also describes metadata filters and performance improvements, but says these patterns are not implemented in the reference platform.

In plain words
What is it for?
Use it as design guidance for hybrid search with PGVector, keyword matching, result merging, metadata filtering, and retrieval optimization.
Why use it?
It explains a possible way to retrieve documents by both meaning and exact words, while clearly separating planned patterns from available functionality.

Skill for Claude CodeCodex

Part of the atk plugin — 16 skills, 25 commands, 1 agent, 1 hook shipped together

Install

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.

agentmods
npx agentmods add skills/ariegoldkin/claude-forge/pgvector-search
Any agent
npx skills add ArieGoldkin/claude-forge --skill pgvector-search
Clone the repo
git clone --depth 1 https://github.com/ArieGoldkin/claude-forge

Made for: Claude Code, Codex.

Or install atk, the plugin that ships this one along with the rest of its 16 skills, 25 commands, 1 agent, 1 hook.

Wrote 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.

agentmods badge for pgvector-search

README.md
[![agentmods](https://agentmods.dev/badge/skills/ariegoldkin/claude-forge/pgvector-search.svg)](https://agentmods.dev/skills/ariegoldkin/claude-forge/pgvector-search)
Your own site
<a href="https://agentmods.dev/skills/ariegoldkin/claude-forge/pgvector-search"><img src="https://agentmods.dev/badge/skills/ariegoldkin/claude-forge/pgvector-search.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,922 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00032 $0.01922
Opus 5 $0.00016 $0.00961
Sonnet 5 $0.00006 $0.00384
Haiku 4.5 $0.00003 $0.00192

Measured 5d ago against content hash 78467e3ef7d4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

pgvector-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 5d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (templates/chunk-repository.py, templates/search-service.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

plugins/ai-toolkit/skills/pgvector-search/SKILL.md · 245 lines

How it starts

The opening of the file, as written. The whole thing — 245 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Aspirational — these patterns are not yet implemented in the reference platform.

Production-grade semantic + keyword search using PostgreSQL

Overview

Hybrid search combines semantic similarity (vector embeddings) with keyword matching (BM25) to achieve better retrieval than either alone.

Architecture:

Query
  ↓
[Generate embedding] → Vector Search (PGVector) → Top 30 results
  ↓
[Generate ts_query]  → Keyword Search (BM25)    → Top 30 results
  ↓
[Reciprocal Rank Fusion (RRF)] → Merge & re-rank → Top 10 final results

Core Concepts

1. Semantic Search (Vector Similarity)

How it works:

  1. Embed query: "database indexing strategies"[0.23, -0.15, ..., 0.42] (1024 dims)
  2. Find nearest neighbors: ORDER BY embedding <=> query_embedding LIMIT 30
  3. Returns: Conceptually similar documents (even with different words)

Example:

  • Query: "machine learning model training"
  • Matches: "neural network optimization", "deep learning techniques"
  • Misses: "ML model training" (different embeddings despite similar meaning)

Strengths:

  • Captures semantic meaning
  • Works across languages
  • Handles synonyms ("car" matches "automobile")

Weaknesses:

  • Slow for exact keyword matches
  • Sensitive to embedding quality
  • Doesn't handle rare technical terms well

2. Keyword Search (BM25)

How it works:

  1. Tokenize query: "database indexing"database & indexing
  2. Full-text search: WHERE content_tsvector @@ to_tsquery('database & indexing')
  3. Rank by BM25 score (TF-IDF + document length normalization)

Example:

  • Query: "PostgreSQL B-tree index"
  • Matches: Documents with exact phrase "PostgreSQL B-tree index"
  • Misses: "Postgres tree-based indexing" (different words)

Strengths:

  • Fast exact matches
  • Handles technical terms well
  • Works for rare/specific phrases

Weaknesses:

  • No semantic understanding
  • Requires exact word matches
  • Sensitive to typos

3. Reciprocal Rank Fusion (RRF)

Read the full file on GitHub · 245 lines

Changes

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.

  1. 5d ago First seen · 245 lines · 32 tokens per session scan A 78467e3ef7d4

Subscribe to this mod's changes

pgvector-search is a skill published in the GitHub repository ArieGoldkin/claude-forge (6 stars, last pushed 27d ago), licensed MIT. It adds 32 tokens to every session and 1,922 once invoked, about $0.0002 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-31.

Related

Other skills, from other repositories

030201-pgvector-embeddings

Vector search with pgvector — embedding generation (OpenAI or hash), HNSW indexing, cosine similarity search, and enriched product JOIN queries.

natuleadan/skills · 38 tokens

pgvector-semantic-search

Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. Trigger when user asks to: Store or search vector embeddings in PostgreSQL Set up semantic search, similarity search, or nearest neighbor search Create HNSW or IVFFlat indexes for vectors…

timescale/pg-aiguide · 190 tokens

postgres-hybrid-text-search

Use this skill to implement hybrid search combining BM25 keyword search with semantic vector search using Reciprocal Rank Fusion (RRF). Trigger when user asks to: Combine keyword and semantic search Implement hybrid search or multi-modal retrieval Use BM25/pgtextsearch with pgvector together Implement RRF (Reciprocal…

timescale/pg-aiguide · 162 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…

awslabs/agent-plugins · 229 tokens

ai-vector-brain

Builds vector-brain implementations for repos, docs hubs, and compliance corpora. Use when creating pgvector retrieval brains with scripts, SQL, manifests, and evals.

vasilyu1983/AI-Agents-public · 40 tokens

building-agents

Use when building or restructuring an LLM agent — provider adapter, tool calling, structured output, RAG, agent loop, eval gate, cost routing, tracing, MCP server — model-agnostic across OpenAI/Anthropic/Gemini/OSS so a model swap is a config change. NOT vector-store SQL alone (that is postgresdb) or service…

ericrisco/rsc-harness · 85 tokens