feat(create-pr): detect and use PR template when present - #551
Conversation
📝 WalkthroughWalkthroughUpdates documentation for the PR creation workflow to detect and use PR templates when available, with sections filled from actual changes and fallback to default format if no template is found. Step sequencing adjusted accordingly. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@plugins/me/skills/create-pr/SKILL.md`:
- Around line 38-41: Update the "detect PR template (check in order)"
documentation to list all GitHub-supported template locations and behaviors:
check for templates in both top-level and .github directories, support dedicated
template directories (e.g., PULL_REQUEST_TEMPLATE/ and
.github/PULL_REQUEST_TEMPLATE/) and multiple templates within subdirectories,
and note that filenames are case-insensitive; also mirror this change where "PR
Body Format" is documented so both sections reflect the same discovery order and
case-insensitivity.
- Around line 43-46: The current PR creation uses an inline --body "<filled
body>" which breaks on multiline/markdown content; update the PR creation step
that sets PR_URL via the gh pr create invocation to pass the body via
--body-file (either write the filled template to a temporary file and pass its
path, or stream it via --body-file -) instead of --body, ensuring the command
handles multiline markdown, quotes, and backticks robustly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1490f43c-e0ec-4c88-81b5-94c4eafda130
📒 Files selected for processing (1)
plugins/me/skills/create-pr/SKILL.md
| # 5) detect PR template (check in order) | ||
| # .github/PULL_REQUEST_TEMPLATE.md → PULL_REQUEST_TEMPLATE.md → default format | ||
| # If found: read it, fill each section with actual change details, preserve empty checkboxes (- [ ]) as-is | ||
| # If not found: use default format (see PR Body Format below) |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
What file locations and naming patterns does GitHub currently support for pull request templates (single and multiple templates)?
💡 Result:
Single pull request template (auto-applied)
GitHub will use a single default PR template if you add one of these files (filenames are not case sensitive) on the repository’s default branch:
pull_request_template.md(repository root) [1]docs/pull_request_template.md[1].github/pull_request_template.md[1]
PR template files are not case sensitive and can use extensions like .md or .txt. [2]
Multiple pull request templates (select via URL parameter)
GitHub supports multiple PR templates by placing template files in a PULL_REQUEST_TEMPLATE/ subdirectory (on the default branch) under any of these locations:
PULL_REQUEST_TEMPLATE/<template-file>(repository root) [1]docs/PULL_REQUEST_TEMPLATE/<template-file>[1].github/PULL_REQUEST_TEMPLATE/<template-file>[1]
To use a specific one, pass its filename via the template query parameter when opening a PR, e.g. ...&template=<template-file>. The template parameter works with templates stored in those PULL_REQUEST_TEMPLATE subdirectories. [3]
Example path (from GitHub docs): .github/PULL_REQUEST_TEMPLATE/pull_request_template.md [1]
Sources: [1] GitHub Docs (Creating a pull request template) (docs.github.com), [2] GitHub Docs (About issue and pull request templates) (docs.github.com), [3] GitHub Docs (Using query parameters to create a pull request) (docs.github.com)
Citations:
- 1: https://docs.github.com/en/enterprise-server%403.16/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository
- 2: https://docs.github.com/enterprise-cloud%40latest/communities/using-templates-to-encourage-useful-issues-and-pull-requests/manually-creating-a-single-issue-template-for-your-repository
- 3: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/using-query-parameters-to-create-a-pull-request
Broaden PR template discovery to match GitHub-supported locations.
The current documentation (lines 38–41 and 67–71) documents only .github/PULL_REQUEST_TEMPLATE.md and PULL_REQUEST_TEMPLATE.md, which omits valid template locations supported by GitHub. Additionally, GitHub treats template filenames as case-insensitive and supports multiple templates via subdirectories.
Suggested documentation update
-# .github/PULL_REQUEST_TEMPLATE.md → PULL_REQUEST_TEMPLATE.md → default format
+# GitHub searches in order (case-insensitive):
+# .github/PULL_REQUEST_TEMPLATE/*.md (multiple templates)
+# .github/pull_request_template.md (single template)
+# PULL_REQUEST_TEMPLATE/*.md (multiple templates, repo root)
+# pull_request_template.md (single template, repo root)
+# docs/PULL_REQUEST_TEMPLATE/*.md (multiple templates)
+# docs/pull_request_template.md (single template)
+# Then: default formatAlso applies to: 67–71
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/me/skills/create-pr/SKILL.md` around lines 38 - 41, Update the
"detect PR template (check in order)" documentation to list all GitHub-supported
template locations and behaviors: check for templates in both top-level and
.github directories, support dedicated template directories (e.g.,
PULL_REQUEST_TEMPLATE/ and .github/PULL_REQUEST_TEMPLATE/) and multiple
templates within subdirectories, and note that filenames are case-insensitive;
also mirror this change where "PR Body Format" is documented so both sections
reflect the same discovery order and case-insensitivity.
| # 6) create PR (do not hardcode --base main) | ||
| # Body: filled template or default format | ||
| PR_URL=$(gh pr create --title "$(git log -1 --pretty=%s)" --body "<filled body>") | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In GitHub CLI (gh pr create), what is the recommended way to pass multiline PR body content safely: --bodyor--body-file?
💡 Result:
Use --body-file (or --body-file - to read from stdin) for multiline PR bodies; it avoids fragile shell quoting/escaping that you’d hit trying to cram newlines into --body. [1], [2]
Example (heredoc):
gh pr create --title "My PR" --body-file - <<'EOF'
Line 1
Line 2
- Bullet
EOFSources: [1] GitHub CLI manual: gh pr create (--body-file reads from file / - stdin). [2] Example using --body-file - for multiline input.
Use --body-file instead of inline --body for filled templates.
Line 45's inline --body "<filled body>" is fragile for multiline markdown, quotes, and backticks from real templates. Pass PR body content via --body-file (reading from a temp file or stdin with --body-file -):
Suggested pattern
-PR_URL=$(gh pr create --title "$(git log -1 --pretty=%s)" --body "<filled body>")
+PR_URL=$(gh pr create --title "$(git log -1 --pretty=%s)" --body-file "$TMP_PR_BODY_FILE")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@plugins/me/skills/create-pr/SKILL.md` around lines 43 - 46, The current PR
creation uses an inline --body "<filled body>" which breaks on
multiline/markdown content; update the PR creation step that sets PR_URL via the
gh pr create invocation to pass the body via --body-file (either write the
filled template to a temporary file and pass its path, or stream it via
--body-file -) instead of --body, ensuring the command handles multiline
markdown, quotes, and backticks robustly.
# [5.43.0](v5.42.2...v5.43.0) (2026-03-13) ### Features * **create-pr:** detect and use PR template when present ([#551](#551)) ([014dbd1](014dbd1))
Summary
Add PR template detection to the
create-prskill. When a project defines a standard PR template, the skill now uses it instead of the hardcoded default format.Changes
.github/PULL_REQUEST_TEMPLATE.mdorPULL_REQUEST_TEMPLATE.md- [ ]) in templates are preserved as-isTests
Verified SKILL.md reads correctly with updated workflow and PR Body Format section.
Breaking
None.
Summary by CodeRabbit