Add create-pr skill#1141
Conversation
WalkthroughThis pull request adds a new skill definition file that automates pull request creation from the current git branch to Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
.claude/skills/create-pr/SKILL.md (2)
136-143: Consider ensuring cleanup happens even on failure.If
gh pr createfails, line 142's cleanup won't execute. While/tmpfiles are typically ephemeral, it's better practice to ensure cleanup.♻️ Proposed improvement
cat > /tmp/pr-body.md <<'EOF' <body> EOF -gh pr create --base main --title "<title>" --body-file /tmp/pr-body.md [--draft] - -rm -f /tmp/pr-body.md +gh pr create --base main --title "<title>" --body-file /tmp/pr-body.md [--draft] || { + rm -f /tmp/pr-body.md + exit 1 +} +rm -f /tmp/pr-body.mdAlternatively, use a trap to ensure cleanup:
trap 'rm -f /tmp/pr-body.md' EXIT🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.claude/skills/create-pr/SKILL.md around lines 136 - 143, The script currently writes /tmp/pr-body.md then calls gh pr create and only removes the temp file after that, which will be skipped if gh fails; set a shell trap for EXIT (e.g., using trap 'rm -f /tmp/pr-body.md' EXIT) immediately after creating the temp file so the file is always removed on script exit, and optionally keep or remove the explicit rm -f /tmp/pr-body.md after gh pr create; ensure the trap references the same temp filename (/tmp/pr-body.md) and is installed before invoking gh pr create.
38-44: Clarify execution order.The "run in parallel" comment may be misleading. While these commands don't depend on each other, Step 2's validation (line 46) requires checking the git log output to determine if there are commits ahead. Consider removing the parallel execution note for clarity.
📝 Proposed fix
-## Step 2 — Gather diff (run in parallel) +## Step 2 — Gather diff🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.claude/skills/create-pr/SKILL.md around lines 38 - 44, Update the "Step 2 — Gather diff (run in parallel)" header and accompanying text to remove or reword the "run in parallel" claim and clarify execution order: state that the three commands (git log main..HEAD --no-merges --oneline, git diff main...HEAD --stat, git diff main...HEAD) can be run in any order for viewing diffs, but the subsequent validation step relies on the git log output to detect commits ahead, so ensure the doc (header or a short note) instructs running the git log before the validation check. Use the existing "Step 2 — Gather diff" header text to locate and update the wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.claude/skills/create-pr/SKILL.md:
- Around line 22-28: The header "Step 1 — Pre-checks (run in parallel)" is
misleading because the commands depend on each other; update the header or
comment to reflect sequential execution and/or reorder the instructions so
dependencies are explicit: ensure "git branch --show-current" runs before the
"gh pr list --head \"$(git branch --show-current)\" --state open --json
number,url" command, and change "run in parallel" to "run sequentially" or add a
note that the third command depends on the second; reference the Step 1 header
and the three commands (gh auth status, git branch --show-current, gh pr list
--head ...) when making this edit.
- Line 140: The gh command string using --title "<title>" will break if the
generated title contains double quotes; instead write the generated title to a
temp file (e.g., /tmp/pr-title) and pass it safely to gh (for example use
--title "$(cat /tmp/pr-title)" or use shell escaping like printf %q to escape
the title) and keep --body-file /tmp/pr-body.md for the body; update the
invocation that builds the command (the string containing gh pr create --base
main --title "<title>" --body-file /tmp/pr-body.md [--draft]) to read the title
from the temp file or use proper shell-escaped quoting so embedded quotes in the
title do not break the command.
---
Nitpick comments:
In @.claude/skills/create-pr/SKILL.md:
- Around line 136-143: The script currently writes /tmp/pr-body.md then calls gh
pr create and only removes the temp file after that, which will be skipped if gh
fails; set a shell trap for EXIT (e.g., using trap 'rm -f /tmp/pr-body.md' EXIT)
immediately after creating the temp file so the file is always removed on script
exit, and optionally keep or remove the explicit rm -f /tmp/pr-body.md after gh
pr create; ensure the trap references the same temp filename (/tmp/pr-body.md)
and is installed before invoking gh pr create.
- Around line 38-44: Update the "Step 2 — Gather diff (run in parallel)" header
and accompanying text to remove or reword the "run in parallel" claim and
clarify execution order: state that the three commands (git log main..HEAD
--no-merges --oneline, git diff main...HEAD --stat, git diff main...HEAD) can be
run in any order for viewing diffs, but the subsequent validation step relies on
the git log output to detect commits ahead, so ensure the doc (header or a short
note) instructs running the git log before the validation check. Use the
existing "Step 2 — Gather diff" header text to locate and update the wording.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8c03a309-7f29-4845-94aa-634dd0ed544a
📒 Files selected for processing (1)
.claude/skills/create-pr/SKILL.md
| ## Step 1 — Pre-checks (run in parallel) | ||
|
|
||
| ```bash | ||
| gh auth status | ||
| git branch --show-current | ||
| gh pr list --head "$(git branch --show-current)" --state open --json number,url | ||
| ``` |
There was a problem hiding this comment.
Remove or clarify the "run in parallel" comment.
Line 27 depends on the output of line 26 (git branch --show-current), so these commands cannot run in true parallel. The current dependency chain requires sequential execution: line 26 must complete before line 27 runs.
📝 Proposed fix
-## Step 1 — Pre-checks (run in parallel)
+## Step 1 — Pre-checks🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.claude/skills/create-pr/SKILL.md around lines 22 - 28, The header "Step 1 —
Pre-checks (run in parallel)" is misleading because the commands depend on each
other; update the header or comment to reflect sequential execution and/or
reorder the instructions so dependencies are explicit: ensure "git branch
--show-current" runs before the "gh pr list --head \"$(git branch
--show-current)\" --state open --json number,url" command, and change "run in
parallel" to "run sequentially" or add a note that the third command depends on
the second; reference the Step 1 header and the three commands (gh auth status,
git branch --show-current, gh pr list --head ...) when making this edit.
| <body> | ||
| EOF | ||
|
|
||
| gh pr create --base main --title "<title>" --body-file /tmp/pr-body.md [--draft] |
There was a problem hiding this comment.
Fix title quoting to handle special characters.
If the generated title contains double quotes, the current quoting will break the gh pr create command. Use proper escaping or alternative quoting.
🔧 Proposed fix
Option 1: Write title to the temp file as the first line, then use --title with a safer method:
-gh pr create --base main --title "<title>" --body-file /tmp/pr-body.md [--draft]
+# Write title and body to temp file, then extract
+echo "<title>" > /tmp/pr-title.txt
+gh pr create --base main --title "$(cat /tmp/pr-title.txt)" --body-file /tmp/pr-body.md [--draft]
+rm -f /tmp/pr-title.txtOption 2: Escape the title properly in the shell command or use printf %q for proper escaping.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.claude/skills/create-pr/SKILL.md at line 140, The gh command string using
--title "<title>" will break if the generated title contains double quotes;
instead write the generated title to a temp file (e.g., /tmp/pr-title) and pass
it safely to gh (for example use --title "$(cat /tmp/pr-title)" or use shell
escaping like printf %q to escape the title) and keep --body-file
/tmp/pr-body.md for the body; update the invocation that builds the command (the
string containing gh pr create --base main --title "<title>" --body-file
/tmp/pr-body.md [--draft]) to read the title from the temp file or use proper
shell-escaped quoting so embedded quotes in the title do not break the command.
zandre-eng
left a comment
There was a problem hiding this comment.
I do see the Connect mobile "create-pr" skill is in the dimagi Claude repo here. It could be nice to have the web one there as well for consistency, but happy to keep it in the connect repo if the rest of the team agrees.
Otherwise, the changes look good. Just some minor comments.
|
|
||
| From the branch name and diff: | ||
|
|
||
| - **Jira ticket**: look for `CCCT-\d+` or `CI-\d+` in the branch name or in commit messages (case-insensitive). If found, record as `TICKET` (e.g. `CCCT-2276`). |
There was a problem hiding this comment.
If not found, do we want to prompt the user to provide the ticket number? Otherwise, Claude won't be able to insert a link to the ticket.
|
|
||
| **Product Description** — what a user sees or gains. If no user-facing change: `No user-facing changes.` | ||
|
|
||
| **Technical Summary** — 2–4 sentences on what changed and why. If `TICKET` was found: add `Ticket: [<TICKET>](https://dimagi.atlassian.net/browse/<TICKET>)` as the first line. |
There was a problem hiding this comment.
Do we want to prompt the user for the release path type, so that it can be added here as well?
|
|
||
| Section guidance: | ||
|
|
||
| **Product Description** — what a user sees or gains. If no user-facing change: `No user-facing changes.` |
There was a problem hiding this comment.
Curious to hear your thoughts on letting Claude add <insert screenshot of x> in the product description where applicable so that the dev can easily see if they should add supporting screenshots of UI changes.
Added a create-pr skill as discussed during the Connect Summit.
I’ve kept it within this project repo instead of the Dimagi Claude workflows for now—happy to move it there if the team prefers it not to live in the project repo.
Note: This requires the GitHub CLI (gh) to be installed for the skill to work properly.