npx skills add ...
npx skills add withgraphite/agent-skills --skill graphite
Work with Graphite (gt) for stacked PRs - creating, navigating, and managing PR stacks.
npx skills add withgraphite/agent-skills --skill graphite
Work with Graphite (gt) for creating, navigating, and managing stacked pull requests.
| I want to... | Command |
|---|---|
| Create a new branch/PR | gt create branch-name -m "message" |
| Amend current branch | gt modify -m "message" |
| Navigate up the stack | gt up |
| Navigate down the stack | gt down |
| Jump to top of stack | gt top |
| Jump to bottom of stack | gt bottom |
| View stack structure | gt ls |
| Submit stack for review | gt submit --no-interactive |
| Rebase stack on trunk | gt restack |
| Change branch parent | gt track --parent <branch> |
| Rename current branch | gt rename <new-name> |
| Move branch in stack | gt move |
In roughly descending order of importance:
Do NOT worry about creating TOO MANY pull requests. It is always preferable to create more pull requests than fewer.
NO CHANGE IS TOO SMALL: tiny PRs allow for the medium/larger-sized PRs to have more clarity.
Always argue in favor of creating more PRs, as long as they independently pass build.
When naming PRs in a stack, follow this syntax:
terse-stack-feature-name/terse-description-of-change
For example, a 4 PR stack:
git add <files>gt create branch-name -m "commit message"gt submit --no-interactiveBefore creating branches, check if the current branch is tracked:
If you see "ERROR: Cannot perform this operation on untracked branch":
Option A (Recommended): Track temporarily, then re-parent
gt track -p maingt createOption B: Stash changes and start from main
git stashgit checkout main && git pullgit checkout -b temp-working && git stash popgt track -p main and gt createUse gt move to reorder branches in the stack. This is simpler than trying to use gt create --insert.
If you created a stack on top of a feature branch but want it based on main:
If changes are already committed but you want to re-stack them differently:
Before running gt submit, verify the first PR is parented on main:
If the first branch has a parent other than main:
After creating each PR, run appropriate linting, building, and testing:
gt modifyAfter submitting, use gh pr edit to set proper titles and descriptions.
IMPORTANT: Never use Bash heredocs for PR descriptions - shell escaping breaks markdown tables, code blocks, etc. Instead:
Write tool to create /tmp/pr-body.md with the full markdown contentgh pr edit with --body-file:PR descriptions must include:
Example (for a PR in a 3-PR stack adding a warning feature):
| Problem | Solution |
|---|---|
| "Cannot perform this operation on untracked branch" | Run gt track -p main first |
| Stack parented on wrong branch | Use gt track -p main then gt restack |
| Need to reorder PRs | Use gt move |
| Conflicts during restack | Resolve conflicts, then git rebase --continue |
| Want to split a PR | Reset commits (git reset HEAD^), re-stage selectively, create new branches |
| Need to delete a branch (non-interactive) | gt delete <branch> -f -q |
gt restack hitting unrelated conflicts | Use targeted git rebase <target> instead (see below) |
| Rebase interrupted mid-conflict | Check if files are resolved but unstaged, then git add + git rebase --continue |
In deeply nested stacks with many sibling branches, gt restack can be problematic:
git rebase Instead of gt restackUse direct git rebase when:
gt restack is hitting conflicts in unrelated branchesIf a rebase was interrupted (e.g., Claude session ran out of context):
Check status:
Read the "unmerged" files - they may already be resolved (no conflict markers)
If already resolved, just stage and continue:
If still has conflict markers, resolve them first, then stage and continue
Flags:
-f / --force: Delete even if not merged or closed-q / --quiet: Implies --no-interactive, minimizes outputAfter deleting intermediate branches, children are automatically restacked onto the parent. If you need to manually update tracking: