Empiler une nouvelle couche de PR

VérifiéPrudence

Isole le travail découvert en cours de fonctionnalité dans une nouvelle couche de PR empilée, créée à partir de la branche courante, avec une PR vers la branche inférieure.

Spar Skills Guide Bot
DeveloppementAvancé
03/08/2026
Claude Code
#git#github#stacked-prs#pull-requests#workflow

Recommandé pour

Synthèse automatique

Isole le travail découvert en cours de fonctionnalité dans une nouvelle couche de PR empilée GitHub : création d'une branche depuis la branche courante, implémentation complète, PR ciblant la couche inférieure et liaison de la pile.

Points forts

  • Automatise la création d'une couche de pile cohérente (branche depuis la feature, PR avec base = branche du dessous, jamais main)
  • Conserve les exigences de qualité habituelles : TDD, gates de build/test, changelog et docs
  • Gère le parking du travail en cours via un commit wip: plutôt qu'un stash, visible par les autres sessions
  • Documente la commande gh stack submit et la reconnaissance automatique des chaînes alignées par GitHub

Limites

  • Suppose l'aperçu public des stacked PR natives GitHub et l'extension gh-stack (gh 2.90+), à installer si absente
  • Les commandes de vérification citées (dotnet build/test sur JIM.sln) sont propres à un projet et à adapter
  • Repose sur une politique CLAUDE.md préexistante qui autorise implicitement l'empilement sans demander confirmation
Quand l'utiliser

À utiliser lorsqu'en cours de feature vous découvrez un correctif ou un prérequis nécessaire mais sémantiquement distinct, qui mérite sa propre PR relue isolément.

Quand l'éviter

À ne pas utiliser si le travail fait partie intégrante de la branche courante, si vous êtes sur main, ou si le dépôt n'est pas hébergé sur GitHub avec les stacked PR activées.

Analyse de sécurité

Prudence
Score qualité78/100

Nothing here is destructive or exfiltration-oriented: the commands are ordinary git/gh operations for branching, committing, pushing, and opening stacked PRs, and no secrets are sent anywhere. Risk is moderate rather than safe because the skill drives bash and network tooling for legitimate purposes, uses blanket `git add -A` staging that could capture unintended/sensitive files, and installs a CLI extension unattended while deliberately skipping user confirmation.

Points d'attention
  • •Instructs `git add -A && git commit` to auto-park WIP, which can sweep unrelated or sensitive files (e.g. .env, credentials) into a commit without review
  • •Installs a GitHub CLI extension from the network (`gh extension install github/gh-stack`) if missing, a supply-chain surface the agent triggers unattended
  • •Runs git/gh commands that push branches and create PRs against remotes, altering shared repository state without a confirmation step (explicitly told not to ask the user)
Comment cette analyse est faite

Exemples

Bug found mid-feature
While building the CSV connector I found a character-encoding bug in the parser. Stack it as the next PR layer: fix: correct encoding handling.
Prerequisite refactor
The import feature needs a config loader that doesn't exist yet. Stack a layer for it on top of feature/csv-connector and implement it with tests.
From conversation context
/stack-pr

name: stack-pr description: Isolate work discovered mid-feature into the next layer of a GitHub stacked PR; branch off the current feature branch, implement to full standard, open the layer's PR against the branch below, link the stack, and carry on. argument-hint: "[one-line description of the discovered work]"

Stack a new PR layer on the current feature branch

This skill implements the policy in CLAUDE.md ("Stacked PRs for discovered work"): something has been found mid-feature that must be solved to deliver the objective but is not semantically part of the current branch's work. It gets its own layer in a GitHub native stacked PR (public preview), never folded into the feature branch, never deferred to an issue.

A stack is a sequential chain: each layer branches off the branch below it, each PR targets the branch below it, and only the bottom PR targets main. Merging is bottom-up; merging an upper PR atomically merges everything below it, each PR recorded individually.

If $ARGUMENTS is non-empty, treat it as the description of the discovered work; otherwise derive one from the conversation context. Announce it to the user in one line and proceed; do not ask whether to stack (the policy pre-authorises it). If the work itself is architecturally significant with multiple sensible approaches, the CLAUDE.md "Ask before significant changes" rule applies to the approach, not to the decision to stack.

0. One-time setup

The gh stack CLI is an extension (requires gh 2.90+). The devcontainer installs it automatically (.devcontainer/setup.sh); if it is missing (e.g. the install was skipped because gh was not yet authenticated):

gh extension list | grep -q gh-stack || gh extension install github/gh-stack

1. Park the current work

git status
git branch --show-current
  • You MUST be on a feature branch. If on main, stop; there is nothing to stack on.
  • If the tree is dirty, commit the WIP to the current branch: git add -A && git commit -m "wip: park work before stacking next layer". Prefer a wip: commit over stashing; squash-merge collapses it on landing, and a stash is invisible to other sessions.
  • Push the current branch so the chain's lower layer exists on the remote: git push (or git push -u origin <branch> if never pushed).

2. Create the layer off the current branch

git checkout -b feature/<feature-suffix>-stack-<desc>
  • Branch from the current feature branch, never from main; the layer must sit on top of the work below it.
  • <feature-suffix> is the feature branch name without its feature/ prefix; <desc> is a short kebab-case description. Example: on feature/csv-connector, an encoding bug becomes feature/csv-connector-stack-fix-encoding.
  • Alternatively gh stack add feature/<feature-suffix>-stack-<desc> creates and tracks the branch in one step if the stack is already initialised.

3. Implement the layer to full standard

Being unplanned lowers no bars. All CLAUDE.md rules apply:

  • TDD (failing test first; for a bug the test must reproduce it before the fix).
  • Build/test gates: targeted during the loop, dotnet build JIM.sln and dotnet test JIM.sln clean before the PR (or the documented non-code exceptions).
  • Changelog entry under [Unreleased] plus public docs if the change is user-facing.
  • Commit with a clear message and push: git push -u origin feature/<feature-suffix>-stack-<desc>.

4. Open the layer's PR and link the stack

Follow /pr-merge conventions (title under 70 chars, JIM body template), with the base set to the branch below, NOT main:

gh pr create --base feature/<feature> --title "fix: <desc>" --body "..."
  • GitHub recognises aligned chains (each PR's base is the head of the PR below) and shows a banner offering to link them into a stack; accept it. With the gh stack CLI, gh stack submit pushes the layers and creates linked PRs in one step.
  • Reviewers see only this layer's diff. CI and all of main's branch protections run for every PR in the stack.
  • Do NOT queue --auto: auto-merge is unsupported for stacked PRs. Landing is handled by /pr-merge when the objective is complete.

5. Continue work in the right layer

Code may only depend on its own layer or a lower one:

  • Remaining feature work needs this layer's code → continue in a new layer on top: gh stack add (or branch off this layer), and repeat this pattern.
  • Remaining feature work is independent of this layer → git checkout feature/<feature> and continue below. Any change to a lower layer breaks the stack's linearity; restack before merging with the web "Rebase stack" button, or locally:
    gh stack rebase
    gh stack push
    

6. Landing

Use /pr-merge; its "Stacked PRs" section covers the differences (rebase to stay current, no auto-merge, bottom-up atomic merge, merging from the top when the objective is done, cleanup of layer branches).

Notes and edge cases

  • Stacks require all branches in the same repository and fully linear history between layers; within a stack, rebase (cascading) replaces the usual merge-don't-rebase rule.
  • Keep layers shallow and single-concern; a discovery inside a layer gets its own layer the same way.
  • Layer branches belong to the same session and objective as the feature branch; the -stack- naming keeps the lineage visible across parallel sessions.
  • The discovery is NOT needed to deliver the objective → this skill does not apply. File an issue with native blocked-by/sub-issue links per CLAUDE.md and stay on the feature.

End the skill on a one-line status: layer branch name, its PR number and base, and which layer work is continuing in.

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/stack-a-new-pr-layer-mscrez6k/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/stack-a-new-pr-layer-mscrez6k' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/stack-a-new-pr-layer-mscrez6k/download' --output '.skill-downloads/stack-a-new-pr-layer-mscrez6k/SKILL.md.part' && mv '.skill-downloads/stack-a-new-pr-layer-mscrez6k/SKILL.md.part' '.skill-downloads/stack-a-new-pr-layer-mscrez6k/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/stack-a-new-pr-layer-mscrez6k/SKILL.md' && test -s '.skill-downloads/stack-a-new-pr-layer-mscrez6k/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/stack-pr' && cp -R '.skill-downloads/stack-a-new-pr-layer-mscrez6k' '.claude/skills/stack-pr'

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/stack-a-new-pr-layer-mscrez6k'

openskills read 'stack-a-new-pr-layer-mscrez6k'

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/stack-a-new-pr-layer-mscrez6k/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