Similarity Search Patterns skill for Claude

Implement efficient similarity search with vector databases.

When Claude uses it

Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.

Similarity Search Patterns SKILL.md

The full skill file from wshobson/agents (MIT).

Similarity Search Patterns

Patterns for implementing efficient similarity search in production systems.

When to Use This Skill

  • Building semantic search systems
  • Implementing RAG retrieval
  • Creating recommendation engines
  • Optimizing search latency
  • Scaling to millions of vectors
  • Combining semantic and keyword search

Core Concepts

1. Distance Metrics

| Metric | Formula | Best For | | ------------------ | ------------------ | --------------------- | --- | -------------- | | Cosine | 1 - (A·B)/(‖A‖‖B‖) | Normalized embeddings | | Euclidean (L2) | √Σ(a-b)² | Raw embeddings | | Dot Product | A·B | Magnitude matters | | Manhattan (L1) | Σ | a-b | | Sparse vectors |

2. Index Types

┌─────────────────────────────────────────────────┐
│                 Index Types                      │
├─────────────┬───────────────┬───────────────────┤
│    Flat     │     HNSW      │    IVF+PQ         │
│ (Exact)     │ (Graph-based) │ (Quantized)       │
├─────────────┼───────────────┼───────────────────┤
│ O(n) search │ O(log n)      │ O(√n)             │
│ 100% recall │ ~95-99%       │ ~90-95%           │
│ Small data  │ Medium-Large  │ Very Large        │
└─────────────┴───────────────┴───────────────────┘

Templates and detailed worked examples

Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.

Best Practices

Do's

  • Use appropriate index - HNSW for most cases
  • Tune parameters - ef_search, nprobe for recall/speed
  • Implement hybrid search - Combine with keyword search
  • Monitor recall - Measure search quality
  • Pre-filter when possible - Reduce search space

Don'ts

  • Don't skip evaluation - Measure before optimizing
  • Don't over-index - Start with flat, scale up
  • Don't ignore latency - P99 matters for UX
  • Don't forget costs - Vector storage adds up

How to install Similarity Search Patterns

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit wshobson/agents/plugins/llm-application-dev/skills/similarity-search-patterns#main ~/.claude/skills/similarity-search-patterns

Codex

npx degit wshobson/agents/plugins/llm-application-dev/skills/similarity-search-patterns#main ~/.codex/skills/similarity-search-patterns

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the Similarity Search Patterns skill do?

Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.

+How do I install Similarity Search Patterns in Claude Code?

Copy the skill folder into ~/.claude/skills/similarity-search-patterns, for example with "npx degit wshobson/agents/plugins/llm-application-dev/skills/similarity-search-patterns#main ~/.claude/skills/similarity-search-patterns". Claude Code loads it automatically and uses it when a task matches.

+Does Similarity Search Patterns work with ChatGPT or Codex?

Yes. Similarity Search Patterns uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/similarity-search-patterns. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Similarity Search Patterns free?

Similarity Search Patterns is published on GitHub by wshobson under the MIT license, which allows free use.

Related devops & cloud skills

  1. Supabase

    Official

    Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron,…

    supabase/agent-skills★ 3.1k
  2. Senior Architect

    System architecture decisions with a written rationale: monolith vs microservices, database choice, scaling limits, ADRs, Mermaid diagrams.

    alirezarezvani/claude-skills★ 30k
  3. Vercel Deploy

    Official

    Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the…

    openai/skills★ 29k
  4. Slo Implementation

    Define and implement Service Level Indicators (SLIs) and Service Level Objectives (SLOs) with error budgets and alerting.

    wshobson/agents★ 43k
  5. Sql Optimization Patterns

    Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow…

    wshobson/agents★ 43k
  6. Terraform Module Library

    Build reusable Terraform modules for AWS, Azure, GCP, and OCI infrastructure following infrastructure-as-code best practices.

    wshobson/agents★ 43k
  7. Deploy To Vercel

    Official

    Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the…

    vercel-labs/agent-skills★ 34k
  8. Vercel Cli With Tokens

    Official

    Deploy and manage projects on Vercel using token-based authentication.

    vercel-labs/agent-skills★ 34k
  9. Vercel Optimize

    Official

    Use for Vercel cost and performance optimization on deployed projects, especially Next.js, SvelteKit, Nuxt, and limited Astro apps.

    vercel-labs/agent-skills★ 34k

See all devops & cloud skills →

More skills from wshobson

  1. Social Evidence Research

    Research public discussion on social platforms and keep every report claim tied to the source material that supports it.

    wshobson/agents★ 43k
  2. Social Publishing

    Schedule and publish social media posts across 13 platforms (X, LinkedIn, Instagram, Facebook Pages, TikTok, Discord, Telegram, YouTube,…

    wshobson/agents★ 43k

All skills by wshobson →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.