# Agent: Fix Bug

End-to-end bug fixing with reproduction, patch generation, and verification.

## Usage

```
/agent-fix-bug "Login fails after password reset"
```

## Description

The `/agent-fix-bug` skill fixes bugs through a systematic process:
1. Classify the issue type (bug/feature/question/doc)
2. Reproduce the bug in isolated environment
3. Retrieve relevant code context via knowledge graph
4. Generate and apply patch
5. Verify fix with regression tests

## Examples

### Fix a reported bug
```
/agent-fix-bug "Users with special characters in names cannot sign up"
```

### Fix with specific error
```
/agent-fix-bug "NullPointerException in UserService.updateProfile
Error: java.lang.NullPointerException: Cannot invoke \"String.length()\" because the return value of \"User.getName()\" is null"
```

### Fix with reproduction steps
```
/agent-fix-bug "Shopping cart loses items when user switches tabs
Steps:
1. Add item to cart
2. Open new tab
3. Cart appears empty
4. Return to original tab
5. Cart still shows items"
```

## Backends

- **Primary**: Prometheus (bug pipeline with LangGraph agents)
- **Verification**: Every Code Auto Review
- **Testing**: Prometheus (Docker container execution)

## Workflow

### 1. Issue Classification
- Analyze issue description
- Classify as bug/feature/question/documentation
- Identify affected components

### 2. Bug Reproduction
- Create minimal reproduction case
- Execute in Docker container
- Capture error logs and stack traces

### 3. Context Retrieval
- Search knowledge graph for related code
- Analyze AST for function call chains
- Identify similar bug fixes

### 4. Patch Generation
- Generate fix using AI reasoning
- Apply patch with git
- Test in isolated environment

### 5. Verification
- Run regression tests
- Verify reproduction case is fixed
- Generate test coverage report

## Output

```
✓ Issue classified as: bug
✓ Bug reproduced: UserService.updateProfile throws NPE for null names
✓ Context retrieved: 5 related files, 12 similar issues
✓ Patch generated: Added null check in UserService.updateProfile
✓ Tests passed: 15/15
✓ Regression verified: No existing tests broken

Fix applied: prometheus-backend/src/main/java/com/prometheus/service/UserService.java:47
```

## Follow-up

After fixing:
- `/agent-review` - Review the changes
- `/agent-test` - Run specific tests
- `/agent-context` - Understand the fix context
