$npx -y skills add Toowiredd/claude-skills-automation --skill error-debuggerAnalyzes errors, searches past solutions in memory, provides immediate fixes with code examples, and saves solutions for future reference. Use when user says "debug this", "fix this error", "why is this failing", or when error messages appear like TypeError, ECONNREFUSED, CORS, 4
| 1 | # Error Debugger |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Context-aware debugging that learns from past solutions. When an error occurs: |
| 6 | 1. Searches memory for similar past errors |
| 7 | 2. Analyzes error message and stack trace |
| 8 | 3. Provides immediate fix with code examples |
| 9 | 4. Creates regression test via testing-builder |
| 10 | 5. Saves solution to memory for future |
| 11 | |
| 12 | **For ADHD users**: Eliminates debugging frustration - instant, actionable fixes. |
| 13 | **For SDAM users**: Recalls past solutions you've already found. |
| 14 | **For all users**: Gets smarter over time as it learns from your codebase. |
| 15 | |
| 16 | ## Activation Triggers |
| 17 | |
| 18 | - User says: "debug this", "fix this error", "why is this failing" |
| 19 | - Error messages containing: TypeError, ReferenceError, SyntaxError, ECONNREFUSED, CORS, 404, 500, etc. |
| 20 | - Stack traces pasted into conversation |
| 21 | - "Something's broken" or similar expressions |
| 22 | |
| 23 | ## Core Workflow |
| 24 | |
| 25 | ### 1. Parse Error |
| 26 | |
| 27 | Extract key information: |
| 28 | |
| 29 | ```javascript |
| 30 | { |
| 31 | error_type: "TypeError|ReferenceError|ECONNREFUSED|...", |
| 32 | message: "Cannot read property 'map' of undefined", |
| 33 | stack_trace: [...], |
| 34 | file: "src/components/UserList.jsx", |
| 35 | line: 42, |
| 36 | context: "Rendering user list" |
| 37 | } |
| 38 | ``` |
| 39 | |
| 40 | ### 2. Search Past Solutions |
| 41 | |
| 42 | Query context-manager: |
| 43 | |
| 44 | ``` |
| 45 | search memories for: |
| 46 | - error_type match |
| 47 | - similar message (fuzzy match) |
| 48 | - same file/component if available |
| 49 | - related tags (if previously tagged) |
| 50 | ``` |
| 51 | |
| 52 | **If match found**: |
| 53 | ``` |
| 54 | 🔍 Found similar past error! |
| 55 | |
| 56 | 📝 3 months ago: TypeError in UserList component |
| 57 | ✅ Solution: Added null check before map |
| 58 | ⏱️ Fixed in: 5 minutes |
| 59 | 🔗 Memory: procedures/{uuid}.md |
| 60 | |
| 61 | Applying the same solution... |
| 62 | ``` |
| 63 | |
| 64 | **If no match**: |
| 65 | ``` |
| 66 | 🆕 New error - analyzing... |
| 67 | (Will save solution after fix) |
| 68 | ``` |
| 69 | |
| 70 | ### 3. Analyze Error |
| 71 | |
| 72 | See [reference.md](reference.md) for comprehensive error pattern library. |
| 73 | |
| 74 | **Quick common patterns**: |
| 75 | |
| 76 | - **TypeError: Cannot read property 'X' of undefined** → Optional chaining + defaults |
| 77 | - **ECONNREFUSED** → Check service running, verify ports |
| 78 | - **CORS errors** → Configure CORS headers |
| 79 | - **404 Not Found** → Verify route definition |
| 80 | - **500 Internal Server Error** → Check server logs |
| 81 | |
| 82 | ### 4. Provide Fix |
| 83 | |
| 84 | **Format**: |
| 85 | ``` |
| 86 | 🔧 Error Analysis |
| 87 | |
| 88 | **Type**: {error_type} |
| 89 | **Location**: {file}:{line} |
| 90 | **Cause**: {root_cause_explanation} |
| 91 | |
| 92 | **Fix**: |
| 93 | |
| 94 | ```javascript |
| 95 | // ❌ Current code |
| 96 | const users = data.users; |
| 97 | return users.map(user => <div>{user.name}</div>); |
| 98 | ``` |
| 99 | |
| 100 | ```javascript |
| 101 | // ✅ Fixed code |
| 102 | const users = data?.users || []; |
| 103 | return users.map(user => <div>{user.name}</div>); |
| 104 | ``` |
| 105 | |
| 106 | **Explanation**: Added optional chaining and default empty array to handle case where data or data.users is undefined. |
| 107 | |
| 108 | **Prevention**: Always validate API response structure before using. |
| 109 | |
| 110 | **Next steps**: |
| 111 | 1. Apply the fix |
| 112 | 2. Test manually |
| 113 | 3. I'll create a regression test |
| 114 | ``` |
| 115 | |
| 116 | ### 5. Save Solution |
| 117 | |
| 118 | After fix confirmed working: |
| 119 | |
| 120 | ```bash |
| 121 | # Save to context-manager as PROCEDURE |
| 122 | remember: Fix for TypeError in map operations |
| 123 | Type: PROCEDURE |
| 124 | Tags: error, typescript, array-operations |
| 125 | Content: When getting "Cannot read property 'map' of undefined", |
| 126 | add optional chaining and default empty array: |
| 127 | data?.users || [] |
| 128 | ``` |
| 129 | |
| 130 | **Memory structure**: |
| 131 | ```markdown |
| 132 | # PROCEDURE: Fix TypeError in map operations |
| 133 | |
| 134 | **Error Type**: TypeError |
| 135 | **Message Pattern**: Cannot read property 'map' of undefined |
| 136 | **Context**: Array operations on potentially undefined data |
| 137 | |
| 138 | ## Solution |
| 139 | |
| 140 | Use optional chaining and default values: |
| 141 | |
| 142 | ```javascript |
| 143 | // Before |
| 144 | const items = data.items; |
| 145 | return items.map(...) |
| 146 | |
| 147 | // After |
| 148 | const items = data?.items || []; |
| 149 | return items.map(...) |
| 150 | ``` |
| 151 | |
| 152 | ## When to Apply |
| 153 | |
| 154 | - API responses that might be undefined |
| 155 | - Props that might not be passed |
| 156 | - Array operations on uncertain data |
| 157 | |
| 158 | ## Tested |
| 159 | |
| 160 | ✅ Fixed in UserList component (2025-10-17) |
| 161 | ✅ Regression test: tests/components/UserList.test.jsx |
| 162 | |
| 163 | ## Tags |
| 164 | |
| 165 | error, typescript, array-operations, undefined-handling |
| 166 | ``` |
| 167 | |
| 168 | ### 6. Create Regression Test |
| 169 | |
| 170 | Automatically invoke testing-builder: |
| 171 | |
| 172 | ``` |
| 173 | create regression test for this fix: |
| 174 | - Test that component handles undefined data |
| 175 | - Test that component handles empty array |
| 176 | - Test that component works with valid data |
| 177 | ``` |
| 178 | |
| 179 | ## Tool Persistence Pattern (Meta-Learning) |
| 180 | |
| 181 | **Critical principle from self-analysis**: Never give up on first obstacle. Try 3 approaches before abandoning a solution path. |
| 182 | |
| 183 | ### Debugging Tools Hierarchy |
| 184 | |
| 185 | When debugging an error, try these tools in sequence: |
| 186 | |
| 187 | **1. Search Past Solutions (context-manager)** |
| 188 | ```bash |
| 189 | # First approach: Check memory |
| 190 | search memories for error pattern |
| 191 | ``` |
| 192 | |
| 193 | If no past solution found → Continue to next approach |
| 194 | |
| 195 | **2. GitHub Copilot CLI Search** |
| 196 | ```bash |
| 197 | # Second approach: Search public issues |
| 198 | copilot "Search GitHub for solutions to: $ERROR_MESSAGE" |
| 199 | ``` |
| 200 | |
| 201 | If Copi |