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 lsto see the current stack state - •Run
git statusto see staged, unstaged, and untracked files - •Run
git diff --statandgit diff --staged --statfor an overview - •Run
git diffandgit diff --stagedto read the actual diffs - •If $ARGUMENTS contains
commits:N, also rungit log --oneline -Nandgit diff HEAD~N..HEAD - •Run
git log --oneline -5to 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):
code
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
- •Stage the specific files with
- •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(orgt submit --stack --draftfor 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-committo decompose - •Always show a dry-run plan and get explicit confirmation
Rules
- •NEVER run
gt submitwithout explicit user confirmation - •NEVER use
git add .orgit 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
gtis 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