create-pr
npx machina-cli add skill flurdy/agent-skills/create-pr --openclawCreate Pull Request
Create a pull request from the current branch using project conventions.
Usage
/create-pr
Instructions
1. Gather Context
Run these commands to understand the current state:
# Get current branch name
git branch --show-current
# Check if branch needs pushing
git status -sb
# Get commits on this branch not on main
git log main..HEAD --oneline
# Get diff summary against main
git diff main...HEAD --stat
2. Extract Jira Ticket from Branch Name
Parse the branch name to find the ticket number:
- Pattern:
{type}/{TICKET-NUMBER}-{description} - Example:
feat/AB-123-sanitize-input→AB-123 - Ticket format: 2-4 uppercase letters, dash, numbers (e.g.,
AB-123,SSP-456)
If no ticket found, ask the user.
3. Look Up Jira Ticket
Use the /jira-ticket skill or the Jira MCP tools directly to get ticket details for the PR description:
mcp__jira__jira_get with:
path: /rest/api/3/issue/{ticketNumber}
jq: "{key: key, summary: fields.summary, description: fields.description}"
4. Generate PR Title
Use conventional commit format based on branch prefix:
| Branch Prefix | PR Title Format |
|---|---|
feat/ | feat(<scope>): <description> |
fix/ | fix(<scope>): <description> |
refactor/ | refactor(<scope>): <description> |
chore/ | chore(<scope>): <description> |
docs/ | docs(<scope>): <description> |
perf/ | perf(<scope>): <description> |
Infer the scope from changed files (e.g., offers-cms, web, api).
5. Generate PR Body
Analyze the actual code changes (use git diff main...HEAD) to write a meaningful description.
Check for a repo-specific PR template at .github/pull-request-template.md or .github/pull_request_template.md. If found, use that format. If not, ask user for confirmation on generating the body ourselves.
6. Push and Create PR
# Push branch with upstream tracking
git push -u origin {branch-name}
# Create the PR targeting main
gh pr create --base main --title "{title}" --body "$(cat <<'EOF'
{body}
EOF
)"
7. Return Result
Output the PR URL so the user can view it.
Source
git clone https://github.com/flurdy/agent-skills/blob/main/skills/create-pr/SKILL.mdView on GitHub Overview
Automates opening a pull request from the active branch following project conventions. It uses the branch name to locate the Jira ticket, fetches ticket details, and builds a PR title and body using the repo’s template, then pushes to origin.
How This Skill Works
The tool gathers context (branch name, status, commits, and diffs) and parses the Jira ticket from the branch name. It queries Jira via mcp__jira__jira_get to retrieve ticket details, then generates a PR title based on the branch prefix (feat/, fix/, etc.) and inferred scope from changed files. It checks for a PR template, constructs the body from git diff against main, pushes the branch to origin, and creates the PR with gh pr create, finally returning the PR URL.
When to Use It
- You’re on a feature or fix branch named with a Jira ticket (e.g., feat/AB-123-some-work) and want to open a PR quickly.
- Your branch includes changes that should be described against the main branch with a conventional-commit style title.
- You want to automatically pull Jira ticket details into the PR description from the ticket’s summary and description.
- Your repository provides a PR template, and you want to ensure the body conforms to it before creating the PR.
- You need to push your branch and create the PR in one workflow, then receive the PR URL for sharing.
Quick Start
- Step 1: Gather context (branch name, status, commits, and diff against main).
- Step 2: Extract Jira ticket from branch name and fetch ticket details; generate PR title based on prefix and scope.
- Step 3: Push the branch to origin and create the PR with gh pr create, then return the PR URL.
Best Practices
- Name branches with a Jira ticket (e.g., feat/AB-123-description) to enable automatic ticket lookup.
- Verify the Jira ticket exists and view its summary before finalizing the PR body.
- Review the git diff against main to keep PRs focused and small.
- Use the repo’s PR template if present; otherwise confirm body generation with the user.
- Push with upstream tracking (-u) and confirm the PR base is main before creating.
Example Use Cases
- Feature branch: feat/AB-123-add-login-rate-limit → PR title: feat(add-login-rate-limit): add login rate limit
- Bugfix branch: fix/SSP-456-handle-null-user → PR title: fix(handle-null-user): properly guard against null user
- Refactor branch: refactor/AB-789-migrate-auth → PR title: refactor(auth): migrate authentication module
- Docs branch: docs/AB-321-update-readme → PR title: docs(readme): update installation steps
- Chore branch: chore/AB-555-deps-sync → PR title: chore(deps): sync dependencies