Création de backports

VérifiéPrudence

Créer des backports d'une pull request GitHub fusionnée dans devel vers des branches stables via git cherry-pick.

Spar Skills Guide Bot
DevOpsIntermédiaire
29/08/2026
Claude CodeCodex
#git#backports#github-cli#cherry-pick#release-management

Recommandé pour

Synthèse automatique

Guide un agent dans le rétroportage d’une pull request GitHub fusionnée en amont, en appliquant son commit de fusion par cherry-pick sur des branches stables choisies et en ouvrant les PR de backport.

Points forts

  • Vérifie que la PR est bien fusionnée dans devel et récupère le SHA du commit de fusion avec gh.
  • Applique une politique de backport selon le type de correctif et confirme les branches stables cibles avec l’utilisateur.
  • S’arrête en cas de conflit de cherry-pick et demande une résolution manuelle au lieu de continuer.
  • Pousse vers le fork de l’utilisateur et crée les pull requests de backport avec gh.

Limites

  • Suppose que gh est authentifié et que les remotes upstream/origin sont correctement configurés.
  • Dépend d’une politique de backport définie dans context/contributing.md, propre au dépôt.
  • Les conflits de cherry-pick nécessitent une intervention manuelle et bloquent la suite du workflow.
Quand l'utiliser

À utiliser lorsqu’un correctif déjà fusionné dans devel doit être répliqué sur une ou plusieurs branches stables via une PR de backport.

Quand l'éviter

À ne pas utiliser pour une PR non fusionnée, pour un problème de sécurité qui doit être signalé en privé, ou dans un dépôt sans convention de branches stables ni de backport.

Analyse de sécurité

Prudence
Score qualité86/100

The skill drives real git and gh operations (fetch, checkout, cherry-pick, push, pr create) against a repository, so it is not purely informational and warrants caution. However, it is defensively written: it aborts on conflicts instead of forcing through, explicitly forbids pushing to the upstream remote, requires user confirmation at key steps, and handles security issues by directing to a private email rather than GitHub. No exfiltration, obfuscated payloads, secret access, or destructive commands (rm -rf, reset --hard, force-push) are present.

Points d'attention
  • •Uses git and the GitHub CLI (gh) for branch creation, cherry-pick, and pushing branches to a remote repository
  • •Runs `git pull --rebase <upstream> devel` when syncing devel, which rewrites local unpushed commits on the branch
  • •Creates and pushes branches and opens pull requests on the user's fork — mutating remote state, though the skill explicitly warns against pushing to upstream and asks for confirmation
Comment cette analyse est faite

Exemples

Backport a merged fix
Backport PR #1234 from the upstream repository to the latest stable branch. Verify it merged into devel, create the backport branch, cherry-pick the merge commit, push to my fork, and open the PR.
Critical fix to two stable branches
This is a critical bug fix in PR #5678 that merged into devel. Create backports to the latest and previous stable branches, and stop if any cherry-pick conflicts.
Check backport policy first
Can you help me backport merged PR #9012? First check context/contributing.md for the backport policy and confirm which stable branches are appropriate.

name: creating-backports description: Create backports of a GitHub pull request that has merged into the devel branch in the upstream repository user-invocable: true

Creating Backports

Backport creation workflow

Backporting Progress:
- [ ] Step 1: Verify the referenced pull request
- [ ] Step 2: Identify the git remote for the upstream repository
- [ ] Step 3: Determine the stable branches for the backport
- [ ] Step 4: Create the backport branches
- [ ] Step 5: Create pull requests
- [ ] Step 6: Summarize the work

Step 1: Verify the referenced pull request

Use gh pr view <number> to verify the PR is merged into devel and get the merge commit SHA: gh pr view <number> --json mergeCommit -q .mergeCommit.oid

Abort if the PR is not merged or merged to wrong branch.

Step 2: Identify the git remote for the upstream repository

Identify the upstream remote (typically named upstream). If it doesn't exist, offer to create it.

Sync the local devel branch with the identified upstream remote:

  • git fetch <upstream_remote>
  • git checkout devel
  • git pull --rebase <upstream_remote> devel

Step 3: Determine the stable branches for the backport

Refer to the backport policy in context/contributing.md:

  • Bug fixes: backported to latest stable only
  • Critical bug fixes: backported to latest and previous stable
  • Security issues: must be reported to security@ansible.com privately (not via GitHub)

Ask the user what type of fix this is and confirm the target branches before proceeding.

To identify available stable branches, run: git ls-remote --heads <upstream_remote> 'refs/heads/stable-*'

Step 4: Create the backport branches

Before creating backport branches, verify you're not on a branch you want to keep (the workflow will create and switch between multiple branches).

First, ensure stable branches are up to date:

  • Run git fetch <upstream_remote> to get latest stable branch refs

The backport process consists of these steps:

  1. Create a new branch for each stable branch: git checkout -b backport/VERSION/PR_NUMBER <upstream_remote>/STABLE_BRANCH Example: git checkout -b backport/2.20/1234 upstream/stable-2.20 (if upstream remote is named upstream)
  2. Cherry-pick the MERGE commit from the referenced pull request into each branch using the -x option. (The merge commit SHA was obtained in Step 1 with gh pr view) Example: git cherry-pick -x <merge_commit_sha> If merge conflicts are encountered:
    • Run git cherry-pick --abort to abort the cherry-pick
    • Notify the user that manual conflict resolution is required for this stable branch
    • Explain the user can either: a) Manually resolve conflicts (you can help guide them) b) Skip this stable branch backport
    • Do NOT continue with remaining branches if conflicts occur - wait for user direction
  3. Before pushing, identify the user's fork remote:
    • Typically named origin
    • Verify with git remote -v that it points to the user's fork, not upstream
    • Confirm the remote name before pushing
  4. Push each backport branch to the user's fork remote (identified in step 3, typically origin): git push <fork_remote> backport/VERSION/PR_NUMBER Example: git push origin backport/2.20/1234 (if fork remote is named origin) Never push to the upstream remote - this would push directly to the upstream repository.

Step 5: Create pull requests

Confirm with the user that they would like to create a pull request for each backport branch.

Use gh pr create for each branch:

  • --base STABLE_BRANCH_NAME (the stable branch being backported to)
  • --title "[STABLE_BRANCH_NAME] ORIGINAL_PR_TITLE"
  • --body "Backport of PR #XXXX\n\n(cherry picked from commit COMMIT_HASH)"

Example: gh pr create --base stable-2.20 --title "[stable-2.20] Fix bug in module" --body "Backport of PR #1234\n\n(cherry picked from commit abc123)"

Step 6: Summarize the work

Give the user a summary of the backports that were created. The summary must provide a list of the URL links to all pull requests that were created.

Error Recovery

If errors occur during the backport process:

  • Cherry-pick conflicts: List which branches succeeded and which failed due to conflicts
  • PR creation failures: Clean up any orphaned branches that weren't converted to PRs
  • Partial success: Summarize what succeeded and offer to retry failed branches individually

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/creating-backports-mte1lfmw/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/creating-backports-mte1lfmw' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/creating-backports-mte1lfmw/download' --output '.skill-downloads/creating-backports-mte1lfmw/SKILL.md.part' && mv '.skill-downloads/creating-backports-mte1lfmw/SKILL.md.part' '.skill-downloads/creating-backports-mte1lfmw/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/creating-backports-mte1lfmw/SKILL.md' && test -s '.skill-downloads/creating-backports-mte1lfmw/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/creating-backports' && cp -R '.skill-downloads/creating-backports-mte1lfmw' '.claude/skills/creating-backports'

Codex
test -f '.skill-downloads/creating-backports-mte1lfmw/SKILL.md' && test -s '.skill-downloads/creating-backports-mte1lfmw/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/creating-backports' && cp -R '.skill-downloads/creating-backports-mte1lfmw' '.agents/skills/creating-backports'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/creating-backports-mte1lfmw'

openskills read 'creating-backports-mte1lfmw'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/creating-backports-mte1lfmw/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires