# Git-Bug Command Reference for CodeCrew

## Overview
git-bug is our primary bug tracking system, synced bidirectionally with bug.md via `scripts/sync-bugs.sh`.

## Core Commands

### Listing Bugs
```bash
# List all bugs
git bug bug

# List open bugs only
git bug bug --status open

# List closed bugs only
git bug bug --status closed

# Search bugs by text
git bug bug "keyword"
```

### Viewing Bug Details
```bash
# Show full bug details
git bug bug show BUG_HASH

# Show bug title
git bug bug title BUG_HASH

# Show bug comments
git bug bug comment BUG_HASH
```

### Creating Bugs
```bash
# Create new bug (interactive)
git bug bug new

# Create bug with title and message (non-interactive)
git bug bug new --title "Bug title" --message "Description"
```

### Updating Bug Status
```bash
# Close a bug
git bug bug status close BUG_HASH

# Reopen a bug
git bug bug status open BUG_HASH
```

### Managing Labels
```bash
# Add labels to bug
git bug bug label new BUG_HASH label1 label2

# Remove labels
git bug bug label rm BUG_HASH label1

# View bug labels
git bug bug label BUG_HASH
```

### Adding Comments
```bash
# Add comment to bug
git bug bug comment new BUG_HASH --message "Comment text"

# Edit existing comment
git bug bug comment edit COMMENT_ID --message "Updated text"
```

## CodeCrew Bug Workflow

### Bug ID Mapping
- bug.md IDs (bug-00000001) map to git-bug hashes via `.codecrew/bug-hash-map.txt`
- Format: `bug-00000001:b31d1c9`

### Standard Labels
- **status:** created, analyzed, in-progress, resolved, rejected, closed
- **priority:** 높음 (high), 중간 (medium), 낮음 (low)
- **version:** 0.3.x (version where bug found/fixed)

### Bug States
1. **created** → Bug reported, not analyzed
2. **analyzed** → Root cause identified
3. **in-progress** → Developer working on fix
4. **resolved** → Fix implemented, ready for testing
5. **closed** → Verified working, released
6. **rejected** → Won't fix (duplicate, invalid, etc.)

## Sync with bug.md

### Export bug.md → git-bug
```bash
cd /Users/doha/git/codecrew
./scripts/sync-bugs.sh export
```

### Import git-bug → bug.md
```bash
./scripts/sync-bugs.sh import
```

### Bidirectional sync
```bash
./scripts/sync-bugs.sh sync
```

## Common Workflows

### Find bugs by status
```bash
# Find all resolved bugs (ready for RC)
git bug bug | grep 'status:resolved'

# Find bugs in specific version
git bug bug | grep 'version:0.3.13'
```

### Get bug details for testing
```bash
# Get bug hash from ID
BUG_ID="bug-00000021"
HASH=$(grep "^${BUG_ID}:" .codecrew/bug-hash-map.txt | cut -d: -f2)

# Show bug details
git bug bug show $HASH
```

### Update bug status after fix
```bash
# Add in-progress label
git bug bug label new $HASH status:in-progress

# Remove created label
git bug bug label rm $HASH status:created

# Add comment with resolution
git bug bug comment new $HASH --message "Fixed in commit abc123"

# Mark as resolved
git bug bug label rm $HASH status:in-progress
git bug bug label new $HASH status:resolved
```

## Agent Usage Tips

### For Developers (@codecrew_dev)
- Use `git bug bug --status open` to find bugs to fix
- Update status: created → in-progress → resolved
- Add comments with fix details
- Never set status:closed (only users can close)

### For QA (@codecrew_qa_lead, @codecrew_tester)
- List resolved bugs: `git bug bug | grep 'status:resolved'`
- Get bug details for test planning: `git bug bug show HASH`
- Verify labels match expected version

### For Release Manager (@codecrew_release_manager)
- Find bugs for RC: `git bug bug | grep 'status:resolved'`
- Parse bug hashes for merging
- Cross-reference with .codecrew/bug-hash-map.txt

## Output Format
```
HASH    STATUS  TITLE
b31d1c9 open    [bug-00000001] 로그 버그
6cfd309 closed  [bug-00000002] Claude CLI v2.0 Breaking Changes
...
```

- First column: git-bug hash (7 chars)
- Second column: open/closed status
- Third column: Bug title (includes bug-ID if synced from bug.md)

## Important Notes
- **Hash is primary identifier** in git-bug (not bug-ID)
- Bug titles include [bug-XXXXX] prefix when synced from bug.md
- Status in git-bug: only "open" or "closed" (labels track detailed states)
- Always sync after manual git-bug changes: `./scripts/sync-bugs.sh import`
