Bug Hunter
v1.1.0 | Systematically hunt and detect potential bugs in code including security vulnerabilities, null safety issues, boundary conditions, exception handling gaps, logic defects, code smells, and concurrency problems.
A comprehensive bug detection prompt/instruction that systematically analyzes code to find potential issues before they reach production. Works with Claude Code, OpenAI Codex, Cursor, Qoder, Windsurf, and other AI coding assistants.
Quick Start
When hunting for bugs:
- Scan the target code - Read and understand the code structure
- Apply detection checklist - Go through each category systematically
- Report findings - Organize issues by severity and category
- Suggest fixes - Provide actionable remediation guidance
Detection Categories
1. Security Vulnerabilities
Check for:
- Injection: SQL injection, command injection, LDAP injection
- XSS: Reflected, stored, DOM-based cross-site scripting
- Authentication: Weak passwords, missing rate limiting, session fixation
- Authorization: Broken access control, IDOR, privilege escalation
- Data Exposure: Sensitive data in logs, hardcoded secrets, PII leaks
- Cryptography: Weak algorithms, improper key management
- SSRF/CSRF: Server-side request forgery, cross-site request forgery
- Path Traversal: Directory traversal, file inclusion vulnerabilities
2. Input Validation & Sanitization
Check for:
- Missing input validation on user data
- Unescaped output in HTML/SQL/Shell contexts
- Missing length/format/range checks
- Type coercion vulnerabilities
- Regex DoS (ReDoS) patterns
- Deserialization of untrusted data
3. Null Safety & Boundary Issues
Check for:
- Null/undefined dereference without guards
- Array/collection access without bounds checking
- Off-by-one errors in loops
- Empty collection handling
- Division by zero possibilities
- Integer overflow/underflow
4. Exception Handling Gaps
Check for:
- Catch blocks that swallow exceptions silently
- Missing try-catch for operations that can throw
- Unclosed resources (files, connections, streams)
- Finally blocks with return statements
- Exception type too broad (catching
Exception instead of specific types)
5. Logic Defects
Check for:
- Unreachable code paths
- Incorrect boolean logic (De Morgan's law violations)
- Wrong comparison operators (= vs ==, < vs <=)
- Missing break in switch/case
- Infinite loop possibilities
- Return value ignored when it shouldn't be
6. Code Smells
Check for:
- Duplicate code blocks
- Magic numbers without constants
- Functions/methods that are too long (>50 lines)
- Deep nesting (>4 levels)
- Unused variables or imports
- Hardcoded credentials or secrets
- TODO/FIXME comments that indicate known issues
7. Concurrency Problems
Check for:
- Race conditions on shared mutable state
- Deadlock possibilities (lock ordering)
- Non-atomic operations assumed to be atomic
- Missing synchronization
- Thread-unsafe singleton implementations
- Async/await misuse (missing await, fire-and-forget)
8. Performance Issues
Check for:
- N+1 database queries
- Missing pagination on large datasets
- Unbounded memory growth / memory leaks
- Inefficient algorithms (O(n²) when O(n) possible)
- Blocking I/O in async contexts
- Missing caching for expensive operations
- Unnecessary object creation in loops
Severity Levels
Report issues using these levels:
| Level |
Icon |
Description |
| Critical |
🔴 |
Will cause crashes or data corruption |
| High |
🟠 |
Likely to cause bugs in edge cases |
| Medium |
🟡 |
Code smell that may lead to issues |
| Low |
🟢 |
Minor improvement suggestion |
Output Format
## Bug Hunt Report
### Summary
- Critical: X issues
- High: X issues
- Medium: X issues
- Low: X issues
### Critical Issues 🔴
#### [Issue Title]
**Location:** `file.py:123`
**Problem:** Description of the issue
**Impact:** What can go wrong
**Fix:**
```code
// suggested fix
High Issues 🟠
...
## Language-Specific Checks
### Python
- Missing `if __name__ == "__main__"` guard
- Mutable default arguments
- Late binding closures in loops
- String formatting vulnerabilities (f-string injection)
- Pickle deserialization of untrusted data
- `eval()`/`exec()` on user input
### JavaScript/TypeScript
- `==` instead of `===`
- Missing `async/await` handling
- Prototype pollution risks
- Memory leaks in closures/event listeners
- `innerHTML` with unsanitized content
- `eval()`/`Function()` on user input
### Java/Kotlin
- Unchecked casts
- Resource leaks (try-with-resources missing)
- Null checks after method calls that can't return null
- Serialization/deserialization vulnerabilities
- SQL concatenation instead of prepared statements
### Go
- Ignored error returns
- Goroutine leaks (missing WaitGroup/context)
- Data races on maps
- Deferred function argument evaluation
- `fmt.Sprintf` in SQL queries
### Rust
- Unwrap on Result/Option without handling
- Integer overflow in release mode
- Unsafe blocks without proper documentation
- Use-after-free in unsafe code
### C/C++
- Buffer overflows
- Use-after-free / double-free
- Null pointer dereference
- Integer overflow
- Format string vulnerabilities
- Memory leaks (missing free)
### PHP
- SQL injection (missing PDO/prepared statements)
- `include`/`require` with user input
- Unserialize on untrusted data
- Missing CSRF tokens
- File upload vulnerabilities
## Additional Resources
- For detailed checklists, see [CHECKLIST.md](CHECKLIST.md)
- For real-world examples, see [examples.md](examples.md)
1---2name: bug-hunter-skill3description: Bug Hunter4---5# Bug Hunter67> **v1.1.0** | Systematically hunt and detect potential bugs in code including security vulnerabilities, null safety issues, boundary conditions, exception handling gaps, logic defects, code smells, and concurrency problems.89A comprehensive bug detection prompt/instruction that systematically analyzes code to find potential issues before they reach production. Works with Claude Code, OpenAI Codex, Cursor, Qoder, Windsurf, and other AI coding assistants.1011## Quick Start1213When hunting for bugs:14151. **Scan the target code** - Read and understand the code structure162. **Apply detection checklist** - Go through each category systematically173. **Report findings** - Organize issues by severity and category184. **Suggest fixes** - Provide actionable remediation guidance1920## Detection Categories2122### 1. Security Vulnerabilities2324Check for:25- **Injection**: SQL injection, command injection, LDAP injection26- **XSS**: Reflected, stored, DOM-based cross-site scripting27- **Authentication**: Weak passwords, missing rate limiting, session fixation28- **Authorization**: Broken access control, IDOR, privilege escalation29- **Data Exposure**: Sensitive data in logs, hardcoded secrets, PII leaks30- **Cryptography**: Weak algorithms, improper key management31- **SSRF/CSRF**: Server-side request forgery, cross-site request forgery32- **Path Traversal**: Directory traversal, file inclusion vulnerabilities3334### 2. Input Validation & Sanitization3536Check for:37- Missing input validation on user data38- Unescaped output in HTML/SQL/Shell contexts39- Missing length/format/range checks40- Type coercion vulnerabilities41- Regex DoS (ReDoS) patterns42- Deserialization of untrusted data4344### 3. Null Safety & Boundary Issues4546Check for:47- Null/undefined dereference without guards48- Array/collection access without bounds checking49- Off-by-one errors in loops50- Empty collection handling51- Division by zero possibilities52- Integer overflow/underflow5354### 4. Exception Handling Gaps5556Check for:57- Catch blocks that swallow exceptions silently58- Missing try-catch for operations that can throw59- Unclosed resources (files, connections, streams)60- Finally blocks with return statements61- Exception type too broad (catching `Exception` instead of specific types)6263### 5. Logic Defects6465Check for:66- Unreachable code paths67- Incorrect boolean logic (De Morgan's law violations)68- Wrong comparison operators (= vs ==, < vs <=)69- Missing break in switch/case70- Infinite loop possibilities71- Return value ignored when it shouldn't be7273### 6. Code Smells7475Check for:76- Duplicate code blocks77- Magic numbers without constants78- Functions/methods that are too long (>50 lines)79- Deep nesting (>4 levels)80- Unused variables or imports81- Hardcoded credentials or secrets82- TODO/FIXME comments that indicate known issues8384### 7. Concurrency Problems8586Check for:87- Race conditions on shared mutable state88- Deadlock possibilities (lock ordering)89- Non-atomic operations assumed to be atomic90- Missing synchronization91- Thread-unsafe singleton implementations92- Async/await misuse (missing await, fire-and-forget)9394### 8. Performance Issues9596Check for:97- N+1 database queries98- Missing pagination on large datasets99- Unbounded memory growth / memory leaks100- Inefficient algorithms (O(n²) when O(n) possible)101- Blocking I/O in async contexts102- Missing caching for expensive operations103- Unnecessary object creation in loops104105## Severity Levels106107Report issues using these levels:108109| Level | Icon | Description |110|-------|------|-------------|111| **Critical** | 🔴 | Will cause crashes or data corruption |112| **High** | 🟠 | Likely to cause bugs in edge cases |113| **Medium** | 🟡 | Code smell that may lead to issues |114| **Low** | 🟢 | Minor improvement suggestion |115116## Output Format117118```markdown119## Bug Hunt Report120121### Summary122- Critical: X issues123- High: X issues 124- Medium: X issues125- Low: X issues126127### Critical Issues 🔴128129#### [Issue Title]130**Location:** `file.py:123`131**Problem:** Description of the issue132**Impact:** What can go wrong133**Fix:** 134```code135// suggested fix136```137138### High Issues 🟠139...140```141142## Language-Specific Checks143144### Python145- Missing `if __name__ == "__main__"` guard146- Mutable default arguments147- Late binding closures in loops148- String formatting vulnerabilities (f-string injection)149- Pickle deserialization of untrusted data150- `eval()`/`exec()` on user input151152### JavaScript/TypeScript153- `==` instead of `===`154- Missing `async/await` handling155- Prototype pollution risks156- Memory leaks in closures/event listeners157- `innerHTML` with unsanitized content158- `eval()`/`Function()` on user input159160### Java/Kotlin161- Unchecked casts162- Resource leaks (try-with-resources missing)163- Null checks after method calls that can't return null164- Serialization/deserialization vulnerabilities165- SQL concatenation instead of prepared statements166167### Go168- Ignored error returns169- Goroutine leaks (missing WaitGroup/context)170- Data races on maps171- Deferred function argument evaluation172- `fmt.Sprintf` in SQL queries173174### Rust175- Unwrap on Result/Option without handling176- Integer overflow in release mode177- Unsafe blocks without proper documentation178- Use-after-free in unsafe code179180### C/C++181- Buffer overflows182- Use-after-free / double-free183- Null pointer dereference184- Integer overflow185- Format string vulnerabilities186- Memory leaks (missing free)187188### PHP189- SQL injection (missing PDO/prepared statements)190- `include`/`require` with user input191- Unserialize on untrusted data192- Missing CSRF tokens193- File upload vulnerabilities194195## Additional Resources196197- For detailed checklists, see [CHECKLIST.md](CHECKLIST.md)198- For real-world examples, see [examples.md](examples.md)