Always verify before acting:
git statusbefore staginggit log --oneline -5for commit style- Check remote tracking before push
- Re-check
git log/git statusbefore assuming your session's work is still uncommitted. An external tool (IDE Git panel, a teammate, a pre-commit flow) may have committed "held" changes mid-session. Acting on the stale "it's uncommitted" assumption risks a duplicate commit or clobbering what already landed — confirm what's actually staged/committed first. - PR merge-state before pushing to an existing PR branch — if the PR already merged, the push orphans the commits (nobody re-reviews/re-merges them; the change silently never ships). Check
gh pr view <branch> --json state,mergedAtand stop if merged — branch off the default branch for the follow-up instead.
git worktree remove is destructive — sweep first. Before removing ANY worktree, in EACH worktree run:
git status --short— surface uncommitted edits (modified, untracked, staged)git log --oneline <upstream>..HEAD— surface unpushed commits- If either is non-empty, STOP. Ask the user explicitly: (a) commit + push it now, (b) save as a patch (
git diff > /tmp/<name>.patch) for later, or (c) discard. Don't assume "the work is mirrored elsewhere" — the whole reason worktrees exist is to hold work that isn't yet on the canonical branch. Surfacing the diff one-line-per-file BEFORE the user makes the call is the right move; runninggit worktree remove --forceto bypass a "worktree contains modified files" warning is the wrong one. Also delete stale local branch labels (git branch -D <name>) AFTER worktree removal if the label points at a commit the user has confirmed they're done with.
Branch naming: See ~/.claude/rules/git-workflow/RULE.md §"Branch Strategy".
- What changed (if not obvious from description)
- Why it changed (motivation)
Co-Authored-By: Claude noreply@anthropic.com
Types: see `~/.claude/rules/git-workflow/RULE.md` §"Commit Messages (Conventional Commits)" for the canonical type list.
Use HEREDOC for multi-line messages:
```bash
git commit -m "$(cat <<'EOF'
feat(auth): add JWT refresh token rotation
- Rotates refresh tokens on every use
- Prevents replay attacks on stolen tokens
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Test plan
- [Test 1]
- [Test 2]
Changes
- [File 1]: [What changed]
- [File 2]: [What changed]
</pr_format>
</essential_principles>
<intake>
What would you like to do?
1. **Commit** — Stage and commit changes
2. **Push** — Push commits to remote
3. **PR** — Open a pull request
4. **Ship** — Full workflow: commit + push + PR
**Wait for response.**
</intake>
<routing>
| Response | Workflow |
|----------|----------|
| 1, "commit" | `workflows/commit.md` |
| 2, "push" | `workflows/push.md` |
| 3, "pr", "pull request" | `workflows/pr.md` |
| 4, "ship", "all" | commit → push → pr (sequential) |
</routing>
<workflows_index>
| Workflow | Purpose |
|----------|---------|
| commit.md | Stage changes and create commit |
| push.md | Push to remote, create branch if needed |
| pr.md | Create pull request with gh CLI |
</workflows_index>