| name | forge-bug-investigate |
| description | Investigate bugs automatically - error logs, code paths, root cause analysis, edge cases. Trigger when user types /forge-bug-investigate or requests bug investigation/debugging.
|
/forge-bug-investigate
Investigate bugs automatically using AI reasoning.
Command
/forge-bug-investigate [path] [--quick|--deep] [--markdown|--json] [--verbose]
Options
[path] — Target directory (default: current directory)
--quick — Fast scan, focus on critical issues only
--deep — Thorough scan, check all patterns
--markdown — Output as markdown (default)
--json — Output as JSON
--verbose — Include detailed evidence
Purpose
Analyze source code for:
- Error handling issues
- Null/undefined access risks
- Race conditions
- Memory leaks
- Edge case bugs
Workflow
Step 1: Understand Project
Use shared/analyzer/ to detect:
- Repository type
- Primary language
- Framework
- Project structure
Step 2: Run Bug Analysis
Execute analysis prompts:
- Error Log Analysis (
prompts/error-log-analysis.md)
- Code Path Tracing (
prompts/code-path-tracing.md)
- Root Cause Analysis (
prompts/root-cause-analysis.md)
- Edge Case Detection (
prompts/edge-case-detection.md)
Step 3: Classify Findings
For each finding:
- Assign severity: Critical, High, Medium, Low, Info
- Assign confidence: High, Medium, Low
- Include evidence (file, line, code snippet)
Step 4: Generate Report
Use shared/report/ to generate:
- Bug Score (0-100)
- Severity-grouped findings
- Root cause analysis
- Fix recommendations
Output Format
Follow the markdown report format generated by shared/report/markdown.ts. It MUST use the following layout:
Bug Investigation Report
Project: [Project Name]
Path: [Project Path]
Language: [Primary Language]
Framework: [Detected Framework (optional)]
Date: [Timestamp]
Score
[Score]/100 (Grade: [Grade])
| Severity | Count |
|---|
| 🔴 Critical | [count] |
| 🟠 High | [count] |
| 🟡 Medium | [count] |
| 🔵 Low | [count] |
| ⚪ Info | [count] |
Executive Summary
Found [total] issues: [count] critical, [count] high, [count] medium, [count] low, [count] info.
🔍 Detailed Findings
[Severity Group (e.g. 🔴 Critical)]
| Title | Location | Description | Impact |
|---|
| [Finding Title] | [file-name]:[line] | [Description] | [Impact] |
📂 Code Evidence
Finding #[number]: [Finding Title]
[code snippet]