/debug - Debugging Assistant Command for Claude Code
Advanced debugging assistant with root cause analysis, step-by-step troubleshooting, and automated fix suggestions
Open the source and read safety notes before installing.
Schema details
- Install type
- cli
- Reading time
- 3 min
- Difficulty score
- 100
- Troubleshooting
- Yes
- Breaking changes
- No
- Command syntax
- /debug
Full copyable content
/debugAbout this resource
The /debug command provides intelligent debugging assistance with root cause analysis, systematic troubleshooting, performance profiling, and automated fix generation for various programming languages and frameworks.\n\n## Usage\n\n\n/debug [options] <error_or_file>\n\n\n## Options\n\n### Debug Modes\n- --interactive - Step-by-step guided debugging\n- --automated - Automatic issue detection and fixes\n- --analysis - Deep code analysis without fixes\n- --performance - Performance bottleneck identification\n\n### Error Types\n- --runtime - Runtime errors and exceptions\n- --logic - Logic errors and unexpected behavior\n- --memory - Memory leaks and allocation issues\n- --network - Network and API related problems\n- --database - Database connection and query issues\n\n### Scope Options\n- --function - Debug specific function\n- --class - Debug entire class\n- --module - Debug module/file\n- --system - System-wide debugging\n\n### Output Formats\n- --format=detailed - Comprehensive analysis (default)\n- --format=quick - Quick diagnosis and fix\n- --format=checklist - Debugging checklist\n- --format=trace - Execution trace analysis\n\n## Examples\n\n### Runtime Error Debugging\n\njavascript\n// Problematic code with multiple issues\nconst UserManager = {\n users: [],\n \n async addUser(userData) {\n // 🐛 Bug 1: No input validation\n const user = {\n id: this.users.length + 1, // 🐛 Bug 2: Race condition possible\n name: userData.name,\n email: userData.email,\n createdAt: new Date()\n };\n \n // 🐛 Bug 3: Async operation without proper error handling\n const result = await fetch('/api/users', {\n method: 'POST',\n body: JSON.stringify(user) // 🐛 Bug 4: Missing Content-Type header\n });\n \n // 🐛 Bug 5: No response status check\n const savedUser = await result.json();\n \n this.users.push(savedUser);\n return savedUser;\n },\n \n findUserByEmail(email) {\n // 🐛 Bug 6: Case-sensitive search\n return this.users.find(user => user.email === email);\n },\n \n deleteUser(userId) {\n // 🐛 Bug 7: Modifying array while iterating\n for (let i = 0; i < this.users.length; i++) {\n if (this.users[i].id === userId) {\n this.users.splice(i, 1);\n break;\n }\n }\n }\n};\n\n// Error scenario\nUserManager.addUser({ name: \"John\" }) // Missing email\n .then(user => console.log('Added:', user))\n .catch(error => console.error('Error:', error)); // 🐛 Error not properly caught\n\n\nDebug Analysis Output:\n\nmarkdown\n# 🐛 Debug Analysis: UserManager\n\n## 🚨 Critical Issues Found (7)\n\n### Issue 1: Missing Input Validation\n**Location:** Line 5 - `addUser` method\n**Severity:** High\n**Type:** Runtime Error\n\n**Problem:**\njavascript\n// Current code (vulnerable)\nconst user = {\n id: this.users.length + 1,\n name: userData.name, // ❌ Could be undefined\n email: userData.email, // ❌ Could be undefined\n createdAt: new Date()\n};\n\n\n**Error Symptoms:**\n- `TypeError: Cannot read property 'name' of undefined`\n- Silent failures with incomplete data\n- Database constraint violations\n\n**Root Cause:**\nNo validation of input parameters allows undefined/null values to propagate through the system.\n\n**Fix:**\njavascript\nasync addUser(userData) {\n // Input validation\n if (!userData || typeof userData !== 'object') {\n throw new Error('Invalid user data: expected object');\n }\n \n const required = ['name', 'email'];\n const missing = required.filter(field => !userData[field]);\n \n if (missing.length > 0) {\n throw new Error(Missing required fields: ${missing.join(', ')});\n }\n \n // Email format validation\n const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;\n if (!emailRegex.test(userData.email)) {\n throw new Error('Invalid email format');\n }\n \n // Continue with validated data...\n}\n\n\n### Issue 2: Race Condition in ID Generation\n**Location:** Line 6\n**Severity:** High\n**Type:** Logic Error\n\n**Problem:**\njavascript\nid: this.users.length + 1, // ❌ Not thread-safe\n\n\n**Race Condition Scenario:**\n\nThread A: reads length = 5, calculates id = 6\nThread B: reads length = 5, calculates id = 6\nThread A: adds user with id = 6\nThread B: adds user with id = 6 (DUPLICATE!)\n\n\n**Fix Options:**\n\n**Option 1: UUID (Recommended)**\njavascript\nconst { v4: uuidv4 } = require('uuid');\n\nconst user = {\n id: uuidv4(), // ✅ Guaranteed unique\n name: userData.name,\n email: userData.email,\n createdAt: new Date()\n};\n\n\n**Option 2: Atomic Counter**\njavascript\nclass UserManager {\n constructor() {\n this.users = [];\n this.nextId = 1;\n }\n \n generateId() {\n return this.nextId++; // ✅ Atomic increment\n }\n}\n```\n\nThis debugging analysis demonstrates systematic problem identification, root cause analysis, and comprehensive solution implementation with prevention strategies.
Source citations
Signals
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.