Parses error messages, traces execution flow through stack traces, correlates log entries to identify failure points, and applies systematic hypothesis-driven methodology to isolate and resolve bugs. Use when investigating errors, analyzing stack traces, finding root causes of unexpected behavior, troubleshooting crashes, or performing log analysis, error investigation, or root cause analysis.
git clone https://github.com/Jeffallan/claude-skills.git--- name: debugging-wizard description: Parses error messages, traces execution flow through stack traces, correlates log entries to identify failure points, and applies systematic hypothesis-driven methodology to isolate and resolve bugs. Use when investigating errors, analyzing stack traces, finding root causes of unexpected behavior, troubleshooting crashes, or performing log analysis, error investigation, or root cause analysis. license: MIT metadata: author: https://github.com/Jeffallan version: "1.1.0" domain: quality triggers: debug, error, bug, exception, traceback, stack trace, troubleshoot, not working, crash, fix issue role: specialist scope: analysis output-format: analysis related-skills: test-master, fullstack-guardian, monitoring-expert --- # Debugging Wizard Expert debugger applying systematic methodology to isolate and resolve issues in any codebase. ## Core Workflow 1. **Reproduce** - Establish consistent reproduction steps 2. **Isolate** - Narrow down to smallest failing case 3. **Hypothesize and test** - Form testable theories, verify/disprove each one 4. **Fix** - Implement and verify solution 5. **Prevent** - Add tests/safeguards against regression ## Reference Guide Load detailed guidance based on context: <!-- Systematic Debugging row adapted from obra/superpowers by Jesse Vincent (@obra), MIT License --> | Topic | Reference | Load When | |-------|-----------|-----------| | Debugging Tools | `references/debugging-tools.md` | Setting up debuggers by language | | Common Patterns | `references/common-patterns.md` | Recognizing bug patterns | | Strategies | `references/strategies.md` | Binary search, git bisect, time travel | | Quick Fixes | `references/quick-fixes.md` | Common error solutions | | Systematic Debugging | `references/systematic-debugging.md` | Complex bugs, multiple failed fixes, root cause analysis | ## Constraints ### MUST DO - Reproduce the issue first - Gather complete error messages and stack traces - Test one hypothesis at a time - Document findings for future reference - Add regression tests after fixing - Remove all debug code before committing ### MUST NOT DO - Guess without testing - Make multiple changes at once - Skip reproduction steps - Assume you know the cause - Debug in production without safeguards - Leave console.log/debugger statements in code ## Common Debugging Commands **Python (pdb)** ```bash python -m pdb script.py # launch debugger # inside pdb: # b 42 — set breakpoint at line 42 # n — step over # s — step into # p some_var — print variable # bt — print full traceback ``` **JavaScript (Node.js)** ```bash node --inspect-brk script.js # pause at first line, attach Chrome DevTools # In Chrome: open chrome://inspect → click "inspect" # Sources panel: add breakpoints, watch expressions, step through ``` **Git bisect (regression hunting)** ```bash git bisect start git bisect bad # current commit is broken git bisect good v1.2.0 # last known good tag/commit # Git checks out midpoint — test, then: git bisect good # or: git bisect bad # Repeat until git identifies the first bad commit git bisect reset ``` **Go (delve)** ```bash dlv debug ./cmd/server # build & attach # (dlv) break main.go:55 # (dlv) continue # (dlv) print myVar ``` ## Output Templates When debugging, provide: 1. **Root Cause**: What specifically caused the issue 2. **Evidence**: Stack trace, logs, or test that proves it 3. **Fix**: Code change that resolves it 4. **Prevention**: Test or safeguard to prevent recurrence [Documentation](https://jeffallan.github.io/claude-skills/skills/quality/debugging-wizard/)
1. **Gather Inputs**: Collect the error message, stack trace, and relevant log snippets. Tools like IDE debuggers (e.g., IntelliJ, VS Code), log aggregators (e.g., ELK Stack, Splunk), or error tracking tools (e.g., Sentry, Datadog) can help extract this data. 2. **Paste the Prompt**: Copy the prompt template and replace the placeholders with your specific error details. Ensure the stack trace and logs are complete to avoid missing critical context. 3. **Analyze the Output**: Review the AI’s summary, execution flow, and log correlation. Verify the hypotheses by checking the suggested next steps (e.g., database queries, code changes). 4. **Iterate**: If the root cause isn’t clear, provide additional logs or context (e.g., environment variables, recent code changes) and ask the AI to refine its analysis. 5. **Implement Fixes**: Use the proposed solutions to resolve the issue. Test the changes in a staging environment before deploying to production. Tip: For complex issues, break the problem into smaller chunks (e.g., isolate the failing component) and debug each part separately. Use the AI’s output as a starting point, but validate its findings with manual checks.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/Jeffallan/claude-skills/tree/main/skills/debugging-wizardCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Debug this error for me: [ERROR_MESSAGE]. Here’s the stack trace: [STACK_TRACE]. I’ve also included relevant log snippets: [LOG_SNIPPETS]. Follow a systematic approach to identify the root cause. Start by summarizing the error, then trace the execution flow, correlate log entries, and propose hypotheses for the failure. Finally, suggest specific next steps to resolve the issue, including code changes or additional diagnostics needed.
### Error Summary
The application crashed with a `NullPointerException` in the `UserService.updateUserProfile()` method when attempting to save changes to a user profile. The error occurred at line 42 in `UserService.java`, where the code tried to access a field on a `user` object that was unexpectedly `null`. This suggests a data integrity issue or an uninitialized object being passed to the method.
### Execution Flow Analysis
1. The error originated in `UserService.updateUserProfile()`, which was called from the `ProfileController.updateProfile()` endpoint.
2. The stack trace shows the call chain: `ProfileController.updateProfile()` → `UserService.updateUserProfile()` → `UserRepository.save()`.
3. The `save()` method in `UserRepository` triggered the exception when it tried to persist the `user` object.
### Log Correlation
- **Log Entry 1 (UserService.java:42)**: `WARN: Attempting to update profile for user ID 12345, but user object is null.`
- **Log Entry 2 (ProfileController.java:15)**: `INFO: Received update request for user ID 12345 with payload: {name: "John Doe", email: "[email protected]"}`.
- **Log Entry 3 (UserRepository.java:89)**: `ERROR: NullPointerException in save() method for user ID 12345.`
The logs reveal a mismatch: the controller received a valid request payload, but the `UserService` somehow received a `null` user object. This indicates a failure in the service layer to properly initialize or retrieve the user before processing the update.
### Root Cause Hypotheses
1. **Database Query Failure**: The `UserRepository.findById()` call might have returned `null` due to a missing or corrupted record in the database.
2. **Race Condition**: A concurrent process (e.g., user deletion) might have removed the user record between the time the request was received and the update was processed.
3. **Request Validation Bypass**: The request might have bypassed validation checks, allowing an invalid user ID to reach the service layer.
### Recommended Next Steps
1. **Verify Database Integrity**: Query the database directly to confirm whether user ID 12345 exists and is not corrupted. Run: `SELECT * FROM users WHERE id = 12345;`
2. **Add Null Checks**: Modify `UserService.updateUserProfile()` to explicitly check for `null` users before processing. Example:
```java
if (user == null) {
throw new IllegalArgumentException("User not found for ID: " + userId);
}
```
3. **Implement Logging**: Add debug logs in `UserRepository.findById()` to track when a user lookup returns `null`.
4. **Add Retry Logic**: For transient issues (e.g., race conditions), implement a retry mechanism with exponential backoff when fetching the user.
### Additional Diagnostics
- Check the application logs for any `UserNotFoundException` or similar exceptions around the time of the crash.
- Review the database transaction logs to see if the user record was deleted or modified concurrently.
- Test the endpoint with a valid user ID to confirm the fix works as expected.skills-collection
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan