$npx -y skills add spencermarx/open-code-review --skill reasoningbank-intelligenceImplement adaptive learning with ReasoningBank for pattern recognition, strategy optimization, and continuous improvement. Use when building self-learning agents, optimizing workflows, or implementing meta-cognitive systems.
| 1 | # ReasoningBank Intelligence |
| 2 | |
| 3 | ## What This Skill Does |
| 4 | |
| 5 | Implements ReasoningBank's adaptive learning system for AI agents to learn from experience, recognize patterns, and optimize strategies over time. Enables meta-cognitive capabilities and continuous improvement. |
| 6 | |
| 7 | ## Prerequisites |
| 8 | |
| 9 | - agentic-flow v3.0.0-alpha.1+ |
| 10 | - AgentDB v3.0.0-alpha.10+ (for persistence) |
| 11 | - Node.js 18+ |
| 12 | |
| 13 | ## Quick Start |
| 14 | |
| 15 | ```typescript |
| 16 | import { ReasoningBank } from 'agentic-flow/reasoningbank'; |
| 17 | |
| 18 | // Initialize ReasoningBank |
| 19 | const rb = new ReasoningBank({ |
| 20 | persist: true, |
| 21 | learningRate: 0.1, |
| 22 | adapter: 'agentdb' // Use AgentDB for storage |
| 23 | }); |
| 24 | |
| 25 | // Record task outcome |
| 26 | await rb.recordExperience({ |
| 27 | task: 'code_review', |
| 28 | approach: 'static_analysis_first', |
| 29 | outcome: { |
| 30 | success: true, |
| 31 | metrics: { |
| 32 | bugs_found: 5, |
| 33 | time_taken: 120, |
| 34 | false_positives: 1 |
| 35 | } |
| 36 | }, |
| 37 | context: { |
| 38 | language: 'typescript', |
| 39 | complexity: 'medium' |
| 40 | } |
| 41 | }); |
| 42 | |
| 43 | // Get optimal strategy |
| 44 | const strategy = await rb.recommendStrategy('code_review', { |
| 45 | language: 'typescript', |
| 46 | complexity: 'high' |
| 47 | }); |
| 48 | ``` |
| 49 | |
| 50 | ## Core Features |
| 51 | |
| 52 | ### 1. Pattern Recognition |
| 53 | ```typescript |
| 54 | // Learn patterns from data |
| 55 | await rb.learnPattern({ |
| 56 | pattern: 'api_errors_increase_after_deploy', |
| 57 | triggers: ['deployment', 'traffic_spike'], |
| 58 | actions: ['rollback', 'scale_up'], |
| 59 | confidence: 0.85 |
| 60 | }); |
| 61 | |
| 62 | // Match patterns |
| 63 | const matches = await rb.matchPatterns(currentSituation); |
| 64 | ``` |
| 65 | |
| 66 | ### 2. Strategy Optimization |
| 67 | ```typescript |
| 68 | // Compare strategies |
| 69 | const comparison = await rb.compareStrategies('bug_fixing', [ |
| 70 | 'tdd_approach', |
| 71 | 'debug_first', |
| 72 | 'reproduce_then_fix' |
| 73 | ]); |
| 74 | |
| 75 | // Get best strategy |
| 76 | const best = comparison.strategies[0]; |
| 77 | console.log(`Best: ${best.name} (score: ${best.score})`); |
| 78 | ``` |
| 79 | |
| 80 | ### 3. Continuous Learning |
| 81 | ```typescript |
| 82 | // Enable auto-learning from all tasks |
| 83 | await rb.enableAutoLearning({ |
| 84 | threshold: 0.7, // Only learn from high-confidence outcomes |
| 85 | updateFrequency: 100 // Update models every 100 experiences |
| 86 | }); |
| 87 | ``` |
| 88 | |
| 89 | ## Advanced Usage |
| 90 | |
| 91 | ### Meta-Learning |
| 92 | ```typescript |
| 93 | // Learn about learning |
| 94 | await rb.metaLearn({ |
| 95 | observation: 'parallel_execution_faster_for_independent_tasks', |
| 96 | confidence: 0.95, |
| 97 | applicability: { |
| 98 | task_types: ['batch_processing', 'data_transformation'], |
| 99 | conditions: ['tasks_independent', 'io_bound'] |
| 100 | } |
| 101 | }); |
| 102 | ``` |
| 103 | |
| 104 | ### Transfer Learning |
| 105 | ```typescript |
| 106 | // Apply knowledge from one domain to another |
| 107 | await rb.transferKnowledge({ |
| 108 | from: 'code_review_javascript', |
| 109 | to: 'code_review_typescript', |
| 110 | similarity: 0.8 |
| 111 | }); |
| 112 | ``` |
| 113 | |
| 114 | ### Adaptive Agents |
| 115 | ```typescript |
| 116 | // Create self-improving agent |
| 117 | class AdaptiveAgent { |
| 118 | async execute(task: Task) { |
| 119 | // Get optimal strategy |
| 120 | const strategy = await rb.recommendStrategy(task.type, task.context); |
| 121 | |
| 122 | // Execute with strategy |
| 123 | const result = await this.executeWithStrategy(task, strategy); |
| 124 | |
| 125 | // Learn from outcome |
| 126 | await rb.recordExperience({ |
| 127 | task: task.type, |
| 128 | approach: strategy.name, |
| 129 | outcome: result, |
| 130 | context: task.context |
| 131 | }); |
| 132 | |
| 133 | return result; |
| 134 | } |
| 135 | } |
| 136 | ``` |
| 137 | |
| 138 | ## Integration with AgentDB |
| 139 | |
| 140 | ```typescript |
| 141 | // Persist ReasoningBank data |
| 142 | await rb.configure({ |
| 143 | storage: { |
| 144 | type: 'agentdb', |
| 145 | options: { |
| 146 | database: './reasoning-bank.db', |
| 147 | enableVectorSearch: true |
| 148 | } |
| 149 | } |
| 150 | }); |
| 151 | |
| 152 | // Query learned patterns |
| 153 | const patterns = await rb.query({ |
| 154 | category: 'optimization', |
| 155 | minConfidence: 0.8, |
| 156 | timeRange: { last: '30d' } |
| 157 | }); |
| 158 | ``` |
| 159 | |
| 160 | ## Performance Metrics |
| 161 | |
| 162 | ```typescript |
| 163 | // Track learning effectiveness |
| 164 | const metrics = await rb.getMetrics(); |
| 165 | console.log(` |
| 166 | Total Experiences: ${metrics.totalExperiences} |
| 167 | Patterns Learned: ${metrics.patternsLearned} |
| 168 | Strategy Success Rate: ${metrics.strategySuccessRate} |
| 169 | Improvement Over Time: ${metrics.improvement} |
| 170 | `); |
| 171 | ``` |
| 172 | |
| 173 | ## Best Practices |
| 174 | |
| 175 | 1. **Record consistently**: Log all task outcomes, not just successes |
| 176 | 2. **Provide context**: Rich context improves pattern matching |
| 177 | 3. **Set thresholds**: Filter low-confidence learnings |
| 178 | 4. **Review periodically**: Audit learned patterns for quality |
| 179 | 5. **Use vector search**: Enable semantic pattern matching |
| 180 | |
| 181 | ## Troubleshooting |
| 182 | |
| 183 | ### Issue: Poor recommendations |
| 184 | **Solution**: Ensure sufficient training data (100+ experiences per task type) |
| 185 | |
| 186 | ### Issue: Slow pattern matching |
| 187 | **Solution**: Enable vector indexing in AgentDB |
| 188 | |
| 189 | ### Issue: Memory growing large |
| 190 | **Solution**: Set TTL for old experiences or enable pruning |
| 191 | |
| 192 | ## Learn More |
| 193 | |
| 194 | - ReasoningBank Guide: agentic-flow/src/reasoningbank/README.md |
| 195 | - AgentDB Integration: packages/agentdb/docs/reasoningbank.md |
| 196 | - Pattern Learning: docs/reasoning/patterns.md |