/jj:jj-gh-stackfrom jj
Manages GitHub stacked PRs from a Jujutsu (jj) repository using gh stack CLI. Replaces git-centric workflow with jj bookmarks and jj git push.
Ships in jj. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
gh stack is git-centric: init, add, checkout, up, down, top, bottom, submit,
push, rebase, and sync all move git branches, run git rebase, and keep stack state in
.git/gh-stack. In a jj repo those fight jj's model — branches move and commits get rewritten
behind jj's back while @ stays put, and the resulting divergence has to be untangled by hand.
From a jj repo use only the GitHub-facing subcommands. gh stack link --help states the intent:
"designed for users who manage branches with external tools (e.g. jj, Sapling, ghstack, git-town,
etc…) and want to use GitHub stacked PRs without adopting local stack tracking."
Read skill://gh-stack for stack semantics, the link/merge/unstack flag reference, exit
codes, and layer-design guidance — all of it applies. This skill covers only what jj changes.
gh stack link a b c takes branches in stack order, bottom to top, positionally. a is
based on trunk and merges first.link is the only way to write stack structure, and it keeps no local state (documented in
gh-stack's own troubleshooting reference). GitHub holds the stack; the jj repo holds nothing, so
the local commands have nothing to read. gh stack view fails outright here —
✗ failed to get current branch: failed to run git: not on any branch (exit 2) — because jj
leaves git HEAD detached. The same applies to merge with no argument. Get status from GraphQL
or gh pr view instead.jj git push force-pushes rewritten bookmarks with lease; link pushes the branch arguments
itself but never forces (git.Push(remote, branches, force=false, atomic=true)). So push
rewrites with jj first, then relink — a reordered branch cannot be updated by link.| Never run | Why |
|---|---|
git add, git commit | No staging area in jj; changes are already in @. gh-stack's git loop assumes one. |
gh stack init / add / checkout | Create git branches and .git/gh-stack tracking that jj bookmarks don't mirror. |
gh stack up / down / top / bottom | Read the local tracking file; absent or stale here. |
gh stack rebase / sync / rebase --continue / --abort | git rebase behind jj's back, plus .git/gh-stack-rebase-state. Conflicts are jj's to resolve. |
gh stack push / submit | Operate on locally tracked stack branches; use jj git push. |
git checkout, git rebase, git branch -f | Same divergence problem without gh-stack involved. |
link needs bottom-to-top. jj log is newest-first by default, so order must be forced:
jj log -r 'roots(mutable() & ::@)::@' --no-graph --reversed \
-T 'if(local_bookmarks, local_bookmarks.map(|b| b.name()).join(" ") ++ " ", "")'
Optionally alias it (edit ~/.config/jj/config.toml):
[revset-aliases."substack()"]
definition = "roots(mutable() & ::@)::@"
doc = "Stack from its bottom through the working copy"
[aliases.sb]
definition = ["stack-bookmarks"]
doc = "Shorthand for stack-bookmarks"
[aliases.stack-bookmarks]
definition = [
"--config", "revsets.log=substack()",
"log", "--no-graph", "--reversed", "-T",
'if(local_bookmarks, local_bookmarks.map(|b| b.name()).join(" ") ++ " ", "")'
]
doc = "Local bookmark names in substack(@), oldest first, space-separated"
Pipe the output into link with xargs; zsh does not word-split $(...), so
gh stack link $(jj sb) passes one bogus argument there.
jj log -r 'roots(mutable() & ::@)::@' --no-graph --reversed -T 'if(local_bookmarks, local_bookmarks.map(|b| b.name()).join(" ") ++ " ", "")' | xargs gh stack link
Verify the printed order names your layers bottom-first before running it. Run link from the top
of the stack so the revset covers every layer, and check out the layer you intend to edit.
jj bookmark create auth-layer -r <change>
jj bookmark create api-routes -r <change>
Alternative: jj git push --change '<revset>' auto-creates a bookmark per change from
templates.git_push_bookmark (default push-<changeid>). It ignores existing bookmarks, so
mixing the two produces duplicate branches and duplicate PRs. Pick one approach.
3. Push and set tracking in one step. A plain jj git push -r <bookmarks> refuses to create new
remote bookmarks:
jj git push --bookmark auth-layer --bookmark api-routes
# "Refusing to create new remote bookmark api-routes@origin" means the tracking push was skipped
gh stack link auth-layer api-routes
link auto-generates PR titles and bodies. Replace them, then publish:gh pr edit <number> --title "<conventional title>" --body-file <file>
gh stack link --open auth-layer api-routes # drafts -> ready for review
jj edit <layer> (or rewrite while @ is above it), then push the whole stack and relink:
jj git push -r 'roots(mutable() & ::@)::@'
gh stack link auth-layer api-routes
Relinking skips PRs that already exist and retargets bases. It cannot update a rewritten branch itself, which is why the jj push comes first.
New commit and bookmark on top of the previous top layer, then:
jj git push --bookmark ui-layer
gh stack link auth-layer api-routes ui-layer
With a known stack number the first argument is a shortcut, appending only the delta:
gh stack link 7 ui-layer.
gh stack rejects PRs added to the middle of a stack, and never reorders or removes. Both require
unstacking on GitHub first. gh stack unstack <stack-number> works through the API with no local
state, so it is usable from a jj repo.
gh stack unstack <n>, create or jj abandon -r <change> the layer, jj git push the stack, then gh stack link every layer again.jj git push -r <stack> against a still-stacked, reordered set.jj git push --deleted after relinking.
Deleting the remote branch first closes the PR stacked above it as well.gh stack merge <pr-number> --yes --squash
Merges that PR and everything below it, all-or-nothing. Without an argument it resolves the stack
from the current git branch, which fails under jj's detached HEAD — always pass a PR or stack
number. Discovery of a stack number, or of your position in a stack, comes from the number shown in
the GitHub stack UI or the GraphQL query below. For a partial merge, jj git fetch afterwards and
rebase the surviving layers onto the new trunk before relinking. Once a stack has merged, prune the
per-layer bookmarks with jj cleanup (see the jj-cleanup skill).
gh pr view --json stack does not exist. Use GraphQL, which exposes read-only stack and
stackEntry on PullRequest (position 1 is closest to trunk):
gh api graphql -f query='query($owner:String!,$name:String!,$number:Int!){repository(owner:$owner,name:$name){pullRequest(number:$number){number baseRefName stack{number size baseRefName} stackEntry{position}}}}' \
-F owner=<owner> -F name=<repo> -F number=<pr-number>
stack: null means the PR is not stacked.
gh stack rebase --continue / --abort and
the exit-3 recovery in the gh-stack skill do not apply. Resolve in jj (jj status, edit the
conflicted files, jj records conflicts as first-class).gh stack v0.1.1 and jj 0.45.1; gh stack <command> --help remains authoritative for flags.What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/jj-cleanupRemoves the local jj bookmarks, revisions, and workspaces left behind by merged or closed GitHub pull requests, using the jj-cleanup binary through the `jj cleanup` / `jj cl` aliases. Use after a PR or stack merges or closes, when pruning stale bookmarks or workspaces, when `jj log` is cluttered with finished work, or when asked what is safe to delete locally. Also use to install jj-cleanup and its aliases when they are missing./jj-create-prCreates GitHub pull requests from Jujutsu changes with AI-generated descriptions. Use when the user wants to create a PR, push changes for review, or open a pull request./jj-update-prUpdates existing GitHub pull request descriptions with AI-generated content based on the current diff. Use when the user wants to update a PR description, refresh PR content, or sync PR with latest changes.npx claudepluginhub hotthoughts/jj-skills --plugin jjOther plugins' skills for the same job