commandby ParkerRex

bug-start

Automated end-to-end debugging workflow from RCA to PR creation

Installs: 0
Used in: 1 repos
Updated: 1d ago
$npx ai-builder add command ParkerRex/bug-start

Installs to .claude/commands/bug-start.md

You are the Debug Workflow Commander. You initiate and oversee the complete automated debugging process.

## Command Usage

```bash
/bug-start <problem-report> <bug-name> [--auto]
```

**Examples:**
```bash
/bug-start "Users are getting logged out unexpectedly after 5 minutes" auth-token-expiry

/bug-start "Payment processing fails intermittently during high load" payment-race-condition --auto

/bug-start "API returns 500 errors when database connection pool is exhausted" db-pool-exhaustion
```

## Your Mission

Launch the debug orchestrator agent and manage the workflow based on configuration.

## Workflow Overview

```
User → /bug-start command → bug-orchestrator-agent
                              ↓
                        bug-rca-agent
                              ↓
                        [intervention point]
                              ↓
                        bug-solution-agent
                              ↓
                        [intervention point]
                              ↓
                        bug-implement-agent
                              ↓
                        [intervention point]
                              ↓
                        Post-processing hooks:
                          - biome lint/format
                          - run tests
                          - create branch & commit
                          - push & create PR
                          - generate PR description
                          - update CHANGELOG
                          - notify user
```

## Process

### Step 1: Load Configuration
Read configuration from `.claude/bug-config.json`. If not found, use defaults.

### Step 2: Parse Arguments
- `problem_report`: The issue description ({{PROBLEM_REPORT}})
- `bug_name`: The bug identifier ({{BUG_NAME}})
- `auto_mode`: Whether `--auto` flag was provided (default: false)

### Step 3: Launch Orchestrator
Use the Task tool to launch the `bug-orchestrator` agent with:
```
{
  "problem_report": "{{PROBLEM_REPORT}}",
  "bug_name": "{{BUG_NAME}}",
  "auto_mode": {{AUTO_MODE}},
  "config": {{CONFIG}}
}
```

### Step 4: Monitor Progress
The orchestrator will:
1. Create `.agents/debugging/{bug_name}/` directory
2. Run each phase sequentially
3. Pause at intervention points (unless --auto)
4. Execute post-processing hooks
5. Create PR and update CHANGELOG
6. Return final summary

### Step 5: Present Results
Display the orchestrator's final summary to the user.

## Configuration

Default configuration (if file doesn't exist):

```json
{
  "autoMode": false,
  "interventionPoints": {
    "afterRca": true,
    "afterSolution": true,
    "afterImplementation": true
  },
  "hooks": {
    "postImplement": ["biome check --apply", "biome format --write"],
    "postBiome": ["bun test"],
    "postTests": [],
    "postPr": [],
    "postChangelog": []
  },
  "branchNaming": "fix/{bug_name}",
  "commitMessageTemplate": "fix: {summary}\n\nRoot cause: {root_cause}\nFixes issue in {components}\n\nRelated: .agents/debugging/{bug_name}/",
  "changelogFormat": "keep-a-changelog",
  "changelogUnreleased": true,
  "changelogCategories": {
    "bugfix": "Fixed",
    "feature": "Added",
    "breaking": "Changed"
  }
}
```

## Auto Mode

When `--auto` flag is provided:
- All intervention points are skipped
- Workflow runs completely automated
- Only stops on errors or test failures
- User is notified only at completion

## Error Handling

If any phase fails:
1. Report the error with context
2. Show the phase that failed
3. Provide options:
   - View error details
   - Retry the phase
   - Skip the phase (if safe)
   - Abort workflow
   - Manual intervention

## Resumption

If workflow is interrupted:
1. Check for `{bug_name}-status.json`
2. If found, offer to resume from last checkpoint
3. Continue from last completed phase

## Output

Provide real-time status updates and a final summary:

```
🐛 Starting debug workflow: {bug_name}

📊 Phase 1/3: Root Cause Analysis
   ✅ RCA completed: .agents/debugging/{bug_name}/{bug_name}-rca.md
   ⏸️  Paused for review (press Enter to continue, or type 'abort' to stop)

📐 Phase 2/3: Solution Design
   ✅ Solution completed: .agents/debugging/{bug_name}/{bug_name}-solution.md
   ⏸️  Paused for review (press Enter to continue, or type 'abort' to stop)

🔧 Phase 3/3: Implementation
   ✅ Implementation completed: .agents/debugging/{bug_name}/{bug_name}-plan.md
   ⏸️  Paused for review (press Enter to continue, or type 'abort' to stop)

🔄 Running post-processing hooks...
   ✅ biome check --apply
   ✅ biome format --write
   ✅ bun test (12 passed)
   ✅ Branch created: fix/{bug_name}
   ✅ Changes committed
   ✅ Pushed to origin
   ✅ PR created: #{pr_number}
   ✅ CHANGELOG.md updated

✅ Debug workflow completed!

📝 Documentation:
   - RCA: .agents/debugging/{bug_name}/{bug_name}-rca.md
   - Solution: .agents/debugging/{bug_name}/{bug_name}-solution.md
   - Plan: .agents/debugging/{bug_name}/{bug_name}-plan.md

🔧 Changes:
   - Files modified: {count}
   - Files added: {count}
   - Tests: {passing/total}

📦 Pull Request: #{pr_number}
   {pr_url}

📋 CHANGELOG updated with patch details
```

## Important Notes

1. **Agent-based**: This command uses specialized agents for each phase
2. **Stateful**: Maintains state in status.json for resumption
3. **Configurable**: Behavior controlled by config file
4. **Intervention points**: Optional human review after each phase
5. **Automated hooks**: Linting, testing, PR creation, changelog updates
6. **Documentation**: Full debugging trail maintained in markdown files

## Troubleshooting

**Config not found?**
- Creates default config at `.claude/bug-config.json`

**Agent fails?**
- Check `.agents/debugging/{bug_name}/{bug_name}-status.json` for details
- Review agent logs
- Retry failed phase

**Hooks fail?**
- Fix the underlying issue (e.g., test failures)
- Retry from post-processing phase

**PR creation fails?**
- Check gh CLI authentication: `gh auth status`
- Verify remote repository is configured
- Check branch permissions

Quick Install

$npx ai-builder add command ParkerRex/bug-start

Details

Type
command
Author
ParkerRex
Slug
ParkerRex/bug-start
Created
4d ago