/jj:jj-cleanupfrom jj
Removes local jj bookmarks, revisions, and workspaces left behind by merged or closed GitHub pull requests. Use after PR merges to prune stale state and declutter jj log.
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.
jj-cleanup (HotThoughts/jj-cleanup) deletes the local
bookmarks, revisions, and workspaces that outlive the GitHub pull requests they were opened for. It
plans first, prints exactly what it would remove, and asks before changing anything. It is not
git clean: no file is ever removed from a working copy.
If jj cleanup or jj cl report an unknown alias, or jj-cleanup is not on PATH, the tool is not
installed. Surface this to the user rather than installing silently — the shell installer pipes a
remote script into sh:
curl -LsSf https://github.com/HotThoughts/jj-cleanup/releases/latest/download/jj-cleanup-installer.sh | sh
jj-cleanup util install-aliases # writes `jj cleanup` and `jj cl`
With Cargo: cargo install --git https://github.com/HotThoughts/jj-cleanup then
jj-cleanup util install-aliases. The installer targets user config; --repo scopes the aliases to
the current repository. By hand, the aliases are:
[aliases]
cleanup = ["util", "exec", "--", "jj-cleanup"]
cl = ["util", "exec", "--", "jj-cleanup"]
Requirements: jj 0.44 or newer (it refuses older versions — workspace cleanup needs the directory a
workspace reports) and an authenticated gh, which owns all GitHub access.
Check the install with jj-cleanup --version and jj config get aliases.cleanup.
| Command | Effect |
|---|---|
jj cleanup list | Print the plan. Always a dry run, never applies. |
jj cleanup | Plan, prompt, apply. |
jj cleanup -y | Plan and apply without the prompt. |
jj cleanup lock <bookmark>... | Never treat these bookmarks as candidates. Repo-scoped. |
jj cleanup unlock <bookmark>... | Stop protecting them. |
jj cleanup util dump | Print the gathered jj and gh state as JSON — use to debug "nothing to clean". |
jj cleanup util install-aliases | Write the cleanup and cl aliases. |
Options: --state merged (default) or closed; --scan quick (default, the repository gh
resolves) or deep (every GitHub remote); --dry-run; --no-fetch; --no-workspaces;
--remove; -y. Exit codes: 0 for success including a plan with nothing to do, 1 for an error or
an abort.
jj cleanup runs a fetch before planning unless --no-fetch is passed. Reviewing before applying is
the point of the tool, so drive it in two steps:
jj git fetch # optional; cleanup fetches too
jj cleanup list # review the plan
jj cleanup # interactive, or `jj cleanup -y` after the user confirms
jj bookmark list && jj log # verify
The plan names each action, e.g.:
abandon 1 revision for bookmark "docs-jj-gh-stack"
Applying deletes the bookmark and abandons its revisions: they leave jj log and all(), while
squash-merged work is already in trunk. The abandoned revision stays addressable by change or commit
id and recoverable with jj undo or jj op restore.
Agents: never pass -y before showing the user the plan. list and --dry-run change nothing, but
they may record a snapshot operation for a workspace that has uncommitted changes, because reading
that state snapshots it (--no-workspaces reads no workspace and records nothing).
A bookmark is a candidate only when it has at least one associated pull request, none of those pull
requests is open, at least one is in the requested state set, and the bookmark is not locked, not
conflicted, not the default branch, and not sitting on trunk. Otherwise the run reports Nothing to clean plus a skipped: and warnings: list. Real lines:
skipped:
bookmark "docs-jj-gh-stack": checked out in a workspace
bookmark "docs-jj-gh-stack": locked
workspace "default": is the primary workspace
warnings:
bookmark "docs-gh-stack-demo" carries a trailer for #8, which was opened from "docs-jj-gh-stack"
A pull request is associated either by a PR: #N trailer on the bookmark's tip commit, or by a pull
request whose head branch has the bookmark's name and whose head commit matches the tip. Since
cleanup abandons revisions and leaves the user's uncommitted work alone, it also protects a bookmark
whose revisions are still held by a kept bookmark or by a workspace this run leaves alone — a shared
stack base survives and is retried on a later run.
To make cleanup recognize a pull request, put the trailer in a trailing trailer block:
jj describe -r <change> -m "feat: add auth
PR: #42"
A prose mention (PR: #7 was reverted) is ignored, and a tip that disagrees with the pull request's
recorded head is kept with a mismatch warning so local work is not mistaken for the finished
pull request.
jj cleanup lock <bookmark>... stores the name in repository-scoped jj config
(jj-cleanup.locked-bookmarks), so it travels with the repository and applies in every workspace.
Use it for a merged pull request whose branch the user still needs locally. unlock removes it.
Workspaces participate by default. One is cleaned only when it is clean, is not the primary
workspace, is not the one being run from, holds a candidate's revisions, and its bookmark is not
locked; otherwise it is listed as skipped and its checked-out commits are protected. Forgetting a
workspace does not delete its directory — --remove does, and ignored files in that directory are
lost, which is why --remove is never the default.
--state closed also treats closed-unmerged pull requests as cleanable; the default skips them.gh stack unstack (see the jj-gh-stack skill).jj cleanup <command> --help
and jj-cleanup --help are authoritative.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub hotthoughts/jj-skills --plugin jj5 skills in this plugin
/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-gh-stackManages GitHub stacked PRs from a Jujutsu (jj) repository with the gh stack CLI. Use when creating, growing, updating, unstacking, or merging a stack of pull requests in a jj repo, when a jj bookmark backs a stacked PR layer, or when gh-stack's git-oriented workflow (init/add/checkout/up/down/rebase/sync) would touch a jj repo. Replaces the local-tracking loop in the gh-stack skill with jj bookmarks plus jj git push plus gh stack link./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./jj-workflowGuides Claude on using Jujutsu (jj) version control system. Use when working with jj repositories, making commits, syncing changes, or managing version control workflows.Other plugins' skills for the same job