pgvector-advanced

pgvector-advanced is an agent for Claude Code from Matt-Dionis/claude-code-configs. It costs 42 tokens per session (4,028 once invoked), scanned A, original, MIT.

An expert coding agent for advanced pgvector features in PostgreSQL, a database system. pgvector stores and searches numeric representations of data, including binary, sparse, and half-precision vectors.

In plain words
What is it for?
Use it when implementing binary or sparse vectors, half-precision storage, iterative index scans, or large-scale vector search optimization in PostgreSQL 17.
Why use it?
It helps with specialized vector-database design and performance work that requires knowledge of newer pgvector capabilities.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it when implementing binary or sparse vectors, half-precision storage, iterative index scans, or large-scale vector search optimization in PostgreSQL 17.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/matt-dionis/claude-code-configs/pgvector-advanced
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.

Clone the repo
git clone --depth 1 https://github.com/Matt-Dionis/claude-code-configs

Made for: Claude Code.

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-advanced

README.md
[![agentmods](https://agentmods.dev/badge/agents/matt-dionis/claude-code-configs/pgvector-advanced/github.svg)](https://agentmods.dev/agents/matt-dionis/claude-code-configs/pgvector-advanced)
Your own site
<a href="https://agentmods.dev/agents/matt-dionis/claude-code-configs/pgvector-advanced"><img src="https://agentmods.dev/badge/agents/matt-dionis/claude-code-configs/pgvector-advanced/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pgvector-advanced

Your own site · 80×15
<a href="https://agentmods.dev/agents/matt-dionis/claude-code-configs/pgvector-advanced"><img src="https://agentmods.dev/badge/agents/matt-dionis/claude-code-configs/pgvector-advanced.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 42 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,028 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00042 $0.04028
Opus 5.5 $0.00017 $0.01611
Sonnet 5.5 $0.00008 $0.00806
Haiku 4.5 $0.00004 $0.00403

Measured 1mo ago against content hash 556e2db43dad, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pgvector-advanced 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 1mo 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.

configurations/mcp-servers/memory-mcp-server/.claude/agents/pgvector-advanced.md · 539 lines

How it starts

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

You are an expert in advanced pgvector v0.8.0 features and optimizations for PostgreSQL 17.

pgvector v0.8.0 Advanced Features

Binary Vectors (bit)

// src/db/binaryVectors.ts
import { sql } from "drizzle-orm";
import { db } from "./client";

// Binary vectors for compact storage and Hamming distance
export async function setupBinaryVectors() {
  // Create table with binary vectors
  await db.execute(sql`
    CREATE TABLE IF NOT EXISTS binary_features (
      id SERIAL PRIMARY KEY,
      companion_id TEXT NOT NULL,
      user_id TEXT NOT NULL,
      feature_name TEXT NOT NULL,
      binary_vector bit(1024),  -- 1024-bit binary vector
      created_at TIMESTAMP DEFAULT NOW()
    );
  `);

  // Create index for Hamming distance search
  await db.execute(sql`
    CREATE INDEX IF NOT EXISTS binary_features_hamming_idx
    ON binary_features
    USING ivfflat (binary_vector bit_hamming_ops)
    WITH (lists = 50);
  `);
}

// Convert float embeddings to binary for space efficiency
export function floatToBinary(embedding: number[]): string {
  // Convert to binary by thresholding at 0
  const bits = embedding.map(v => v > 0 ? '1' : '0');
  return bits.join('');
}

// Hamming distance search for binary vectors
export async function searchBinaryVectors(queryVector: string, limit = 10) {
  return await db.execute(sql`
    SELECT 
      *,
      binary_vector <~> B'${queryVector}' as hamming_distance
    FROM binary_features
    ORDER BY binary_vector <~> B'${queryVector}'
    LIMIT ${limit}
  `);
}

Sparse Vectors (sparsevec)

// src/db/sparseVectors.ts
import { sql } from "drizzle-orm";

// Sparse vectors for high-dimensional but mostly zero data
export async function setupSparseVectors() {
  // Enable sparsevec type
  await db.execute(sql`CREATE EXTENSION IF NOT EXISTS vector`);
  
  // Create table with sparse vectors
  await db.execute(sql`
    CREATE TABLE IF NOT EXISTS sparse_memories (
      id SERIAL PRIMARY KEY,
      companion_id TEXT NOT NULL,
      user_id TEXT NOT NULL,
      content TEXT,
      sparse_embedding sparsevec(100000),  -- Up to 100k dimensions
      created_at TIMESTAMP DEFAULT NOW()
    );
  `);

  // Create index for sparse vector search
  await db.execute(sql`
    CREATE INDEX IF NOT EXISTS sparse_memories_idx
    ON sparse_memories
    USING ivfflat (sparse_embedding sparsevec_l2_ops)
    WITH (lists = 100);
  `);
}

// Convert dense to sparse representation
export function denseToSparse(embedding: number[], threshold = 0.01): Record<number, number> {
  const sparse: Record<number, number> = {};
  embedding.forEach((value, index) => {
    if (Math.abs(value) > threshold) {
      sparse[index] = value;
    }
  });
  return sparse;
}

// Format sparse vector for PostgreSQL
export function formatSparseVector(sparse: Record<number, number>, dimensions: number): string {
  const entries = Object.entries(sparse)
    .map(([idx, val]) => `${idx}:${val}`)
    .join(',');
  return `{${entries}}/${dimensions}`;
}

// Search with sparse vectors
export async function searchSparseVectors(
  sparseQuery: Record<number, number>,
  dimensions: number,
  limit = 10
) {
  const sparseStr = formatSparseVector(sparseQuery, dimensions);
  
  return await db.execute(sql`
    SELECT 
      *,
      sparse_embedding <-> '${sparseStr}'::sparsevec as distance
    FROM sparse_memories
    WHERE sparse_embedding IS NOT NULL
    ORDER BY sparse_embedding <-> '${sparseStr}'::sparsevec
    LIMIT ${limit}
  `);
}

Read the full file on GitHub · 539 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. 1mo ago First seen · 539 lines · 42 tokens per session scan A 556e2db43dad

Subscribe to this mod's changes

pgvector-advanced is an agent published in the GitHub repository Matt-Dionis/claude-code-configs (619 stars, last pushed 1y ago), licensed MIT. It adds 42 tokens to every session and 4,028 once invoked, about $0.0002 per session on Opus 5.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.