name: mode-debug
description: >-
Debug mode for fixing bugs, errors, and crashes. Use when user reports bugs or
errors that need fixing. Follows 5W1H approach: gather info, reproduce, analyze
root cause, fix, and prevent recurrence.
license: MIT
compatibility: opencode
metadata:
category: workflow
source: antigravity-kit
Debug Mode
Goal: Find the correct cause, fix the right place, prevent recurrence.
Process
- Gather information (5W1H)
- Reproduce the bug
- Analyze root cause
- Propose fix + explanation
- Propose prevention measures
Required Questions If Information Is Missing
- Exact error message? (Copy verbatim)
- Which screen/feature does it occur on?
- Can it be reproduced? Specific steps?
- Any recent code changes?
- Anything unusual in logs?
- Which language/framework are you using?
Common Bug Patterns
Null/None Reference Errors
| Language |
Error Message |
Typical Cause |
| JS/TS |
Cannot read property of undefined |
Missing null check |
| Python |
AttributeError: 'NoneType' has no attribute |
Variable is None |
| Java |
NullPointerException |
Object not initialized |
| Go |
panic: runtime error: invalid memory address |
Nil pointer |
Type/Cast Errors
| Language |
Error Message |
Typical Cause |
| JS/TS |
TypeError: X is not a function |
Wrong type assignment |
| Python |
TypeError: unsupported operand type |
Type mismatch |
| Java |
ClassCastException |
Invalid casting |
Common Logic Bugs
| Bug Type |
Symptom |
All Languages |
| Off-by-one |
Wrong loop bounds |
< vs <=, index starts at 0 or 1 |
| Race condition |
Inconsistent data |
Async/threading without sync |
| Memory leak |
Performance degrades |
Missing cleanup, circular refs |
| Infinite loop |
App hangs/freezes |
Missing break condition |
Output Format
## DEBUG
**Symptom:** [error description]
**Language:** [JS/Python/Java/Go/PHP/Ruby]
**Reproduction:**
1. [Step 1]
2. [Step 2]
3. [Error appears]
---
### Analysis:
**Root Cause:** [root cause]
**Location:** `[file:line]`
### Fix:
```diff
- [old code]
+ [new code]
Reason: [explanation]
Prevention:
| Suggestion |
Priority |
| [Add validation] |
High |
| [Write unit test] |
Medium |
## Quick Fix Examples
### JavaScript
```diff
- const userName = user.name;
+ const userName = user?.name ?? 'Unknown';
Python
- email = data['email']
+ email = data.get('email', '')
Go
- value := items[index]
+ if index < len(items) {
+ value := items[index]
+ }
Principles
| DON'T |
DO |
| Guess randomly |
Request log/screenshot |
| Refactor randomly |
Fix the right place, minimal change |
| Stop after fixing |
Propose prevention |
| Fix symptoms |
Find and fix root cause |
| Skip testing fix |
Verify fix works before delivering |