Mettre à jour une pull request

VérifiéPrudence

Met à jour une pull request existante en poussant de nouveaux commits, en recalculant la description à partir de tous les commits, et en mettant à jour le titre si nécessaire. Il passe en revue tous les commits de la branche, demande confirmation avant de pousser, et régénère la description en utilisant l'ancienne comme guide de style. Utile pour garder les PRs précises et à jour avec les changements.

Spar Skills Guide Bot
DeveloppementIntermédiaire
9002/06/2026
Claude Code
#pull-request#git#github#pr-update#workflow

Recommandé pour

Notre avis

Met à jour une pull request existante en poussant de nouveaux commits et en régénérant la description.

Points forts

  • Recompose entièrement la description à partir de tous les commits de la branche
  • Respecte le workflow git en demandant confirmation avant de pousser
  • Met à jour le titre uniquement si nécessaire
  • Utilise la description précédente comme guide pour conserver la cohérence

Limites

  • Nécessite que l'outil gh soit installé et configuré
  • Ne fonctionne que pour des PR sur GitHub (pas GitLab, Bitbucket, etc.)
  • Peut ne pas détecter les changements de base de branche
Quand l'utiliser

Lorsque vous avez ajouté des commits à une branche avec une PR ouverte et souhaitez mettre à jour automatiquement la description.

Quand l'éviter

Si vous voulez seulement pousser sans changer la description, ou si la PR concerne un service autre que GitHub.

Analyse de sécurité

Prudence
Score qualité85/100

The skill runs bash commands that push to remote and update PR descriptions. It includes a confirmation step, reducing risk. Legitimate use case but requires network access and repository write permissions.

Points d'attention
  • Uses powerful git and gh commands that modify the remote repository, including git push and gh pr edit. However, user confirmation is required before push.

Exemples

Update PR with new commits
I just pushed a fix for the login validation to my branch. Update the PR description to reflect all changes.
Push and update PR description
I have two new commits on this branch that haven't been pushed yet. Please push them and regenerate the PR description based on all commits.
Refresh PR title and body
Update the PR number 42 with all my recent changes. Rewrite the description but keep the format similar to the current one.

name: update-pr description: Update existing pull request with new commits

Update Pull Request

Push new commits to an existing pull request and optionally update its description.

Workflow

  1. Verify branch and PR: Ensure you're on a branch with an existing PR
  2. Review all commits: Show all commits that will be in the PR
  3. Ask user for confirmation: Before pushing, show what will be pushed and ask for confirmation
  4. Push any unpushed changes: Push any new commits to origin if user confirms
  5. Recompute PR description: Generate a fresh PR description based on all commits, using the previous description as a guide
  6. Update PR: Update both title (if needed) and description
  7. Return PR URL: Show the updated PR URL

Instructions

  1. Check current branch and PR status:

    git branch --show-current
    gh pr view --json number,title,url,baseRefName,body
    
    • If no PR exists, inform user and suggest using /create-pr instead
    • If on main/master, stop and ask user to switch branches
    • Store the current title and body for reference
  2. Review ALL commits in the branch (not just unpushed ones):

    # Get all commits in this branch compared to the base branch
    git log <base-branch>..HEAD --oneline
    
    # Also check if there are unpushed commits
    git log origin/<current-branch>..HEAD --oneline
    
    • Show all the commits that are part of this PR
    • Note if there are unpushed commits that need to be pushed
  3. ASK USER before pushing any unpushed commits:

    • Show user what commits will be pushed (from step 2)
    • Ask: "Ready to push these commits to update the PR?"
    • Wait for user confirmation
    • This respects the user's git workflow rules
  4. Push any unpushed commits (if user confirmed):

    git push
    
    • Only run this if there were unpushed commits AND user confirmed
    • If already up to date, skip this step
  5. Analyze all changes and recompute PR description:

    • Review ALL commits in the branch (from step 2)
    • Look at the previous PR description and title as a guide
    • Generate a fresh, comprehensive PR description that:
      • Accurately reflects ALL changes in the branch
      • Follows the same format/style as the previous description
      • Uses concise bullet points
      • Groups related changes together
      • Is complete but not verbose
    • Consider if the title needs updating to better reflect the scope
  6. Update the PR:

    # Update title if needed
    gh pr edit <pr-number> --title "New Title"
    
    # Update description
    gh pr edit <pr-number> --body "$(cat <<'EOF'
    ## Summary
    - First main change
    - Second main change
    - Additional improvements
    EOF
    )"
    
    • Always update the description
    • Only update the title if the current one doesn't accurately reflect the changes
  7. Return the PR URL and summary of what was done

Key Principles

  • Complete recomputation: Generate the description from scratch based on ALL commits
  • Use previous as guide: Keep similar format and style from the previous description
  • Smart title updates: Only change title if it's no longer accurate
  • Account for pushed commits: Handle cases where commits were already pushed
  • Clear and comprehensive: Description should cover everything in the branch
  • Concise format: Keep it readable with bullet points, no unnecessary detail
  • Respect git workflow: Always ask user before pushing (per user's git workflow rules)

Example Output

✅ Found PR #123: "Add user authentication"

📝 All commits in this branch:
   - abc1234 Initial authentication setup
   - def5678 Add JWT token support
   - 789abcd Fix login validation
   - 012cdef Add password reset

📤 Unpushed commits: 2
   - 789abcd Fix login validation
   - 012cdef Add password reset

🚀 Pushing commits...
✅ Pushed to origin

🔄 Recomputing PR description based on all commits...
✅ Updated PR #123:
   - Title: "Add user authentication" (unchanged)
   - Description: Updated to reflect all changes

PR URL: https://github.com/org/repo/pull/123
Skills similaires