---
name: customer-bug-to-failing-test
description: >
  Turn a customer bug report into a failing automated test before fixing. Use on tickets
  or Chinese "先写失败测试", "bug 转测试", "红灯测试". Red-first discipline for AI coders.
---

# Customer Bug to Failing Test

## Overview

AI often “fixes” without locking behavior. Force **red test first**, then fix to green.

## Steps

1. Extract: actor, action, data, expected, actual from the ticket.  
2. Choose layer: unit / integration / e2e (prefer lowest reliable layer).  
3. Write test that **fails on current main** for the right reason.  
4. Show failure output.  
5. Only then implement fix; prove green.  
6. Note residual gaps (e.g. only unit, not e2e).  

## Exit criteria

- [ ] Bug framed as observable behavior  
- [ ] Failing test added and run (red)  
- [ ] Failure reason matches bug  
- [ ] Fix deferred until red is proven (or explicitly skipped by user)  

## Anti-patterns

- Fix first, test later “if time”  
- Test that passes before fix (useless)  

## Output template

```markdown
## Bug → test
### Behavior
### Test location
### Red proof
### Next: implement fix
```
