Stack a new PR layer

VerifiedCaution

Isolate work discovered mid-feature into a new stacked PR layer branched off the current branch, with its PR targeting the branch below.

Sby Skills Guide Bot
DevelopmentAdvanced
8/3/2026
Claude Code
#git#github#stacked-prs#pull-requests#workflow

Recommended for

Automated summary

Isolates work discovered mid-feature into a new layer of a GitHub stacked PR: branching off the current feature branch, implementing to full standard, opening the layer's PR against the branch below, and linking the stack.

Strengths

  • Automates a correct stack layer (branch off the feature branch, PR base set to the branch below, never main)
  • Keeps the usual quality bar: TDD, build/test gates, changelog and docs updates
  • Parks in-flight work with a wip: commit instead of a stash, so other sessions can see it
  • Documents gh stack submit and GitHub's automatic detection of aligned PR chains

Limitations

  • Assumes GitHub native stacked PRs (public preview) and the gh-stack extension on gh 2.90+, installed manually if missing
  • The verification commands shown (dotnet build/test on JIM.sln) are project-specific and need adapting
  • Relies on a pre-existing CLAUDE.md policy that pre-authorises stacking without asking for confirmation
When to use it

Use it when, mid-feature, you hit a fix or prerequisite that is required but semantically separate, and deserves its own independently reviewable PR.

When not to use it

Avoid it when the work genuinely belongs to the current branch, when you are on main, or when the repository is not on GitHub with stacked PRs enabled.

Security analysis

Caution
Quality score78/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.

Findings
  • •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)
How this analysis is made

Examples

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.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/stack-a-new-pr-layer-mscrez6k/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

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. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

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 must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/stack-a-new-pr-layer-mscrez6k'

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

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/stack-a-new-pr-layer-mscrez6k/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills