Drive gitq with agents
gitq is a CLI you can drive by hand, and it is a CLI built to be driven by an agent. Five Claude skills wrap it: gitq:sync, gitq:publish, gitq:absorb, gitq:restructure, and gitq:track. Each owns exactly one action, and each one splits the work the same way: gitq does the git mechanics, deterministically, and the agent supplies the judgment gitq deliberately does not have an opinion about.
What each skill owns
| Skill | CLI mechanics | Judgment the skill adds |
|---|---|---|
gitq:sync | gitq sync, gitq continue, gitq abort | Reading a conflict's both sides and merging them for real, not picking one side mechanically. |
gitq:publish | gitq publish --mr-meta <path> | Writing MR titles and descriptions from the actual diff, deciding which already-published MRs should have their prose overwritten (an --mr-meta entry for one replaces what is on the forge), and holding the gate before anything reaches it. |
gitq:absorb | gitq absorb --preview, gitq absorb | Sanity-checking the file→branch attribution before committing to it; gitq's attribution is mechanical (git diff --name-only <parent> <branch>) and can be wrong on a surprising file. |
gitq:restructure | gitq split, fold, reparent, rename, reset | Turning a plain-language instruction ("split the UI work out of feat-core") into the right sequence of surgery commands, and gating the whole plan before executing any of it. |
gitq:track | gitq track, add, import, stacks | Working out which branches form the chain and which parent each one sits on, before anything is tracked. |
None of them mutate git directly. All five run the real gitq CLI for every git operation and only exercise judgment in the parts gitq's own conflict/attribution/mapping logic hands back for a human (or an agent standing in for one) to decide.
Installing them
The horsey app (mattstack.app) ships the skills alongside the bundled gitq CLI. Its setup links them into ~/.claude/skills (the "Link bundled skills" step). So /gitq:sync and the others are available as slash commands in any Claude Code session. With the app installed there is nothing to run, and an app update brings skills that match the CLI it ships.
From a checkout
Working on the skills themselves, link them to your checkout instead:
bun run scripts/install-skills.ts
This symlinks every skills/<dir> whose SKILL.md has a name: frontmatter field into ~/.claude/skills/<name>. It is checkout-only, and it is idempotent: re-running it after a git pull that changed the skills just re-links. It replaces any existing symlink at the destination, the app's links included, and the app's setup leaves a link it did not make alone, so the checkout links stay until you remove them. It refuses (with a message, not a crash) if something other than a symlink already occupies the destination path. Pass a different destination directory as the first argument if you don't want ~/.claude/skills.
Invoking a skill
Every skill takes the repo and the stack by position:
/gitq:<action> <repoPath> <stackName>
<repoPath> and <stackName> are required. gitq:restructure has one extra positional, an optional [instruction] after <stackName>: the plain-language description of what to restructure. gitq:track takes only an optional [repoPath], which defaults to the current directory.
gitq:absorb's <repoPath> is not necessarily the primary checkout. It can be any worktree of the repo, because absorb sources its uncommitted changes from wherever you point it.
Each skill runs the same steps from start to finish and narrates them in the conversation. Run /gitq:sync /Users/you/repos/myrepo demo and it reports each step as it goes, resolving conflicts itself and stopping when a gate needs your answer.
A worked example: gitq:restructure by hand
Say a branch has grown one commit of pure cleanup that really belongs one level down. Invoked directly, with the instruction as the third positional:
/gitq:restructure /Users/you/repos/myrepo demo "fold feat-core-docs into feat-core, it's just cleanup"
What the skill does, matching its own steps:
- Reads the intent straight from the instruction positional: no ambiguity here, so no clarifying question.
- Learns the current shape:
gitq -C /Users/you/repos/myrepo stacks --jsonandgitq -C /Users/you/repos/myrepo diagnose --json, plusgit log --oneline <parent>..<branch>on the branch in question, to see there really is nothing but cleanup on it. - Maps the instruction to one operation:
gitq fold feat-core-docs --stack demo. - Gates. Before running anything it shows you the plan (
fold feat-core-docs into feat-core; feat-core-docs's children get reparented onto feat-core) and the caveat that matters:foldis not reversible bygitq undo(onlyreparentis), so this is a one-way door. It waits for your yes. The pane itself is the gate: if you never answer, nothing executes and the conversation just sits there. - Executes only after approval: runs
gitq fold feat-core-docs --stack demo --json, checks the result. - Verifies: a final
gitq diagnose --jsonto confirm the tree is healthy, then reports the new shape back to you in the conversation.
Where the docs are occasionally wrong
These skill files are the prompts actually driving the agents, so a detail in one can fall behind the code underneath it. Where that has happened, the mismatch is called out here rather than left to mislead you from inside the skill:
skills/restructure/SKILL.md on checkout neutralityIts step 3 says "surgery never moves the launch worktree's checkout." True for split, reparent, rename, and reset, but there is one exception, and this skill drives it.
fold deletes the branch it folds, so if your launch worktree has that branch checked out (clean), gitq switches it to the parent before deleting (src/core/branch-fold.ts). Nothing else in the surgery set moves a checkout: reset, which used to check the branch out and leave you there, is a compare-and-swap on the ref now (src/core/branch-reset.ts), so gitq reset feat-b while you are on feat-a leaves you on feat-a. See Restructure a stack.
Next
- Resolve a conflict: the conflict loop
gitq:syncandgitq:restructure's reparent path both follow. - Publish a stack: what
gitq:publishgates before it runs. - Absorb uncommitted changes and Restructure a stack: the CLI mechanics behind the other two skills.