crates/but/skill/SKILL.md
Use GitButler CLI (but) as the default version-control interface.
Choose the narrowest first command by task; avoid ritual status checks:
# Selected dirty files/hunks:
but diff
# Commit order, branch/stack placement, conflict overview:
but status
# File/hunk IDs, per-commit files, amend/split details:
but status -fv
# Details for one known branch or commit:
but show <id>
Do not run plain but status and then but status -fv unless the compact output lacks file/hunk details needed for the task.
For "commit just/only/specific changes on a new branch", use the fast path:
but diff
but commit <branch> -c -m "<msg>" --changes <id>,<id>
but commit <branch> -c ... --changes ... creates the branch and prints the resulting workspace state. Do not run a separate but branch new, staging command, status command, or verification diff unless the returned output lacks information you need.
The first token on each but diff / but status line is that line's ID — pass it to commands as-is; never hardcode or invent IDs. IDs may be a single character when unambiguous; copy them exactly from command output.
--changes (or -p) takes comma-separated file or hunk IDs. A hunk ID is written <file-id>:<hunk-id> (e.g. qs:5, copied from but diff) — the part after the colon is the hunk's ID, not a line range (qs:16-40 is invalid). Do not invent flags like --hunk / --hunks / --ids, pass a line range, or pass the IDs as positional arguments.amend, squash, move, uncommit, reword). Commits without a change ID (e.g. upstream-only) lead with a sha prefix instead, and #N-suffixed refs disambiguate duplicates — both go stale after history edits, and a stale sha can silently resolve to the wrong commit. The (sha …) on verbose commit lines is informational — do not pass it to commands.but status/but diff and retry.Chaining: you may chain mutations with && off one inspection read. Chained but commit calls stack in the order written — the first is oldest, each later one goes on top. History edits may run in sequence when every commit ref involved is a change-ID ref; run them one at a time when a ref is sha-based or #N-suffixed, or when the next command needs IDs the previous one prints (e.g. recommitting after but uncommit --diff). Take follow-up refs from the returned workspace state.
but for all write operations. Never run git add, git commit, git push, git checkout, git merge, git rebase, git stash, or git cherry-pick. If the user says a git write command, translate it to but and run that. Exceptions: git add -- <path> to mark a conflicted uncommitted file resolved (see "Conflicts in uncommitted files"), and a worktree-local Git commit when but commit reports that linked worktrees are unsupported. Never run but setup from a linked worktree.but status/but diff only if that output lacks the ID you need or files changed since.(merged upstream); run but pull to remove it, or create/use another branch for new work.but commands and give a concise final summary.--help probes; use this skill and references/reference.md first. Only use --help after a command fails or required syntax is missing from the installed references.but commit <branch> -m "<msg>" --changes <id>,<id>but commit calls with && (commits stack oldest-first in the order written)but commit <branch> -c -m "<msg>" --changes <id>... --before <commit-or-branch-id> or --after <commit-or-branch-id>but commit -a is accepted as a no-op compatibility flag; GitButler already includes uncommitted changes by default.but amend <commit-id> --changes <file-or-hunk-id>,<file-or-hunk-id>but uncommit <commit-id> --diffbut commit empty [-m "<msg>"] [<target>]but squash <source-commit-id> [<source-commit-id>...] <target-commit-id> [-m "<msg>"]but move <source-commit-id> <target-commit-id> (commit IDs, not branch names)but move <source-commit-id>,<source-commit-id> <target-commit-id> (comma-separated commit IDs)but move <commit-id> <branch-name-or-id>but move <branch-name-or-id> <target-branch-name-or-id> (branch names or branch CLI IDs)but move <branch-name-or-id> zz (zz = uncommitted)but push <branch-name> — always specify the branch; bare but push pushes ALL branches when run non-interactivelybut pull — the output reports the result; --check is only a dry-run previewbut pr new <branch-id> [-m "Title..."] [-F pr_message.txt] [-t] [--draft] — auto-pushes first; do not run but push before itFor "get latest from main", "update/sync this workspace", "rebase onto main", or "pull main":
but pull — one command; no preflight needed. Its output reports the resulting state, it refuses safely when uncommitted changes conflict, and but undo reverts it.but resolve <commit>, edit the files, but resolve finish. Finishing a lower commit rebases the ones above it, so always work bottom-up.Use but pull --check only to answer "would this conflict?" without updating (a dry-run preview), not as a step before every pull.
Rebasing applied branches onto the latest target IS but pull — never move, config target, unapply, or raw git pull/git rebase. The base shown in status is the last FETCHED state: when git log shows main (local or remote) ahead of it, that is exactly the update but pull fetches and applies — the target setting is not stale and repointing it is never the fix. Pull carries uncommitted changes along, and its output reports the resulting state. If it refuses because uncommitted changes conflict, park them as printed: but commit <branch> --changes <ids> -m "wip", pull again, then but uncommit the parked commit (there is no stash; do not hand-revert files).
but diff — shows file and hunk IDs for uncommitted changes. Do not run plain but status first.<file-id>:<hunk-id>) when only part of a file belongs. Omit IDs you don't want committed.but commit <branch> -c -m "<msg>" --changes <id1>,<id2> (no prior but branch new needed). Existing branch: omit -c.Edge case: if wanted and unwanted edits are in the same diff hunk, GitButler cannot split that hunk by ID. Only when the task requires keeping part of that hunk uncommitted, temporarily edit the working tree to isolate the wanted lines, commit with --changes, then restore the leftover lines so they remain uncommitted.
but status -fv (or but show <branch-id>) — locate file/hunk IDs and target commit IDs.but amend <commit-id> --changes <id>,<id> — one command per target commit. For several target commits, chain the amends with && when every target is a change-ID ref; otherwise run them one at a time with fresh refs from each returned status.Use this when an existing commit should be replaced by selected smaller commits.
but status -fv when you need the source commit, branch name, or placement anchor.but uncommit <source-commit-id> --diff exposes the commit's changes as uncommitted and prints committable file/hunk IDs.but commit calls. Each new commit goes to the TOP of the stack — if the split commit had commits above it, the replacements now sit above those preserved commits.--before <top>/--after <top> (sha/#N anchors go stale as each insert rewrites history; --before <branch> just puts commits on top of the branch). Take the preserved commit's ref from the last returned workspace state, then but move <preserved-commit-id> <branch> (several: but move <id1>,<id2> <branch>, oldest first).but status displays commits newest/top first, while task specs often list history oldest to newest — translate before moving.
but status once to get commit IDs (use -fv only if you also need file details).but move <source> <target-commit> places source immediately before target in oldest-to-newest history (directly below it in but status). --after places it immediately after (directly above). but move <source> <branch> moves it to branch top/newest.but move <oldest-block-id>,<newest-block-id> <following-commit-id> — do not sort the whole branch or move members one by one. After a successful block move, stop if the returned status shows the requested order; do not move the anchor or block members again.but status for commit IDs and order.but squash <source> [<source>...] <target> -m "<new message>".#N-suffixed.To make one existing branch depend on another: but move <child-branch> <parent-branch> (branch names or branch CLI IDs — commit reordering uses commit IDs). To unstack: but move <branch> zz.
DO NOT stack via uncommit + branch delete + branch new -a (git branch names persist after delete and it loses work), and do not use but undo to unstack.
but pr new <branch-id> pushes the branch and creates the PR in one step — no prior but push. Provide -F pr_message.txt, -t, or -m with real newlines (zsh/bash: -m $'Title\n\nBody') so no editor opens. If forge auth is missing, run but config forge auth.
For stacked branches but pr is mandatory (it sets PR bases and stack metadata; gh pr create breaks that). To publish a whole stack: but pr new <top-branch-id> -t. Manage with but pr auto-merge|set-draft|set-ready <selector>. See references/reference.md for details.
Changes that build on another branch's commits cannot land on an independent branch. but commit either creates the commit but reports the change as "could not be applied", or refuses outright — both name the branch the changes depend on and print the exact recovery command.
Recovery: run the printed but move <your-branch> <dependency-branch> (full branch names) to stack the branches, then commit again with the same --changes IDs.
If that but move fails, do NOT try uncommit, squash, or undo as a workaround — re-run but status -fv to confirm both branches exist and are applied, then retry with exact branch names.
NEVER use git add, git commit, git checkout --theirs/--ours, or any git write command during resolution. Only but resolve commands plus direct file edits.
but pull summary lists them oldest-first; otherwise but status marks them.but resolve <commit-id> — enters resolution mode and prints the conflict regions.<<<<<<< / ======= / >>>>>>> markers and keep the correct content. Do NOT skip this; do NOT use but amend on conflicted commits.but resolve finish — reports leftover markers and surviving uncommitted changes; no follow-up status needed.but status marks uncommitted files with unresolved merge conflicts {conflicted}; they are excluded from committable changes and outside but resolve mode. Choose the desired contents or delete the file, then git add -- <path> to mark it resolved (the one permitted git add).
| git | but |
|---|---|
git status | but status for branch/stack/commit overview; but status -fv for file/hunk details; but diff for selected dirty changes |
git add + git commit | but commit ... --changes ... |
git checkout -b + commit | but commit <branch> -c -m ... --changes ... |
git push | but push <branch-name> |
git rebase -i | but move, but squash, but reword |
git rebase --onto | but move <branch> <new-base> |
git cherry-pick | but pick |
gh pr create | but pr new <branch-id> |
git log, git blame, git show --stat) is allowed.but prints an AGENT ACTION REQUIRED skill warning, run the suggested command once, then reload/use the GitButler skill. If it repeats, report it instead of retrying.references/reference.mdreferences/concepts.mdreferences/examples.md