Skip to content

Add create-pr skill#1141

Open
hemant10yadav wants to merge 1 commit intomainfrom
hy/create-pr
Open

Add create-pr skill#1141
hemant10yadav wants to merge 1 commit intomainfrom
hy/create-pr

Conversation

@hemant10yadav
Copy link
Copy Markdown
Contributor

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

Walkthrough

This pull request adds a new skill definition file that automates pull request creation from the current git branch to main. The workflow performs sequential validation checks (gh authentication, branch verification, existing PR detection), gathers change data (commit history and diffs), reads the PR template, extracts context from branch names and commit messages using ticket pattern matching, generates a PR title following specific formatting constraints, populates the PR body according to the template structure, previews the details, pushes the branch to origin, and creates the PR using the gh CLI.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new create-pr skill to the codebase.
Description check ✅ Passed The description is clearly related to the changeset, explaining the skill's purpose, location, and dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hy/create-pr

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 create fails, line 142's cleanup won't execute. While /tmp files 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.md

Alternatively, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1dda837 and 65190a2.

📒 Files selected for processing (1)
  • .claude/skills/create-pr/SKILL.md

Comment on lines +22 to +28
## 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
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.txt

Option 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.

Copy link
Copy Markdown
Contributor

@zandre-eng zandre-eng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants