-
Notifications
You must be signed in to change notification settings - Fork 27
PR skill: auto-populate PR description when gh pr create fails #72
Description
Problem
When gh pr create fails (the common case for GitHub App bots due to Resource not accessible by integration), the PR skill falls back to providing a GitHub compare URL. The user must then manually copy the contents of artifacts/bugfix/docs/pr-description.md and paste it into the PR body field.
This is tedious, especially in environments where browsing and copying file contents is awkward.
Proposed Approaches
Three options worth evaluating (not mutually exclusive):
1. Encode the PR body into the compare URL query parameters
GitHub's compare URL supports title and body query parameters:
https://github.com/OWNER/REPO/compare/main...FORK:branch?expand=1&title=fix(scope):+desc&body=URL-encoded-body
Pros: Single click opens the PR form fully populated. No copy/paste needed.
Cons: URL length limits (~8KB in most browsers). Long PR descriptions could be truncated. Needs URL encoding of the body content.
Implementation: In Step 7's fallback (Rung 2), URL-encode the PR description and append it as &title=...&body=... query parameters to the compare URL.
2. Put the PR description in the commit message body
When a PR has a single commit, GitHub auto-fills the PR description from the commit message body. The skill already creates a single commit in Step 5.
Pros: No URL length limits. Works reliably. Zero extra steps for the user — GitHub just does it.
Cons: Makes commit messages longer (though git log --oneline still works fine). If the branch has multiple commits, GitHub concatenates them which may look messy. Slightly conflates commit message with PR description.
Implementation: In Step 5, append the PR description content (from pr-description.md or inline) to the commit message body, after the Fixes #N line.
3. Use the GitHub REST API directly as a fallback
Instead of giving up after gh pr create fails, try the REST API:
gh api repos/OWNER/REPO/pulls --method POST \
-f head="FORK_OWNER:branch" -f base="main" \
-f title="..." -f body="..." -f draft=truePros: Might succeed where gh pr create (GraphQL) fails, depending on token scopes. Keeps the PR description out of the commit message.
Cons: May fail for the same permission reasons. Adds another step to the fallback ladder.
Recommendation
Option 2 (commit message body) is the most robust — it works regardless of URL length limits and requires no changes to the fallback flow. Option 1 (URL params) is a good complement for cases where the body is short enough. Both could be implemented together.
Option 3 is worth trying but may not solve the underlying permission issue.
Files to Change
.claude/skills/pr/SKILL.md— Update Step 5 (commit) and/or Step 7 fallback (Rung 2)
Context
This came up during a bugfix speedrun on sallyom/claw-installer#31 where the bot pushed the branch successfully but couldn't create the PR, leaving the user to manually copy the description.