Postgres Vectors

Use when working with embeddings, semantic similarity, vector search, or the <-> <#> <=> operators. Load for pgvector queries, HNSW index creation, embedding storage, or similarity calculations. Covers distance operators, index strategies, and common pitfalls with 384-dimensional vectors.

8 stars 3 forksDatabases Plugin marketplace

Install

Claude Code plugin
/plugin marketplace add Freddy-CHEN-ux/00_claude_skills

The repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add Freddy-CHEN-ux/00_claude_skills --skill postgres-vectors
Manual install
git clone --depth 1 https://github.com/Freddy-CHEN-ux/00_claude_skills.git /tmp/00_claude_skills
mkdir -p ~/.claude/skills
cp -r /tmp/00_claude_skills/skills/postgres-vectors ~/.claude/skills/postgres-vectors

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Postgres Vectors (pgvector)

Vector similarity search patterns for semantic matching.

> **Announce:** "I'm using postgres-vectors to implement vector similarity correctly."

## Vector Storage

Embeddings are stored in the `embeddings` table:

```sql
CREATE TABLE embeddings (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  source_text text NOT NULL,
  embedding extensions.vector(384) NOT NULL,  -- 384 dimensions from gte-small
  created_at timestamptz DEFAULT now()
);

-- Unique constraint prevents duplicate embeddings
CREATE UNIQUE INDEX idx_embeddings_source_text 
ON embeddings (source_text);
```

**Key points:**
- Use `extensions.vector(384)` - pgvector is in extensions schema
- 384 dimensions matches gte-small model output
- Deduplicate by source_text

## Distance Operators

| Operator | Distance Type | Use Case |
|----------|---------------|----------|
| `<->` | L2 (Euclidean) | General purpose |
| `<#>` | Inner product (negative) | Normalized vectors (fastest) |
| `<=>` | Cosine distance | When normalization varies |

**For this project:** Use `<=>` (cosine) since we want similarity regardless of vector magnitude.

```sql
-- Cosine similarity = 1 - cosine_distance
SELECT 
  id,
  1 - (embedding <=> query_embedding) AS similarity
FROM embeddings
WHERE 1 - (embedding <=> query_embedding) > 0.5  -- 0.5 threshold
ORDER BY embedding <=> query_embedding  -- ASC for distance
LIMIT 10;
```

## Index Strategy

### When to Use HNSW
Read the full skill on GitHub

Details

Skill name
postgres-vectors
Path
skills/postgres-vectors/SKILL.md
Repo updated
10 January 2026

FAQ

What does the Postgres Vectors skill do?

Use when working with embeddings, semantic similarity, vector search, or the <-> <#> <=> operators. Load for pgvector queries, HNSW index creation, embedding storage, or similarity calculations. Covers distance operators, index strategies, and common pitfalls with 384-dimensional vectors.

How do I install the Postgres Vectors skill?

Claude Code plugin: /plugin marketplace add Freddy-CHEN-ux/00_claude_skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Postgres Vectors popular?

It lives in Freddy-CHEN-ux/00_claude_skills, which has 8 GitHub stars and 3 forks.

Related skills

Browse the most popular Claude skills, all databases skills, or write your own with the skills generator.