Arguments: `/git-actions:pr-edit [PR_NUMBER] [CUSTOM_INSTRUCTIONS]`
Edit PR descriptions with AI assistance or generate draft PRs. Use to update existing PRs with custom instructions or preview descriptions before creating a PR.
/plugin marketplace add olioapps/claude-code-plugins/plugin install git-actions@olio-pluginsArguments: /git-actions:pr-edit [PR_NUMBER] [CUSTOM_INSTRUCTIONS]
Examples:
/git-actions:pr-edit - Update current branch PR or generate draft/git-actions:pr-edit 123 - Update PR #123/git-actions:pr-edit 123 brief format - Update with minimal description/git-actions:pr-edit add performance metrics - Update current PR, add perf sectionCurrent: !git branch --show-current
Check prerequisites:
git rev-parse --git-dir 2>/dev/null || echo "NOT_A_REPO"
command -v gh &>/dev/null || echo "GH_NOT_FOUND"
gh auth status &>/dev/null || echo "GH_NOT_AUTH"
Abort if:
Parse arguments and check PR existence:
pr_id="$1" # May be number, URL, or empty
if [ -n "$pr_id" ]; then
# Specific PR provided
gh pr view "$pr_id" &>/dev/null || echo "PR_NOT_FOUND"
mode="existing"
pr_number=$(gh pr view "$pr_id" --json number -q .number)
elif gh pr view &>/dev/null; then
# Current branch has PR
mode="existing"
pr_number=$(gh pr view --json number -q .number)
else
# No PR exists - generate draft
mode="draft"
fi
Modes:
pr_data=$(gh pr view "$pr_number" --json number,title,body,baseRefName,headRefName,state,isDraft)
current_title=$(echo "$pr_data" | jq -r .title)
current_body=$(echo "$pr_data" | jq -r .body)
base=$(echo "$pr_data" | jq -r .baseRefName)
head=$(echo "$pr_data" | jq -r .headRefName)
state=$(echo "$pr_data" | jq -r .state)
is_draft=$(echo "$pr_data" | jq -r .isDraft)
Verify permissions:
Use pr-creator agent.
Context:
- mode: update-existing
- PR: #$pr_number
- current_title: "$current_title"
- current_body: "$current_body"
- branches: $base ← $head
- state: $state (draft: $is_draft)
[IF USER PROVIDED CUSTOM INSTRUCTIONS:]
USER INSTRUCTIONS (HIGHEST PRIORITY):
"""
[custom instructions verbatim]
"""
Agent returns structured output:
---TITLE---
[updated title]
---BODY---
[updated body]
---END---
Parse response. Validate:
## Updated PR Description
**Current Title:** [current_title]
**New Title:** [new_title]
**Current Body:**
[first 30 lines of current_body]
**New Body:**
[first 50 lines of new_body, indicate if truncated]
**Changes:** [highlight what changed]
Use AskUserQuestion: "Apply these changes to PR #$pr_number?"
Options:
On approval:
# Update PR with new title and body
gh pr edit "$pr_number" --title "$new_title" --body "$(cat <<'EOF'
$new_body
EOF
)"
# Get updated PR URL
pr_url=$(gh pr view "$pr_number" --json url -q .url)
If update succeeds:
✅ PR #$pr_number updated successfully!
🔗 $pr_url
If update fails:
On cancel: ❌ "Cancelled. PR description unchanged."
current=$(git branch --show-current)
base=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
[ -z "$base" ] && base="main"
# Check commits exist
commits=$(git rev-list --count origin/$base..HEAD 2>/dev/null)
[ "$commits" -eq 0 ] && echo "NO_COMMITS"
Abort if:
Use pr-creator agent.
Context:
- mode: draft-preview
- branch: $current
- base: $base
- commits: $commits
[IF USER PROVIDED CUSTOM INSTRUCTIONS:]
USER INSTRUCTIONS (HIGHEST PRIORITY):
"""
[custom instructions verbatim]
"""
Agent returns structured output:
---TITLE---
[draft title]
---BODY---
[draft body]
---END---
Parse response. Validate:
## Draft PR Description
**Title:** [title]
**Body:**
[body]
**Target:** $current → $base
**Commits:** $commits
Use AskUserQuestion: "What would you like to do with this draft?"
Options:
/git-actions:pr-write with this descriptionIf "Create PR now":
/git-actions:pr-write commandIf "Save to file":
draft_file=".github/PR_DRAFT_$(date +%Y%m%d_%H%M%S).md"
cat > "$draft_file" <<EOF
# $title
$body
EOF
echo "✅ Saved: $draft_file"
If "Revise":
If "Cancel": ❌ "Draft discarded."
YOU (handler): determine mode, fetch PR data (if exists), invoke agent, present changes, get approval, execute gh pr edit or save draft, handle errors
Agent: analyze current PR or branch changes, generate updated/draft description, return structured title + body
Agent does NOT orchestrate or execute. You do NOT format PR descriptions.
/git-actions:pr-edit # Auto: update PR or create draft
/git-actions:pr-edit 123 # Update PR #123
/git-actions:pr-edit https://github.com/user/repo/pull/123 # Update by URL
/git-actions:pr-edit brief format
# Update current PR with minimal description
/git-actions:pr-edit 123 add performance metrics
# Update PR #123, add performance section
/git-actions:pr-edit focus on security
# Update current PR, emphasize security
/git-actions:pr-edit 123 skip testing section
# Update PR #123, omit testing details
# Update after adding commits
git commit -m "Additional fixes"
git push
/git-actions:pr-edit # Regenerate description with new commits
# Preview before creating
git checkout -b feature/new
# Make changes...
/git-actions:pr-edit # Generate draft preview
# Option: "Create PR now" or "Save to file"
# Iterate on description
/git-actions:pr-edit # Generate
# Option: "Revise" → provide feedback
# Agent regenerates with feedback
# Title only
gh pr edit 123 --title "new title"
# Body only
gh pr edit 123 --body "$(cat PR_DESCRIPTION.md)"
# Append section
current=$(gh pr view 123 --json body -q .body)
gh pr edit 123 --body "$current
## Additional Section
New content here"