Git Workflow Skill
Manage parallel development sessions using git worktrees. Each session gets its own isolated working directory and branch.
Subcommands
Parse the user's arguments to determine which subcommand to run. If no argument, run status.
/git-workflow start <type/name> or /git-workflow start <name>
Create an isolated worktree for a new feature branch.
Steps:
- Parse the name. If it contains
/(e.g.,fix/offset-bug), use as-is. If not, prefix withfeat/(e.g.,error-reporting->feat/error-reporting). - Extract the short name (part after
/) for the worktree directory name. - Check if worktree already exists at
.worktrees/<short-name>/. If yes, just show the path. - Check if
--base <branch>was specified. Default base isorigin/main. - Fetch the base:
git fetch origin - Create worktree:
git worktree add .worktrees/<short-name> -b <type/name> <base> - Output:
Created worktree at .worktrees/<short-name>/ Branch: <type/name> (based on <base>) Next steps: cd .worktrees/<short-name> && claude
Supported branch types: feat, fix, docs, chore, refactor, test, release
/git-workflow status
Show all worktrees, branches, and recommended cleanup actions.
Steps:
- Run
git worktree listto get all worktrees - For each worktree, check dirty/clean:
git -C <path> status --porcelain - Run
git branch -vvfor branch tracking info - Check for merged branches:
git branch --merged mainfor fast-forward mergesgh pr list --state merged --json headRefName -q '.[].headRefName'for squash merges
- Show summary with recommended actions (which branches can be cleaned up)
/git-workflow finish
Push the current branch and create a PR.
Steps:
- Verify current branch is not main:
git branch --show-current - Push with tracking:
git push -u origin <branch> - Create PR:
gh pr create --fill(or ask user for title/body) - Output the PR URL
- Remind: "When PR is merged, run
/git-workflow cleanupfrom the main worktree"
/git-workflow cleanup
Remove completed worktrees and merged branches.
Steps:
- Detect merged branches:
git branch --merged main gh pr list --state merged --json headRefName -q '.[].headRefName' - For each merged branch (excluding main):
- Check no open PRs:
gh pr list --head <branch> --state open - Check worktree is clean:
git -C .worktrees/<name> status --porcelain - If dirty, warn and skip
- Remove worktree:
git worktree remove .worktrees/<name> - Delete local branch:
git branch -d <branch> - Ask user before deleting remote:
git push origin --delete <branch>
- Check no open PRs:
- Prune:
git remote prune origin && git worktree prune - Show summary of what was cleaned
Safety rules:
- NEVER delete main
- NEVER delete branches with open PRs
- NEVER delete worktrees with uncommitted changes
- ALWAYS ask before deleting remote branches
Rules
- Always use
origin/mainas base (notgit checkout main) — avoids branch conflict with existing worktrees - Worktree directory:
.worktrees/<short-name>/relative to repo root - One branch per worktree — git enforces this automatically
- Run
melos bootstrapin new worktrees if the project uses melos
Source: BottlePumpkin/rfw_gen — distributed by TomeVault.