| name | gt-stack |
| description | Analyze changes and organize them into a Graphite stack of logically isolated PRs |
| disable-model-invocation | true |
| argument-hint | [scope] (optional — 'staged', 'all', or 'commits:N') |
Analyze the current changes and organize them into a Graphite stack of logically isolated branches, each becoming its own PR.
Steps
Phase 1: Assess
- Run
gt ls to see the current stack state
- Run
git status to see staged, unstaged, and untracked files
- Run
git diff --stat and git diff --staged --stat for an overview
- Run
git diff and git diff --staged to read the actual diffs
- If $ARGUMENTS contains
commits:N, also run git log --oneline -N and git diff HEAD~N..HEAD
- Run
git log --oneline -5 to understand the commit style
Phase 2: Propose a split plan
- Group changes into logically isolated units. Each unit should:
- Touch a single concern (one feature, one fix, one refactor)
- Be independently reviewable
- Have a clear conventional commit message
- Present the plan (bottom → top):
Proposed stack (bottom → top):
1. feat(scope): description — files: path/to/file.lua
2. fix(scope): description — files: path/to/other.zsh
- Ask the user to confirm, modify, or reorder before proceeding
Phase 3: Execute the stack
- For each entry (bottom to top):
- Stage the specific files with
git add <file>
- Run
gt create <branch-name> -m "type(scope): description"
- Verify with
gt ls
- Show the final stack with
gt ls
Phase 4: Optional submit
- Ask if the user wants to submit the stack as PRs
- If yes:
gt submit --stack (or gt submit --stack --draft for drafts)
- Output the stack summary
Handling commits:N
When reorganizing existing commits:
- Ensure working tree is clean (stash if needed)
- Use
gt branch split --by-commit to decompose
- Always show a dry-run plan and get explicit confirmation
Rules
- NEVER run
gt submit without explicit user confirmation
- NEVER use
git add . or git add -A — always add specific files
- ALWAYS present the split plan and wait for confirmation before creating branches
- ALWAYS use conventional commits: feat, fix, chore, docs, refactor, test
- ALWAYS end commit messages with:
Co-Authored-By: Claude <noreply@anthropic.com>
- If the working tree is dirty and there is an existing stack, warn before modifying
- If
gt is not installed, suggest: brew install withgraphite/tap/graphite
- Prefer smaller, focused branches — that's the whole point of stacking
- When unsure how to split, ask the user