Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement ReasoningBank adaptive learning with AgentDB's 150x faster vector database. Includes trajectory tracking, verdict judgment, memory distillation, and pattern recognition. Use when building self-learning agents, optimizing decision-making, or implementing experience replay systems.
.claude/skills/ruvnet-reasoningbank-with-agentdb/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 149% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 135% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 56% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 142% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 74% | 0% |
Provides ReasoningBank adaptive learning patterns using AgentDB's high-performance backend (150x-12,500x faster). Enables agents to learn from experiences, judge outcomes, distill memories, and improve decision-making over time with 100% backward compatibility.
Performance: 150x faster pattern retrieval, 500x faster batch operations, <1ms memory access.
bash# Initialize AgentDB for ReasoningBank npx agentdb@latest init ./.agentdb$reasoningbank.db --dimension 1536 # Start MCP server for Claude Code integration npx agentdb@latest mcp claude mcp add agentdb npx agentdb@latest mcp
bash# Automatic migration with validation npx agentdb@latest migrate --source .swarm$memory.db # Verify migration npx agentdb@latest stats ./.agentdb$reasoningbank.db
typescriptimport { createAgentDBAdapter, computeEmbedding } from 'agentic-flow$reasoningbank'; // Initialize ReasoningBank with AgentDB const rb = await createAgentDBAdapter({ dbPath: '.agentdb$reasoningbank.db', enableLearning: true, // Enable learning plugins enableReasoning: true, // Enable reasoning agents cacheSize: 1000, // 1000 pattern cache }); // Store successful experience const query = "How to optimize database queries?"; const embedding = await computeEmbedding(query); await rb.insertPattern({ id: '', type: 'experience', domain: 'database-optimization', pattern_data: JSON.stringify({ embedding, pattern: { query, approach: 'indexing + query optimization', outcome: 'success', metrics: { latency_reduction: 0.85 } } }), confidence: 0.95, usage_count: 1, success_count: 1, created_at: Date.now(), last_used: Date.now(), }); // Retrieve similar experiences with reasoning const result = await rb.retrieveWithReasoning(embedding, { domain: 'database-optimization', k: 5, useMMR: true, // Diverse results synthesizeContext: true, // Rich context synthesis }); console.log('Memories:', result.memories); console.log('Context:', result.context); console.log('Patterns:', result.patterns);
Track agent execution paths and outcomes:
typescript// Record trajectory (sequence of actions) const trajectory = { task: 'optimize-api-endpoint', steps: [ { action: 'analyze-bottleneck', result: 'found N+1 query' }, { action: 'add-eager-loading', result: 'reduced queries' }, { action: 'add-caching', result: 'improved latency' } ], outcome: 'success', metrics: { latency_before: 2500, latency_after: 150 } }; const embedding = await computeEmbedding(JSON.stringify(trajectory)); await rb.insertPattern({ id: '', type: 'trajectory', domain: 'api-optimization', pattern_data: JSON.stringify({ embedding, pattern: trajectory }), confidence: 0.9, usage_count: 1, success_count: 1, created_at: Date.now(), last_used: Date.now(), });
Judge whether a trajectory was successful:
typescript// Retrieve similar past trajectories const similar = await rb.retrieveWithReasoning(queryEmbedding, { domain: 'api-optimization', k: 10, }); // Judge based on similarity to successful patterns const verdict = similar.memories.filter(m => m.pattern.outcome === 'success' && m.similarity > 0.8 ).length > 5 ? 'likely_success' : 'needs_review'; console.log('Verdict:', verdict); console.log('Confidence:', similar.memories[0]?.similarity || 0);
Consolidate similar experiences into patterns:
typescript// Get all experiences in domain const experiences = await rb.retrieveWithReasoning(embedding, { domain: 'api-optimization', k: 100, optimizeMemory: true, // Automatic consolidation }); // Distill into high-level pattern const distilledPattern = { domain: 'api-optimization', pattern: 'For N+1 queries: add eager loading, then cache', success_rate: 0.92, sample_size: experiences.memories.length, confidence: 0.95 }; await rb.insertPattern({ id: '', type: 'distilled-pattern', domain: 'api-optimization', pattern_data: JSON.stringify({ embedding: await computeEmbedding(JSON.stringify(distilledPattern)), pattern: distilledPattern }), confidence: 0.95, usage_count: 0, success_count: 0, created_at: Date.now(), last_used: Date.now(), });
AgentDB provides 4 reasoning modules that enhance ReasoningBank:
Find similar successful patterns:
typescriptconst result = await rb.retrieveWithReasoning(queryEmbedding, { domain: 'problem-solving', k: 10, useMMR: true, // Maximal Marginal Relevance for diversity }); // PatternMatcher returns diverse, relevant memories result.memories.forEach(mem => { console.log(`Pattern: ${mem.pattern.approach}`); console.log(`Similarity: ${mem.similarity}`); console.log(`Success Rate: ${mem.success_count / mem.usage_count}`); });
Generate rich context from multiple memories:
typescriptconst result = await rb.retrieveWithReasoning(queryEmbedding, { domain: 'code-optimization', synthesizeContext: true, // Enable context synthesis k: 5, }); // ContextSynthesizer creates coherent narrative console.log('Synthesized Context:', result.context); // "Based on 5 similar optimizations, the most effective approach // involves profiling, identifying bottlenecks, and applying targeted // improvements. Success rate: 87%"
Automatically consolidate and prune:
typescriptconst result = await rb.retrieveWithReasoning(queryEmbedding, { domain: 'testing', optimizeMemory: true, // Enable automatic optimization }); // MemoryOptimizer consolidates similar patterns and prunes low-quality console.log('Optimizations:', result.optimizations); // { consolidated: 15, pruned: 3, improved_quality: 0.12 }
Filter by quality and relevance:
typescriptconst result = await rb.retrieveWithReasoning(queryEmbedding, { domain: 'debugging', k: 20, minConfidence: 0.8, // Only high-confidence experiences }); // ExperienceCurator returns only quality experiences result.memories.forEach(mem => { console.log(`Confidence: ${mem.confidence}`); console.log(`Success Rate: ${mem.success_count / mem.usage_count}`); });
AgentDB maintains 100% backward compatibility with legacy ReasoningBank:
typescriptimport { retrieveMemories, judgeTrajectory, distillMemories } from 'agentic-flow$reasoningbank'; // Legacy API works unchanged (uses AgentDB backend automatically) const memories = await retrieveMemories(query, { domain: 'code-generation', agent: 'coder' }); const verdict = await judgeTrajectory(trajectory, query); const newMemories = await distillMemories( trajectory, verdict, query, { domain: 'code-generation' } );
Organize memories by abstraction level:
typescript// Low-level: Specific implementation await rb.insertPattern({ type: 'concrete', domain: 'debugging$null-pointer', pattern_data: JSON.stringify({ embedding, pattern: { bug: 'NPE in UserService.getUser()', fix: 'Add null check' } }), confidence: 0.9, // ... }); // Mid-level: Pattern across similar cases await rb.insertPattern({ type: 'pattern', domain: 'debugging', pattern_data: JSON.stringify({ embedding, pattern: { category: 'null-pointer', approach: 'defensive-checks' } }), confidence: 0.85, // ... }); // High-level: General principle await rb.insertPattern({ type: 'principle', domain: 'software-engineering', pattern_data: JSON.stringify({ embedding, pattern: { principle: 'fail-fast with clear errors' } }), confidence: 0.95, // ... });
Transfer learning across domains:
typescript// Learn from backend optimization const backendExperience = await rb.retrieveWithReasoning(embedding, { domain: 'backend-optimization', k: 10, }); // Apply to frontend optimization const transferredKnowledge = backendExperience.memories.map(mem => ({ ...mem, domain: 'frontend-optimization', adapted: true, }));
bash# Export trajectories and patterns npx agentdb@latest export ./.agentdb$reasoningbank.db .$backup.json # Import experiences npx agentdb@latest import .$experiences.json # Get statistics npx agentdb@latest stats ./.agentdb$reasoningbank.db # Shows: total patterns, domains, confidence distribution
bash# Migrate from legacy ReasoningBank npx agentdb@latest migrate --source .swarm$memory.db --target .agentdb$reasoningbank.db # Validate migration npx agentdb@latest stats .agentdb$reasoningbank.db
bash# Check source database exists ls -la .swarm$memory.db # Run with verbose logging DEBUG=agentdb:* npx agentdb@latest migrate --source .swarm$memory.db
typescript// Enable context synthesis for better quality const result = await rb.retrieveWithReasoning(embedding, { synthesizeContext: true, useMMR: true, k: 10, });
typescript// Enable automatic optimization const result = await rb.retrieveWithReasoning(embedding, { optimizeMemory: true, // Consolidates similar patterns }); // Or manually optimize await rb.optimize();
npx agentdb@latest mcpCategory: Machine Learning / Reinforcement Learning Difficulty: Intermediate Estimated Time: 20-30 minutes
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 8,298 | 4,804 | -42% | 1 | 1 | 0% | 1,644 | 4,093 | +149% | 0 | 0 | — |
case-16 | fail→pass | 10,003 | 6,628 | -34% | 1 | 1 | 0% | 1,933 | 4,546 | +135% | 0 | 0 | — |
case-02 | fail→fail | 18,974 | 8,643 | -54% | 1 | 1 | 0% | 4,292 | 4,834 | +13% | 0 | 0 | — |
case-03 | pass→pass | 8,918 | 8,506 | -5% | 1 | 1 | 0% | 1,858 | 4,770 | +157% | 0 | 0 | — |
case-04 | pass→pass | 8,596 | 2,949 | -66% | 1 | 1 | 0% | 1,939 | 3,578 | +85% | 0 | 0 | — |
case-05 | fail→pass | 19,713 | 2,627 | -87% | 1 | 1 | 0% | 2,252 | 3,503 | +56% | 0 | 0 | — |
case-06 | pass→fail | 7,184 | 2,178 | -70% | 1 | 1 | 0% | 1,554 | 3,447 | +122% | 0 | 0 | — |
case-07 | pass→pass | 6,199 | 2,052 | -67% | 1 | 1 | 0% | 1,212 | 3,305 | +173% | 0 | 0 | — |
case-08 | fail→pass | 7,008 | 2,354 | -66% | 1 | 1 | 0% | 1,411 | 3,412 | +142% | 0 | 0 | — |
case-09 | pass→pass | 6,891 | 3,133 | -55% | 1 | 1 | 0% | 1,388 | 3,408 | +146% | 0 | 0 | — |
case-10 | fail→pass | 11,333 | 5,347 | -53% | 1 | 1 | 0% | 2,431 | 4,236 | +74% | 0 | 0 | — |
case-11 | fail→pass | 8,336 | 3,053 | -63% | 1 | 1 | 0% | 1,855 | 3,795 | +105% | 0 | 0 | — |
case-12 | pass→pass | 9,441 | 9,599 | +2% | 1 | 1 | 0% | 1,969 | 4,730 | +140% | 0 | 0 | — |
case-13 | fail→pass | 14,608 | 7,756 | -47% | 1 | 1 | 0% | 2,944 | 4,599 | +56% | 0 | 0 | — |
case-14 | fail→pass | 10,577 | 1,870 | -82% | 1 | 1 | 0% | 2,053 | 3,365 | +64% | 0 | 0 | — |
case-15 | fail→pass | 6,393 | 1,984 | -69% | 1 | 1 | 0% | 1,298 | 3,303 | +154% | 0 | 0 | — |
case-17 | fail→pass | 11,435 | 3,140 | -73% | 1 | 1 | 0% | 2,171 | 3,604 | +66% | 0 | 0 | — |
case-18 | pass→pass | 4,334 | 1,782 | -59% | 1 | 1 | 0% | 869 | 3,279 | +277% | 0 | 0 | — |
case-19 | pass→pass | 5,934 | 3,541 | -40% | 1 | 1 | 0% | 1,187 | 3,544 | +199% | 0 | 0 | — |
case-20 | pass→pass | 13,722 | 9,732 | -29% | 1 | 1 | 0% | 2,375 | 4,858 | +105% | 0 | 0 | — |
case-21 | pass→pass | 12,491 | 7,763 | -38% | 1 | 1 | 0% | 2,206 | 4,346 | +97% | 0 | 0 | — |
case-22 | fail→fail | 13,083 | 7,239 | -45% | 1 | 1 | 0% | 2,554 | 4,331 | +70% | 0 | 0 | — |
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 +41 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.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.