/preen:preenfrom preen
Turn messy work into a clean, ordered set of atomic commits. Runs the preen binary, which splits a dirty working tree, absorbs a run of unpushed commits and redoes them, and, only when explicitly asked, rewrites commits that are already pushed. It handles the reset itself, shows a plan, and changes nothing until approved. Commit message style is configurable with flags or a .preen.toml. Run options: --scope preens only part of the tree, --gate runs a check after each commit, --dry-run plans and stops, --fixup folds dirty changes into the unpushed commits that introduced them, --yes skips the approval prompt, --pushed grants the explicit ask a pushed rewrite requires, --allow-generated commits build output preen would otherwise hold back. When Claude made the changes itself, it answers the grouping from preen request with --grouping, since it knows why each hunk exists. Triggers: "preen", "split my diff", "clean up my commit history", "fix my last commits", "reword these commits", "resplit my commits", "fold my changes into the right commits".
Ships in preen. 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.
This skill drives the preen binary. Do not reimplement its behavior with raw git commands: the binary owns the grouping, the staging, the guardrails, and the conservation check that proves no content was lost. Your job is to pick the right flags, relay the plan, and report the result.
preen --version. If it is missing, offer
go install github.com/dcadolph/preen/v2@latest and stop until the user
agrees.The Bash tool cannot answer preen's interactive prompt, so run it in two steps:
preen --dry-run (plus any flags the request calls for) to get the plan.
Show the plan to the user unchanged.--yes in place of
--dry-run to apply it.When the user wants the plan changed, prefer flags that reshape the run
(--scope, --fixup, --grouper, message style flags) and rerun the dry
run. For fine-grained edits like merging or reordering planned commits, tell
the user to run preen themselves: its prompt accepts merge, split, move,
reword, drop, and reorder interactively.
If the changes came from you, in this session, you know why each hunk exists, and the built-in rules do not: they group by package and never split a file. Answer the grouping yourself instead of taking their plan.
preen request --pretty > "${TMPDIR:-/tmp}/preen-request.json", plus any
--scope or --absorb the run will use.tree copied unchanged from the
request and commits in the order they should land, one commit per change
you made for one reason. A part without hunks takes the whole file. List
hunk indexes only for a file whose hunks served different changes. Subjects
follow the repository's commit style, and preen verifies them against it.--leave PATH for scratch
files you created that do not belong in history, and name them to the user.preen --grouping <answer> --leave ... --dry-run and show the plan to the
user unchanged. After approval, the same with --yes in place of
--dry-run.Exit code 5 with "does not match this tree" means something changed after the
request: run preen request again and answer the new one. Never edit the tree
hash to make an answer fit. Changes you did not make, or made in an earlier
session, go to the built-in rules with plain preen.
preen.--absorb brings them back and redoes them.--fixup.--scope <path>, repeatable.--gate "<cmd>".--sweep.--allow-generated, and only when
the user says that path belongs in the repository.--pushed. Pass --pushed, and --pushed-base <rev> when they named
a range. Every other guardrail stays with the binary.Message style flags (--conventional, --prefix, --max-subject,
--no-emdash, --no-semicolon, --punctuation, --body, and the rest) pass
through as the user asks. A .preen.toml at the repository root sets
defaults; flags beat the file.
preen refuses to commit untracked paths that hold generated output rather than
work: __pycache__/, *.pyc, node_modules/, .DS_Store, coverage reports,
editor swap files, and the like. They appear in the plan under "Held back as
generated output", with the pattern that caught each one, and stay in the
working tree untouched.
Relay that section to the user, since it is the part of the plan that needs a
decision. The right fix is almost always a .gitignore entry, which is theirs
to make: preen does not write that file, because editing it mid-run would move
the content hash the conservation check compares. Do not add it yourself
without being asked.
If the path genuinely belongs in the repository, --allow-generated commits
everything held back, and a [generated] allow = [...] entry in .preen.toml
exempts one path for good. A tree holding nothing but generated output exits
with the nothing-to-do code (4) and says so.
Distinct codes tell you what happened without parsing output: a rejected plan (5), a rolled-back run (6, 7), and a declined prompt (8) are different results. On a rollback, relay the binary's report of what diverged; the repository has already been restored.
--no-verify without the user's explicit grant in this session
or allow-no-verify = true in the repository's .preen.toml. With that
consent in place, use it rather than aborting; note the bypass in the
report.--pushed, --allow-protected, a separate push
confirmation); do not work around a refusal.preen-backup/<timestamp> ref. Undo with
preen restore, and clean old refs with preen backups --prune. Name the
backup ref in your report so the user knows how to undo.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dcadolph/preen --plugin preen