Create commits, push branch, and open a pull request on GitHub
Creates commits, pushes branch, and opens a GitHub pull request. Use after completing work to prepare changes for review.
/plugin marketplace add sevos/claude-code-marketplace/plugin install git@sevos-claude-code-marketplacedraftclaude-haiku-4-5You are executing the /open-pr command. Follow these steps precisely:
draft (optional): Create PR as draft if specified (e.g., /open-pr draft)This command creates commits, pushes a branch, and opens a PR. Questions are asked upfront in the main agent, then execution is delegated to preserve context.
CRITICAL: Run this check FIRST.
Check current branch: git branch --show-current
If on main or master branch:
git diff --stat to understand changes brieflyfeature/name, fix/name, or refactor/namegit checkout -b <chosen-branch-name>If on any other branch: Proceed to Step 1.
Extract session context:
Run lightweight git commands:
git status --short
git diff --stat
Assess:
Create a concise summary (2-4 sentences) of the session's work.
Use AskUserQuestion to gather decisions BEFORE delegating. Ask in a single call when multiple apply:
Question 1 (if multiple distinct tasks detected):
Question 2 (if unstaged/untracked files exist not from session):
If "Let me review first": List files and wait. Do not proceed.
Launch a general-purpose agent with the Task tool using claude-haiku-4-5 model.
Include in the prompt:
Agent prompt structure:
You are creating commits, pushing a branch, and opening a PR. Work autonomously - do not ask questions.
## Session Context
[Include summary from Step 1]
## User Decisions
- Commit strategy: [single commit / multiple logical commits]
- Scope: [all changes / session changes only - list specific files if applicable]
- Branch: [branch name]
- Draft PR: [yes/no]
## Your Tasks
### 1. Analyze changes
Run `git diff` on relevant files to understand what changed.
### 2. Create commits
Stage and commit according to user's strategy.
**Commit message rules:**
- Style: Concise, factual. State what was done.
- Simple changes: Title only
- Complex changes: Title + brief description
- Avoid self-praise adjectives
- Hard limit: 80 words total
- Format:
```bash
git commit -m "$(cat <<'EOF'
Commit title here
Optional description.
EOF
)"
If multiple commits: chronological order, each self-contained.
Check if force-push needed (git status shows diverged).
git push -u origin <branch-name>On push failure: Report error and stop.
PR Title:
PR Description:
Create PR:
gh pr create --title "PR title" --body "$(cat <<'EOF'
PR description here.
EOF
)" [--draft if requested]
On failure: Report error and stop.
xdg-open <PR_URL>
Output:
## Step 4: Display Results
After agent completes, display:
- Commit SHA(s) with messages
- Branch name
- PR URL
- Total commits created
## Error Handling
If agent reports failures:
1. Display error clearly
2. Ask if user wants to retry or needs assistance