vibe_learn
Identify and categorize recurring errors with solutions to prevent repeated mistakes. Utilizes pattern recognition to enhance learning and streamline decision-making processes.
Instructions
Pattern recognition system that tracks common errors and solutions to prevent recurring issues
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (standard categories: Complex Solution Bias, Feature Creep, Premature Implementation, Misalignment, Overtooling, Preference, Success, Other) | |
| mistake | Yes | One-sentence description of the learning entry | |
| sessionId | No | Optional session ID for state management | |
| solution | No | How it was corrected (if applicable) | |
| type | No | Type of learning entry |
Input Schema (JSON Schema)
{
"properties": {
"category": {
"description": "Category (standard categories: Complex Solution Bias, Feature Creep, Premature Implementation, Misalignment, Overtooling, Preference, Success, Other)",
"enum": [
"Complex Solution Bias",
"Feature Creep",
"Premature Implementation",
"Misalignment",
"Overtooling",
"Preference",
"Success",
"Other"
],
"type": "string"
},
"mistake": {
"description": "One-sentence description of the learning entry",
"type": "string"
},
"sessionId": {
"description": "Optional session ID for state management",
"type": "string"
},
"solution": {
"description": "How it was corrected (if applicable)",
"type": "string"
},
"type": {
"description": "Type of learning entry",
"enum": [
"mistake",
"preference",
"success"
],
"type": "string"
}
},
"required": [
"mistake",
"category"
],
"type": "object"
}
Implementation Reference
- src/tools/vibeLearn.ts:33-89 (handler)Primary handler function executing the core logic of the vibe_learn tool: validates input, enforces single-sentence format, checks for duplicates, stores learning entry, and returns category summary.export async function vibeLearnTool(input: VibeLearnInput): Promise<VibeLearnOutput> { try { // Validate input if (!input.mistake) { throw new Error('Mistake description is required'); } if (!input.category) { throw new Error('Mistake category is required'); } const entryType: LearningType = input.type ?? 'mistake'; if (entryType !== 'preference' && !input.solution) { throw new Error('Solution is required for this entry type'); } // Enforce single-sentence constraints const mistake = enforceOneSentence(input.mistake); const solution = input.solution ? enforceOneSentence(input.solution) : undefined; // Normalize category to one of our standard categories if possible const category = normalizeCategory(input.category); // Check for similar mistake const existing = getLearningEntries()[category] || []; const alreadyKnown = existing.some(e => isSimilar(e.mistake, mistake)); // Add mistake to log if new let entry: LearningEntry | undefined; if (!alreadyKnown) { entry = addLearningEntry(mistake, category, solution, entryType); } // Get category summaries const categorySummary = getLearningCategorySummary(); // Find current tally for this category const categoryData = categorySummary.find(m => m.category === category); const currentTally = categoryData?.count || 1; // Get top 3 categories const topCategories = categorySummary.slice(0, 3); return { added: !alreadyKnown, alreadyKnown, currentTally, topCategories }; } catch (error) { console.error('Error in vibe_learn tool:', error); return { added: false, alreadyKnown: false, currentTally: 0, topCategories: [] }; } }
- src/tools/vibeLearn.ts:10-27 (schema)TypeScript interfaces defining input and output schemas for the vibe_learn tool.export interface VibeLearnInput { mistake: string; category: string; solution?: string; type?: LearningType; sessionId?: string; } export interface VibeLearnOutput { added: boolean; currentTally: number; alreadyKnown?: boolean; topCategories: Array<{ category: string; count: number; recentExample: LearningEntry; }>; }
- src/index.ts:131-167 (registration)Tool registration in the MCP listTools handler, including name, description, and JSON schema for input validation.name: 'vibe_learn', description: 'Pattern recognition system that tracks common errors and solutions to prevent recurring issues', inputSchema: { type: 'object', properties: { mistake: { type: 'string', description: 'One-sentence description of the learning entry', examples: ['Skipped writing tests'] }, category: { type: 'string', description: `Category (standard categories: ${STANDARD_CATEGORIES.join(', ')})`, enum: STANDARD_CATEGORIES, examples: ['Premature Implementation'] }, solution: { type: 'string', description: 'How it was corrected (if applicable)', examples: ['Added regression tests'] }, type: { type: 'string', enum: ['mistake', 'preference', 'success'], description: 'Type of learning entry', examples: ['mistake'] }, sessionId: { type: 'string', description: 'Optional session ID for state management', examples: ['session-123'] } }, required: ['mistake', 'category'], additionalProperties: false } },
- src/index.ts:243-265 (handler)MCP protocol handler for callTool requests to 'vibe_learn': parses arguments, validates, calls vibeLearnTool, formats output.case 'vibe_learn': { const missing: string[] = []; if (!args || typeof args.mistake !== 'string') missing.push('mistake'); if (!args || typeof args.category !== 'string') missing.push('category'); if (missing.length) { const example = '{"mistake":"Skipped tests","category":"Feature Creep"}'; const message = IS_DISCOVERY ? `discovery: missing [${missing.join(', ')}]; example: ${example}` : `Missing: ${missing.join(', ')}. Example: ${example}`; throw new McpError(ErrorCode.InvalidParams, message); } const input: VibeLearnInput = { mistake: args.mistake, category: args.category, solution: typeof args.solution === 'string' ? args.solution : undefined, type: ['mistake', 'preference', 'success'].includes(args.type as string) ? (args.type as LearningType) : undefined, sessionId: typeof args.sessionId === 'string' ? args.sessionId : undefined }; const result = await vibeLearnTool(input); return { content: [{ type: 'text', text: formatVibeLearnOutput(result) }] }; }
- src/tools/vibeLearn.ts:89-94 (helper)Supporting helper functions used by the handler: enforceOneSentence for input normalization, isSimilar for duplicate detection, normalizeCategory for standardization.} /** * Ensure text is a single sentence */ function enforceOneSentence(text: string): string {