Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement semantic vector search with AgentDB for intelligent document retrieval, similarity matching, and context-aware querying. Use when building RAG systems, semantic search engines, or intelligent knowledge bases.
.claude/skills/agentdb-vector-search/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-19 | ✗→✓ | ▲ Improved | — | — |
| case-18 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-06 | ✗→✓ | ▲ Improved | — | — |
| case-04 | ✗→✓ | ▲ Improved | — | — |
Implements vector-based semantic search using AgentDB's high-performance vector database with 150x-12,500x faster operations than traditional solutions. Features HNSW indexing, quantization, and sub-millisecond search (<100µs).
bash# Initialize with default dimensions (1536 for OpenAI ada-002) npx agentdb@latest init ./vectors.db # Custom dimensions for different embedding models npx agentdb@latest init ./vectors.db --dimension 768 # sentence-transformers npx agentdb@latest init ./vectors.db --dimension 384 # all-MiniLM-L6-v2 # Use preset configurations npx agentdb@latest init ./vectors.db --preset small # <10K vectors npx agentdb@latest init ./vectors.db --preset medium # 10K-100K vectors npx agentdb@latest init ./vectors.db --preset large # >100K vectors # In-memory database for testing npx agentdb@latest init ./vectors.db --in-memory
bash# Basic similarity search npx agentdb@latest query ./vectors.db "[0.1,0.2,0.3,...]" # Top-k results npx agentdb@latest query ./vectors.db "[0.1,0.2,0.3]" -k 10 # With similarity threshold (cosine similarity) npx agentdb@latest query ./vectors.db "0.1 0.2 0.3" -t 0.75 -m cosine # Different distance metrics npx agentdb@latest query ./vectors.db "[...]" -m euclidean # L2 distance npx agentdb@latest query ./vectors.db "[...]" -m dot # Dot product # JSON output for automation npx agentdb@latest query ./vectors.db "[...]" -f json -k 5 # Verbose output with distances npx agentdb@latest query ./vectors.db "[...]" -v
bash# Export vectors to JSON npx agentdb@latest export ./vectors.db ./backup.json # Import vectors from JSON npx agentdb@latest import ./backup.json # Get database statistics npx agentdb@latest stats ./vectors.db
typescriptimport { createAgentDBAdapter, computeEmbedding } from 'agentic-flow/reasoningbank'; // Initialize with vector search optimizations const adapter = await createAgentDBAdapter({ dbPath: '.agentdb/vectors.db', enableLearning: false, // Vector search only enableReasoning: true, // Enable semantic matching quantizationType: 'binary', // 32x memory reduction cacheSize: 1000, // Fast retrieval }); // Store document with embedding const text = "The quantum computer achieved 100 qubits"; const embedding = await computeEmbedding(text); await adapter.insertPattern({ id: '', type: 'document', domain: 'technology', pattern_data: JSON.stringify({ embedding, text, metadata: { category: "quantum", date: "2025-01-15" } }), confidence: 1.0, usage_count: 0, success_count: 0, created_at: Date.now(), last_used: Date.now(), }); // Semantic search with MMR (Maximal Marginal Relevance) const queryEmbedding = await computeEmbedding("quantum computing advances"); const results = await adapter.retrieveWithReasoning(queryEmbedding, { domain: 'technology', k: 10, useMMR: true, // Diverse results synthesizeContext: true, // Rich context });
typescript// Store with automatic embedding await db.storeWithEmbedding({ content: "Your document text", metadata: { source: "docs", page: 42 } });
typescript// Find similar documents const similar = await db.findSimilar("quantum computing", { limit: 5, minScore: 0.75 });
typescript// Combine vector similarity with metadata filtering const results = await db.hybridSearch({ query: "machine learning models", filters: { category: "research", date: { $gte: "2024-01-01" } }, limit: 20 });
typescript// Build RAG pipeline async function ragQuery(question: string) { // 1. Get relevant context const context = await db.searchSimilar( await embed(question), { limit: 5, threshold: 0.7 } ); // 2. Generate answer with context const prompt = `Context: ${context.map(c => c.text).join('\n')} Question: ${question}`; return await llm.generate(prompt); }
typescript// Efficient batch storage await db.batchStore(documents.map(doc => ({ text: doc.content, embedding: doc.vector, metadata: doc.meta })));
bash# Start AgentDB MCP server for Claude Code npx agentdb@latest mcp # Add to Claude Code (one-time setup) claude mcp add agentdb npx agentdb@latest mcp # Now use MCP tools in Claude Code: # - agentdb_query: Semantic vector search # - agentdb_store: Store documents with embeddings # - agentdb_stats: Database statistics
bash# Run comprehensive benchmarks npx agentdb@latest benchmark # Results: # ✅ Pattern Search: 150x faster (100µs vs 15ms) # ✅ Batch Insert: 500x faster (2ms vs 1s for 100 vectors) # ✅ Large-scale Query: 12,500x faster (8ms vs 100s at 1M vectors) # ✅ Memory Efficiency: 4-32x reduction with quantization
AgentDB provides multiple quantization strategies for memory efficiency:
typescriptconst adapter = await createAgentDBAdapter({ quantizationType: 'binary', // 768-dim → 96 bytes });
typescriptconst adapter = await createAgentDBAdapter({ quantizationType: 'scalar', // 768-dim → 768 bytes });
typescriptconst adapter = await createAgentDBAdapter({ quantizationType: 'product', // 768-dim → 48-96 bytes });
bash# Cosine similarity (default, best for most use cases) npx agentdb@latest query ./db.sqlite "[...]" -m cosine # Euclidean distance (L2 norm) npx agentdb@latest query ./db.sqlite "[...]" -m euclidean # Dot product (for normalized vectors) npx agentdb@latest query ./db.sqlite "[...]" -m dot
bash# Check if HNSW indexing is enabled (automatic) npx agentdb@latest stats ./vectors.db # Expected: <100µs search time
bash# Enable binary quantization (32x reduction) # Use in adapter: quantizationType: 'binary'
bash# Adjust similarity threshold npx agentdb@latest query ./db.sqlite "[...]" -t 0.8 # Higher threshold # Or use MMR for diverse results # Use in adapter: useMMR: true
bash# Check embedding model dimensions: # - OpenAI ada-002: 1536 # - sentence-transformers: 768 # - all-MiniLM-L6-v2: 384 npx agentdb@latest init ./db.sqlite --dimension 768
bash# Get comprehensive stats npx agentdb@latest stats ./vectors.db # Shows: # - Total patterns/vectors # - Database size # - Average confidence # - Domains distribution # - Index status
npx agentdb@latest mcp for Claude Codenpx agentdb@latest --helpnpx agentdb@latest help <command>| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-19 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +55 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.