Skip to main content

jj-stack: manage stacked GitHub PRs with jj

jj-stack turns a linear series of local jj changes into a stack of GitHub pull requests. Rewrite, split, squash, or reorder the changes with jj, then let jj-stack update the matching PRs.

Quick start

Requirements

  • Python 3.14 or newer
  • jj 0.44.0 or newer
  • GitHub authentication

Install

Install jj-stack from PyPI with uv in an isolated tool environment (recommended):

uv tool install jj-stack

pipx provides another isolated installation:

pipx install jj-stack

You can also use pip inside an activated virtual environment:

python -m pip install jj-stack

To upgrade an installation made with uv, rerun its command with --force. If the command is not on your shell PATH, run uv tool update-shell.

For tab completion, add the output of jj-stack completion to your shell startup file:

eval "$(jj-stack completion zsh)"

bash and fish work the same way.

To invoke it as jj stack and complete that alias too, see Configuration.

Submit your first stack

Start with a linear series of local jj changes on top of trunk(). In a new repo, check the setup and apply the safe local fixes:

jj-stack doctor --fix

Inspect the stack that ends at your working copy:

jj-stack

Create one GitHub PR per local change:

jj-stack submit

Revise the changes locally with jj and rerun jj-stack submit whenever the stack is ready to refresh. Use jj-stack list to see every tracked stack in the repo.

Mental model

The local jj DAG determines which changes form a stack and their order. On GitHub, each change gets a stable PR branch and a PR; every PR targets the PR branch below it, except the bottom PR, which targets trunk by default:

jj-stack/add-ui-...         -> PR #3 (base: jj-stack/add-api-...)
jj-stack/add-api-...        -> PR #2 (base: jj-stack/refactor-model-...)
jj-stack/refactor-model-... -> PR #1 (base: main)
main                        -> trunk

The PR branches normally stay out of your local bookmark view. When you rewrite a change, jj-stack updates that change's existing PR branch and PR, along with the PR branches and PRs for dependent changes.

Everyday workflow

  1. Write code as a series of local jj changes.
  2. Run jj-stack submit.
  3. Revise, add, remove, or reorder the changes locally as reviews come in.
  4. Run jj-stack submit again to refresh GitHub.
  5. Run jj-stack merge when the changes at the bottom are ready.
  6. After a queued or externally initiated merge finishes, run jj-stack sync <head-change-id>.

view, submit, merge, and sync accept a change ID when you need to select a stack other than the one ending at the working copy.

See the user guide for drafts, descriptions, merge queues, cleanup, and working with multiple stacks.

Learn more

The built-in help is the canonical flag reference:

jj-stack --help
jj-stack <command> --help
jj-stack help --all

Coding agent integration

Install the bundled skill to teach coding agents to work with local jj stacks and refresh their GitHub PRs safely:

gh skill install bos/jj-stack jj-stack

See the skill source. In my evaluations with Codex and Claude Code, agents with the jj-stack skill succeeded in 11/12 scenarios versus 6/12 without it, with one critical error versus four, using 60% fewer failed command attempts and 18% fewer tool calls. (The critical error was due to Claude Haiku understanding a rule and ignoring it. I haven't figured out how to get smaller Claude models to behave better, and I don't personally use them.)

Performance

Although jj-stack is written in Python, this does not significantly affect its speed. The real determinants of its performance are the GitHub API and the jj command.

The GitHub API is slow; a single roundtrip takes many hundreds of milliseconds. jj-stack reduces its impact with:

  • GraphQL batch requests where possible
  • concurrent use of the GitHub REST API
  • periodic audits that its queries are minimal in extent

In pursuit of good performance, jj-stack also batches calls to jj and minimizes the amount of work those calls must do.

Metadata

Release files for jj-stack 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jj-stack 0.1.1
File Size Uploaded
jj_stack-0.1.1.tar.gz 396.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jj-stack 0.1.1
File Interpreter ABI Platform
jj_stack-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 605.7 kB

Release files / jj_stack-0.1.1.tar.gz

Download URL jj_stack-0.1.1.tar.gz
Size 396.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5cf3ca06cf1cfbe8a8e1b47865be321721662192fa7c92aceacfa3f4f96c0405
BLAKE2b-256 checksum
How to use checksums
8747afa8084c9e2cda4850430f81e09aa363f00fcb25d60ede6396adc153a434
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / jj_stack-0.1.1-py3-none-any.whl

Download URL jj_stack-0.1.1-py3-none-any.whl
Size 209.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db9ec74e077cd13a2ee7d0cf756d388467cdffa75f13b6f1c2a50bdc35ac6489
BLAKE2b-256 checksum
How to use checksums
57f5e746e882ea2fb26be911ca5befe7ae7f53963936cdd1c97fa9ec94a2cf33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page