144 lines
2.8 KiB
Markdown
144 lines
2.8 KiB
Markdown
---
|
|
name: create-pr
|
|
description: Create a Bitbucket pull request from a worktree branch.
|
|
---
|
|
|
|
# Skill: create-pr
|
|
|
|
Create a Bitbucket (or GitHub) pull request from a worktree branch.
|
|
|
|
## Invoked by
|
|
|
|
🎫 JiraOps mode (or 🪃 Orchestrator)
|
|
|
|
## Required Inputs
|
|
|
|
| Input | Source | Example |
|
|
|-------|--------|---------|
|
|
| `TICKET_KEY` | Jira issue key | `PROJECT-123` |
|
|
| `MODULE` | Module/component name | `auth`, `api`, `core` |
|
|
|
|
## Output
|
|
|
|
- Pull request created targeting the main branch
|
|
- Jira comment with PR link added
|
|
- BigMind fact stored
|
|
|
|
## Steps
|
|
|
|
### 1. Get current branch
|
|
|
|
```bash
|
|
cd <your-repo-path>-<TICKET_KEY>
|
|
git branch --show-current
|
|
```
|
|
|
|
### 2. Ensure all changes are committed
|
|
|
|
```bash
|
|
git status
|
|
```
|
|
|
|
If uncommitted changes exist, warn the user before proceeding.
|
|
|
|
### 3. Push branch to origin
|
|
|
|
```bash
|
|
git push -u origin <BRANCH>
|
|
```
|
|
|
|
### 4. Gather diff statistics
|
|
|
|
```bash
|
|
git diff origin/main --stat
|
|
git diff origin/main --name-only
|
|
```
|
|
|
|
### 5. Read Jira ticket for context
|
|
|
|
```python
|
|
ticket = retrieve_ticket_details(TICKET_KEY)
|
|
# Extract: summary, description for PR title/description
|
|
```
|
|
|
|
### 6. Compose PR title and description
|
|
|
|
PR title format:
|
|
```
|
|
<TICKET_KEY>: <Jira summary>
|
|
```
|
|
|
|
PR description template:
|
|
```markdown
|
|
## Jira
|
|
|
|
<TICKET_KEY>: <summary>
|
|
|
|
## Description
|
|
|
|
<Brief description of what was changed and why>
|
|
|
|
## Changes
|
|
|
|
<List of changed files grouped by component>
|
|
|
|
## Tests
|
|
|
|
- <N> Unit tests
|
|
- <M> Integration tests
|
|
- All tests passing ✅
|
|
|
|
## Checklist
|
|
|
|
- [ ] Code review completed
|
|
- [ ] Tests passing
|
|
- [ ] No generated source modifications
|
|
```
|
|
|
|
### 7. Create the pull request
|
|
|
|
```python
|
|
create_pull_request(
|
|
project_key="<PROJECT>",
|
|
repo_slug="<repo>",
|
|
title=f"{TICKET_KEY}: {summary}",
|
|
description=<composed description>,
|
|
from_branch=<BRANCH>,
|
|
to_branch="main"
|
|
)
|
|
```
|
|
|
|
### 8. Add Jira comment with PR link
|
|
|
|
```python
|
|
add_comment_to_ticket(
|
|
issue_key=TICKET_KEY,
|
|
comment=f"*Pull Request created*\n\nBranch: {BRANCH}\nPR: [PR #{pr_id}|<pr_url>]"
|
|
)
|
|
```
|
|
|
|
### 9. Store in BigMind
|
|
|
|
```python
|
|
memory_store_fact(
|
|
category="codebase",
|
|
fact=f"{TICKET_KEY}: PR #{pr_id} created — {BRANCH} → main. {N} files changed."
|
|
)
|
|
```
|
|
|
|
## Error Handling
|
|
|
|
| Error | Resolution |
|
|
|-------|------------|
|
|
| Branch not pushed | Run `git push -u origin <BRANCH>` first |
|
|
| Uncommitted changes | Warn user, suggest `git add` + `git commit` |
|
|
| PR already exists | Check `list_prs_for_repository` for existing PR from same branch |
|
|
| Merge conflicts | Run `git fetch origin main && git merge origin/main` in worktree |
|
|
| No diff (empty PR) | Branch is identical to `main` — nothing to merge |
|
|
|
|
## Conventions
|
|
|
|
- PR title: always starts with `TICKET_KEY:` for Jira auto-linking
|
|
- Target branch: typically `main` (configure per project)
|
|
- One PR per ticket — don't create multiple PRs for the same branch
|