AgentDB Vector Search
Skill224 starsChanged 10 months agoMITView on GitHub
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.
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 271
Similarity threshold: Start at 0.7 for quality, adjust based on use case
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AgentDB Vector Search
What This Skill Does
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).
Prerequisites
- Node.js 18+
- AgentDB v1.0.7+ (via agentic-flow or standalone)
- OpenAI API key (for embeddings) or custom embedding model
Quick Start with CLI
Initialize Vector Database
# 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-memoryQuery Vector Database
# 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 "[...]" -vImport/Export Vectors
# 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.dbQuick Start with API
import { 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
});Core Features
1. Vector Storage
// Store with automatic embedding
await db.storeWithEmbedding({
content: "Your document text",
metadata: { source: "docs", page: 42 }
});2. Similarity Search
// Find similar documents
const similar = await db.findSimilar("quantum computing", {
limit: 5,
minScore: 0.75
});3. Hybrid Search (Vector + Metadata)
// 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
});Advanced Usage
RAG (Retrieval Augmented Generation)
// 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);
}Batch Operations
// Efficient batch storage
await db.batchStore(documents.map(doc => ({
text: doc.content,
embedding: doc.vector,
metadata: doc.meta
})));MCP Server Integration
# 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 statisticsPerformance Benchmarks
# 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 quantizationQuantization Options
AgentDB provides multiple quantization strategies for memory efficiency:
Binary Quantization (32x reduction)
const adapter = await createAgentDBAdapter({
quantizationType: 'binary', // 768-dim → 96 bytes
});Scalar Quantization (4x reduction)
const adapter = await createAgentDBAdapter({
quantizationType: 'scalar', // 768-dim → 768 bytes
});Product Quantization (8-16x reduction)
const adapter = await createAgentDBAdapter({
quantizationType: 'product', // 768-dim → 48-96 bytes
});Distance Metrics
# 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 dotAdvanced Features
HNSW Indexing
- O(log n) search complexity
- Sub-millisecond retrieval (<100µs)
- Automatic index building
Caching
- 1000 pattern in-memory cache
- <1ms pattern retrieval
- Automatic cache invalidation
MMR (Maximal Marginal Relevance)
- Diverse result sets
- Avoid redundancy
- Balance relevance and diversity
Performance Tips
- Enable HNSW indexing: Automatic with AgentDB, 10-100x faster
- Use quantization: Binary (32x), Scalar (4x), Product (8-16x) memory reduction
- Batch operations: 500x faster for bulk inserts
- Match dimensions: 1536 (OpenAI), 768 (sentence-transformers), 384 (MiniLM)
- Similarity threshold: Start at 0.7 for quality, adjust based on use case
- Enable caching: 1000 pattern cache for frequent queries
Troubleshooting
Issue: Slow search performance
# Check if HNSW indexing is enabled (automatic)
npx agentdb@latest stats ./vectors.db
# Expected: <100µs search timeIssue: High memory usage
# Enable binary quantization (32x reduction)
# Use in adapter: quantizationType: 'binary'Issue: Poor relevance
# Adjust similarity threshold
npx agentdb@latest query ./db.sqlite "[...]" -t 0.8 # Higher threshold
# Or use MMR for diverse results
# Use in adapter: useMMR: trueIssue: Wrong dimensions
# Check embedding model dimensions:
# - OpenAI ada-002: 1536
# - sentence-transformers: 768
# - all-MiniLM-L6-v2: 384
npx agentdb@latest init ./db.sqlite --dimension 768Database Statistics
# Get comprehensive stats
npx agentdb@latest stats ./vectors.db
# Shows:
# - Total patterns/vectors
# - Database size
# - Average confidence
# - Domains distribution
# - Index statusPerformance Characteristics
- Vector Search: <100µs (HNSW indexing)
- Pattern Retrieval: <1ms (with cache)
- Batch Insert: 2ms for 100 vectors
- Memory Efficiency: 4-32x reduction with quantization
- Scalability: Handles 1M+ vectors efficiently
- Latency: Sub-millisecond for most operations
Learn More
- GitHub: https://github.com/ruvnet/agentic-flow/tree/main/packages/agentdb
- Documentation: node_modules/agentic-flow/docs/AGENTDB_INTEGRATION.md
- MCP Integration:
npx agentdb@latest mcpfor Claude Code - Website: https://agentdb.ruv.io
- CLI Help:
npx agentdb@latest --help - Command Help:
npx agentdb@latest help <command>
Other versions33 projects use a version of this.
Word for word · 31
- ruvnet/wifi-densepose★ 99k100% same
- ruvnet/RuView★ 99k100% same
- ruvnet/ruflo★ 79k100% same
- ruvnet/claude-flow★ 76k100% same
- ruvnet/ruvector★ 4.7k100% same
- ruvnet/RuVector★ 4.6k100% same
- ruvnet/agentic-flow★ 819100% same
- proffesor-for-testing/agentic-qe★ 515100% same
- ruvnet/ruv-FANN★ 385100% same
- spencermarx/open-code-review★ 357100% same
21 more not listed
Edited · 2
- Zekiog/ruflo★ 2100% same
- jpoindexter/theft-kit★ 1100% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use agent-code-review-swarm, agent-test-long-runner and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
ZekiogSkillagent-code-review-swarm
Agent skill for code-review-swarm - invoke with $agent-code-review-swarm
Also in 6 projects that use this
ZekiogSkillagent-test-long-runner
Agent skill for test-long-runner - invoke with $agent-test-long-runner
Also in 6 projects that use this
ruvnetSkillV3 DDD Architecture
Domain-Driven Design architecture for claude-flow v3. Implements modular, bounded context architecture with clean separation of concerns and microkernel pattern.
Also in 26 projects that use this
ruvnetSkillV3 Memory Unification
Unify 6+ memory systems into AgentDB with HNSW indexing for 150x-12,500x search improvements. Implements ADR-006 (Unified Memory Service) and ADR-009 (Hybrid Memory Backend).
Also in 26 projects that use this
- +5 more from Zekiog
- +3 more from ruvnet
In this repository27 other files it gives its agents.
- .claude/commands/monitoring/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- AgentDB Advanced FeaturesSkill
- AgentDB Learning PluginsSkill
- AgentDB Memory PatternsSkill
- AgentDB Performance OptimizationSkill
- agentic-jujutsuSkill
- flow-nexus-neuralSkill
- flow-nexus-platformSkill
- flow-nexus-swarmSkill
- github-code-reviewSkill
- github-multi-repoSkill
- github-project-managementSkill
- github-release-managementSkill
- github-workflow-automationSkill
- hive-mind-advancedSkill
- Hooks AutomationSkill
- Pair ProgrammingSkill
- performance-analysisSkill
- ReasoningBank with AgentDBSkill
- ReasoningBank IntelligenceSkill
- Skill BuilderSkill
- sparc-methodologySkill
- stream-chainSkill
- swarm-advancedSkill
- Swarm OrchestrationSkill
- Verification & Quality AssuranceSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

