Créer une pull request GitHub

VérifiéPrudence

Crée une pull request GitHub à partir de la branche actuelle en analysant l'historique des commits, générant un titre conventionnel et un corps structuré, en poussant vers origin et en soumettant via `gh pr create`. Utile lorsque l'utilisateur veut créer une pull request, ouvrir une PR ou expédier des modifications. Détecte automatiquement la branche de base et vérifie que la branche a des commits en avance et aucun changement non commité.

Spar Skills Guide Bot
DeveloppementIntermédiaire
14002/06/2026
Claude Code
#pull-request#github#git#conventional-commits#automation

Recommandé pour

Notre avis

Crée une pull request GitHub à partir de la branche courante en analysant les commits, générant un titre conventionnel et un corps structuré, puis en soumettant via gh pr create.

Points forts

  • Génère automatiquement un titre et un corps de PR conventionnels à partir de l'historique des commits
  • Valide l'état de la branche (pas sur main, commits en avance, pas de modifications non commitées)
  • Peut enrichir le corps de la PR avec un fichier de spécification optionnel
  • Évite les doublons en détectant les PR existantes pour la branche

Limites

  • Nécessite que gh CLI soit installé et authentifié
  • Ne gère pas les modifications non commitées (demande de commit d'abord)
  • Ne permet pas de revoir ou modifier des PR existantes
Quand l'utiliser

Utilisez cette compétence lorsque vous voulez créer une pull request bien formatée avec un résumé et un plan de test.

Quand l'éviter

Ne l'utilisez pas si vous voulez simplement commiter des changements, pousser sans PR, ou revoir des PR existantes.

Analyse de sécurité

Prudence
Score qualité92/100

The skill automates PR creation using powerful version control and GitHub CLI commands. While it includes safety checks (e.g., branch validation, commit status), pushing to remote carries inherent risk if misused. No destructive or exfiltration commands are present, but the ability to push and create PRs warrants caution.

Points d'attention
  • Executes git push and gh pr create, which can modify remote repositories and potentially push sensitive or untested changes.
  • Reads local files to enrich PR body; could inadvertently include secrets if spec file contains them.

Exemples

Create a PR for current branch
Create a pull request for my current branch.
Open a pull request with spec
Open a PR using specs/feat-auth.md as reference.
Ship it
Ship it

name: pr description: > Creates a GitHub pull request from the current branch by analyzing commits, generating a conventional title and structured body, pushing to origin, and submitting via gh pr create. Use when a user wants to "create a pr", "open a pull request", "submit a pr", "push and create pr", "make a pr", "pr this", or "ship it". Also triggers on "create pull request" or "open pr". Do NOT use for committing changes (use the commit skill). Do NOT use for pushing without a PR (use git push directly). Do NOT use for reviewing existing PRs.

Purpose

Creates a GitHub pull request from the current branch by analyzing commits against the base branch, generating a conventional title and structured body, and submitting via gh pr create.

Variables

  • argument -- Optional spec file path to enrich the PR body with specification context (e.g., specs/feat-auth.md).

Instructions

Step 1: Determine the Base Branch

Identify the default branch:

git remote show origin | grep 'HEAD branch' | sed 's/.*: //'

Use this as the base branch for comparisons. Falls back to main if detection fails.

Step 2: Validate Branch State

Run these checks before proceeding:

git branch --show-current
  • If on the default branch (e.g., main or master), stop and tell the user they need to be on a feature branch.
  • If the branch has no commits ahead of the base branch, stop and tell the user there is nothing to PR.

Check for uncommitted changes:

git status --short
  • If there are uncommitted changes, stop and tell the user to commit first (suggest /commit).

Step 3: Gather Context

Fetch the latest base branch from origin to ensure comparisons are accurate:

git fetch origin <base-branch>

Run these commands to understand the branch:

git log origin/<base-branch>..HEAD --oneline

If a spec path is provided as an argument, read the spec file to enrich the PR body.

Step 4: Generate PR Content

Title: Derive from the commit history. If there is a single commit, use its message. If there are multiple commits, summarize the overall change. Keep under 70 characters.

  • Do not mention AI, Claude, or automated tooling in the title
  • Use lowercase, no period at the end
  • Match conventional commit style when appropriate (e.g., "feat: add user auth")

Body: Use this structure:

## Summary

- [1-3 bullet points describing what changed and why]

## Test plan

- [How the changes were validated -- e.g., "Validation suite passes", specific manual checks, etc.]

If a spec path was provided, add a ## Spec section referencing it.

Step 5: Push and Create PR

Push the branch to origin:

git push -u origin <branch-name>

Create the PR:

gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary

- bullet points here
EOF
)"

Step 6: Report

Print the PR URL returned by gh pr create.

Workflow

  1. Base branch -- Detect the default branch (main/master/etc.)
  2. Validate -- Confirm feature branch, no uncommitted changes, commits ahead of base
  3. Gather -- Fetch latest base, collect commit log, read spec if provided
  4. Generate -- Create conventional title and structured body
  5. Push -- Push branch to origin with tracking, create PR
  6. Report -- Return the PR URL

Cookbook

<If: gh command not found> <Then: tell the user to install GitHub CLI (see https://cli.github.com/) and authenticate with gh auth login>

<If: not authenticated with GitHub> <Then: tell the user to run gh auth login and follow the prompts>

<If: a PR already exists for this branch> <Then: run gh pr view --web to open the existing PR instead of creating a duplicate>

<If: branch has no commits ahead of the base branch> <Then: tell the user there are no changes to PR and check if work was done on a different branch>

<If: invoked with a spec path> <Then: use the spec to write better summary bullets but don't paste the entire spec into the body>

<If: branch has merge conflicts with the base branch> <Then: warn the user about the conflicts. Suggest resolving them before creating the PR, or create the PR anyway and note the conflicts.>

<If: user wants a draft PR> <Then: add --draft flag to the gh pr create command>

<If: changes touch security-sensitive areas (auth, crypto, input handling, secrets)> <Then: consider running the security agent on the diff for a quick vulnerability check before creating the PR.>

Validation

Before creating the PR:

  • Branch is not the default branch (main/master/etc.)
  • No uncommitted changes exist
  • At least one commit exists ahead of the base branch
  • gh auth status succeeds (user is authenticated)
  • Title is under 70 characters
  • Title does not mention "claude", "ai", "automated", or "copilot"

Examples

Example 1: Simple PR from Feature Branch

User says: "create a pr"

Actions:

  1. Check branch: feat/add-auth -- not main, good
  2. Check status: clean working tree
  3. Fetch base, gather: 3 commits ahead
  4. Generate title from commits: "feat: add user authentication"
  5. Generate body with summary
  6. Push and create PR
  7. Report: https://github.com/user/repo/pull/42

Example 2: PR with Spec Reference

User says: "/pr specs/feat-auth.md"

Actions:

  1. Validate branch state
  2. Read specs/feat-auth.md for context
  3. Generate richer PR body incorporating spec details
  4. Push and create PR
  5. Report URL
Skills similaires