# Bug Fix Investigation Prompt

## 📋 Context

**Title:** {{TITLE}}

**Description:**
{{DESCRIPTION}}

**Reproduction Steps:**
{{STEPS}}

**Expected Behavior:**
{{EXPECTED}}

**Actual Behavior:**
{{ACTUAL}}

**Impact:** {{IMPACT}}

---

## 🎯 Your Task

Investigate and fix this bug following the structured approach below.

### Step 1: Understand the Error

- Read and understand the error message completely
- Identify which feature or component is affected
- Check error logs, stack traces, or user reports
- Understand the business impact

### Step 2: Trace the Data Flow

Start from where the user interacts with the system and trace through your application:

```
Controller/Route (receives request)
    ↓
Service/Action (processes business logic)
    ↓
Model/Repository (database operations)
    ↓
External APIs (if applicable)
```

Add logging at each step if needed to understand variable values:
- What data enters the function?
- What transformations happen?
- What data is returned or saved?

### Step 3: Check Git History

Use Git to understand the context:

```bash
# Find suspicious changes
git blame <file>

# See full history of changes
git log -p <file>

# Check recent commits
git log --oneline -20
```

Look for:
- Recent changes that could have broken this
- Why code was changed this way
- Dependencies on other changes

### Step 4: Identify Root Cause

List the root cause with:
- Exact location in code (file:line)
- What is wrong
- Why it's wrong
- Impact on the system

### Step 5: Propose Solution

Suggest the best fix:
- Minimal change (only fix the bug, don't refactor)
- No breaking changes to other features
- Consider performance and security
- Add tests to verify the fix

### Step 6: Test the Fix

```bash
# Run specific test
npm test -- tests/[feature].test.js

# Run all tests
npm test

# Check for linting issues
npm run lint
```

Verify:
- ✅ The bug is fixed
- ✅ No other tests break
- ✅ Code style compliant
- ✅ No performance regression

---

## 📚 Team Framework Rules

{{FRAMEWORK_RULES}}

---

## 📏 Team Rules & Standards

{{TEAM_RULES}}

---

## ✅ Success Criteria

- [ ] Root cause identified with code reference
- [ ] Fix implemented and tested
- [ ] All tests passing
- [ ] No breaking changes
- [ ] Code follows team standards
- [ ] Solution is minimal and focused

---

## 💡 Tips

- **Don't guess** → Investigate systematically
- **Don't break things** → Verify no side effects
- **Don't over-engineer** → Keep fix minimal
- **Do test thoroughly** → Verify all scenarios
- **Do document** → Explain why you fixed it this way

---

**Remember:** A good bug fix is one that:
1. Solves the problem completely
2. Doesn't create new problems
3. Is understood and maintainable
4. Is tested and verified

Start your investigation now! 🔍
