# Bitbucket PR Workflow

Use this reference after an AI agent completes a crash fix.

**Repository**: `{{BITBUCKET_WORKSPACE}}/{{BITBUCKET_REPO_SLUG}}`
**Target branch**: `{{BITBUCKET_TARGET_BRANCH}}`
**Reviewers**: {{BITBUCKET_REVIEWERS}}

---

## Create Pull Request

```
Use mcp_bitbucket_createPullRequest (or create_pull_request):

- workspace: "{{BITBUCKET_WORKSPACE}}"
- repository: "{{BITBUCKET_REPO_SLUG}}"
- title: "{{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER] Fix: [Crash Title]"
- description: [see template below]
- source_branch: "bugfix/{{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER]_[brief-description]"
- destination_branch: "{{BITBUCKET_TARGET_BRANCH}}"
- reviewers: [{{BITBUCKET_REVIEWERS}}]
```

---

## PR Description Template

```markdown
## 🔥 Crash Fix: [Issue Title]

### 🎫 Related Ticket
- **Jira**: {{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER]
- **Branch**: bugfix/{{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER]_[brief-description]

### 📊 Crash Context
- **Firebase Issue**: [Firebase Console Link]
- **Jira Ticket**: [Jira Ticket Link]
- **Crash Type**: FATAL / NON-FATAL
- **Impact**: [X] crashes affecting [Y] users ([Z]% crash-free rate)
- **Affected Versions**: [Version range]
- **Affected Devices**: [Device models and OS versions]

### 🐛 Root Cause Analysis
[AI-generated analysis of the crash cause]

**Stacktrace Summary**:
\`\`\`
[Key stacktrace lines showing crash location]
\`\`\`

### ✅ Solution Implemented
[Detailed description of the fix approach]

### 🧪 Testing Performed
- [ ] Unit tests added/updated: [Test file paths] OR "N/A - UI/View class changes only"
- [ ] Manual testing completed: [Test scenarios] — MANDATORY
- [ ] Regression testing: [Scope covered]
- [ ] Performance impact: [Memory/CPU measurements]
- [ ] Crash reproduction verified: [Steps tested]

**Unit Test Exclusion Note** (if applicable):
If unit tests skipped because changes are in UI/View classes:
- [ ] Changes are purely UI/View-related (Activity/Fragment/Adapter/ViewHolder/Custom Views)
- [ ] Manual testing documented above covers all scenarios
- [ ] UI/Espresso tests added where applicable

### 📈 Expected Impact
- Target crash-free percentage: >99.5%
- Resolution confidence: [High/Medium based on testing]

### 📝 Commit Convention
All commits follow: `{{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER] [description]`

Example commits:
- {{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER] fix crash on [component]
- {{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER] add null safety checks
- {{JIRA_PROJECT_KEY}}-[ISSUE-NUMBER] add unit tests

### 🤖 AI Agent Information
- **Generated by**: [Claude Code / Copilot / Gemini / Codex]
- **Execution time**: [Duration]
- **Files modified**: [List of changed files]

---
⚠️ AI-Generated Fix: Please review thoroughly before merging.
```

---

## Merge Pull Request (after review)

```
Use mcp_bitbucket_mergePullRequest (or merge_pull_request):

- workspace: "{{BITBUCKET_WORKSPACE}}"
- repository: "{{BITBUCKET_REPO_SLUG}}"
- pull_request_id: [PR ID from creation response]
- merge_strategy: "squash"       # or "merge_commit" / "fast_forward"
- close_source_branch: true
```

**Note**: Review and approve the PR before merging to `{{BITBUCKET_TARGET_BRANCH}}`.
