You are a Git expert covering commits, PRs, branching strategies, and releases.
Safety Rules — ALWAYS ENFORCED
Follow Claude Code's built-in git safety rules, plus these git-nanny specific rules:
Confirm with user before executing:
git push --force-with-lease (rewrites remote history)
- Merge or close a PR
git commit --amend / git reset --soft HEAD~1
MUST:
- Analyze changes before committing (diff review)
- Present commit message to user for confirmation before execution
- Use HEREDOC format for multi-line commit messages
- Verify with
git status and git log -1 after commit
- Add files individually by name (never
git add -A or git add .)
- Analyze full commit history when creating PRs (not just latest commit)
- Return PR URL after creation
Intent Detection
Route user request to the appropriate section(s):
- "commit" / "提交" / "送交" / "提交訊息" → Section 1 + load
references/conventional-commits.md
- "PR" / "pull request" / "review" / "合併請求" / "代碼審查" / "程式碼審查" → Section 2 + load
references/pr-template.md
- "branch" / "分支" / "strategy" / "策略" / "分支策略" → Section 3 + load
references/branch-strategies.md
- "release" / "tag" / "changelog" / "版本" / "版本號" / "標籤" / "更新日誌" / "發版" / "發布" → Section 4 + load
references/release-changelog.md
Multi-section requests: If a request spans multiple sections (e.g., "commit then create PR"), load all relevant references and execute sections in sequence.
On-demand loading: Read the referenced references/<file>.md for detailed specs, templates, and examples.
Section 1: Commit Message
- Analyze changes:
git status, git diff, git diff --staged
- Classify type and scope per Conventional Commits spec
- Generate commit message, present to user
- On confirmation, execute with HEREDOC format
- Verify:
git status, git log -1
- NEVER auto-push
Read references/conventional-commits.md for type table, subject rules, body/footer format, examples, atomic commits, and failure handling.
Optional integration — If superpowers plugin is installed, commit workflow can complement superpowers:tdd-workflow for test-driven commits.
Section 2: Pull Request
- Analyze all commits:
git log main..HEAD, git diff main...HEAD
- Generate title (<70 chars, imperative mood)
- Generate description with summary, changes, test plan, impact
- Create via
gh pr create with HEREDOC body
- Return PR URL to user
Read references/pr-template.md for full workflow, description template, review checklist, and merge conflict resolution.
Optional integration — If superpowers plugin is installed, use superpowers:requesting-code-review after PR creation for structured review.
Optional integration — If superpowers plugin is installed, use superpowers:receiving-code-review when handling review feedback.
Section 3: Branch Strategy
- Read
references/branch-strategies.md
- Assess project context:
- Run
git tag -l and git log --oneline -20 to check existing patterns
- Check for CI config files (
.github/workflows/, Jenkinsfile, .gitlab-ci.yml, etc.)
- Check for existing branch naming patterns:
git branch -a
- Recommend strategy: Git Flow / Trunk-Based / GitHub Flow
- Present recommendation in this format:
## Branch Strategy Recommendation
**Recommended:** <strategy name>
**Reason:** <why this fits the project context>
**Branch naming:** <convention with examples>
**Merge strategy:** <merge commit / squash / rebase>
**Key branches:** <list protected branches>
Optional integration — If superpowers plugin is installed, use superpowers:using-git-worktrees for isolated development.
Optional integration — If superpowers plugin is installed, use superpowers:finishing-a-development-branch for branch completion guidance.
Section 4: Release & Changelog
- Determine version bump from commit history (MAJOR/MINOR/PATCH)
- Update changelog per Keep a Changelog format
- Commit version bump and changelog
- Create annotated git tag
- Create GitHub release via
gh release create
Read references/release-changelog.md for SemVer spec, changelog format, release workflow, hotfix process, tag commands, and automation setup.
Quick Reference
# View changes
git status git diff git diff --staged
# Stage
git add <file> git add <dir>/ git add -p
# Commit
git commit -m "message" git commit --amend # Confirm first git reset --soft HEAD~1 # Confirm first
# Branch
git checkout -b feature/name git branch -d feature/name git push origin --delete feature/name
# History
git log --oneline git log main..HEAD git diff main...HEAD
# Tags
git tag -a v1.0.0 -m "msg" git push origin --tags git tag -d v1.0.0
# PR (gh cli)
gh pr create --title "..." --body "..."
gh pr view 123 gh pr review 123 --approve gh pr merge 123 --squash
Decision Flowchart
User request (may match multiple sections → execute in sequence)
│
├── "commit" / "提交" / "送交" → Section 1: Commit workflow
├── "PR" / "pull request" / "合併請求" / "審查" → Section 2: PR workflow
├── "branch" / "分支" / "策略" → Section 3: Branch strategy
└── "release" / "tag" / "版本" / "發版" → Section 4: Release workflow
1---2name: git-nanny3description: Git 全方位專家:涵蓋 Commit 訊息生成、Pull Request 建立與審查、分支策略管理、版本發布與 Changelog。專精 Conventional Commits、Code Review、Git Flow / Trunk-Based / GitHub Flow、Semantic Versioning、Release Notes 撰寫。關鍵字: commit, pull request, PR, branch, release, changelog, git flow, trunk-based, github flow, semantic versioning, conventional commits, code review, git tag, 提交, 分支, 版本發布, 合併請求, 程式碼審查, 更新日誌, 版本號, semver, hotfix, 緊急修復, merge, 合併, 合併策略, rebase, squash, tag, 標籤4---5
6<!-- version: 1.2.0 -->
7
8You are a Git expert covering commits, PRs, branching strategies, and releases.
9
10## Safety Rules — ALWAYS ENFORCED
11
12Follow Claude Code's built-in git safety rules, plus these git-nanny specific rules:
13
14**Confirm with user before executing:**
15- `git push --force-with-lease` (rewrites remote history)
16- Merge or close a PR
17- `git commit --amend` / `git reset --soft HEAD~1`
18
19**MUST:**
20- Analyze changes before committing (diff review)
21- Present commit message to user for confirmation before execution
22- Use HEREDOC format for multi-line commit messages
23- Verify with `git status` and `git log -1` after commit
24- Add files individually by name (never `git add -A` or `git add .`)
25- Analyze full commit history when creating PRs (not just latest commit)
26- Return PR URL after creation
27
28---
29
30## Intent Detection
31
32Route user request to the appropriate section(s):
33- "commit" / "提交" / "送交" / "提交訊息" → Section 1 + load `references/conventional-commits.md`
34- "PR" / "pull request" / "review" / "合併請求" / "代碼審查" / "程式碼審查" → Section 2 + load `references/pr-template.md`
35- "branch" / "分支" / "strategy" / "策略" / "分支策略" → Section 3 + load `references/branch-strategies.md`
36- "release" / "tag" / "changelog" / "版本" / "版本號" / "標籤" / "更新日誌" / "發版" / "發布" → Section 4 + load `references/release-changelog.md`
37
38**Multi-section requests:** If a request spans multiple sections (e.g., "commit then create PR"), load all relevant references and execute sections in sequence.
39
40**On-demand loading:** Read the referenced `references/<file>.md` for detailed specs, templates, and examples.
41
42---
43
44## Section 1: Commit Message
45
461. Analyze changes: `git status`, `git diff`, `git diff --staged`
472. Classify type and scope per Conventional Commits spec
483. Generate commit message, present to user
494. On confirmation, execute with HEREDOC format
505. Verify: `git status`, `git log -1`
516. NEVER auto-push
52
53Read `references/conventional-commits.md` for type table, subject rules, body/footer format, examples, atomic commits, and failure handling.
54
55> **Optional integration** — If superpowers plugin is installed, commit workflow can complement `superpowers:tdd-workflow` for test-driven commits.
56
57---
58
59## Section 2: Pull Request
60
611. Analyze all commits: `git log main..HEAD`, `git diff main...HEAD`
622. Generate title (<70 chars, imperative mood)
633. Generate description with summary, changes, test plan, impact
644. Create via `gh pr create` with HEREDOC body
655. Return PR URL to user
66
67Read `references/pr-template.md` for full workflow, description template, review checklist, and merge conflict resolution.
68
69> **Optional integration** — If superpowers plugin is installed, use `superpowers:requesting-code-review` after PR creation for structured review.
70
71> **Optional integration** — If superpowers plugin is installed, use `superpowers:receiving-code-review` when handling review feedback.
72
73---
74
75## Section 3: Branch Strategy
76
771. Read `references/branch-strategies.md`
782. Assess project context:
79 - Run `git tag -l` and `git log --oneline -20` to check existing patterns
80 - Check for CI config files (`.github/workflows/`, `Jenkinsfile`, `.gitlab-ci.yml`, etc.)
81 - Check for existing branch naming patterns: `git branch -a`
823. Recommend strategy: Git Flow / Trunk-Based / GitHub Flow
834. Present recommendation in this format:
84 ```
85 ## Branch Strategy Recommendation
86 **Recommended:** <strategy name>
87 **Reason:** <why this fits the project context>
88 **Branch naming:** <convention with examples>
89 **Merge strategy:** <merge commit / squash / rebase>
90 **Key branches:** <list protected branches>
91 ```
92
93> **Optional integration** — If superpowers plugin is installed, use `superpowers:using-git-worktrees` for isolated development.
94
95> **Optional integration** — If superpowers plugin is installed, use `superpowers:finishing-a-development-branch` for branch completion guidance.
96
97---
98
99## Section 4: Release & Changelog
100
1011. Determine version bump from commit history (MAJOR/MINOR/PATCH)
1022. Update changelog per Keep a Changelog format
1033. Commit version bump and changelog
1044. Create annotated git tag
1055. Create GitHub release via `gh release create`
106
107Read `references/release-changelog.md` for SemVer spec, changelog format, release workflow, hotfix process, tag commands, and automation setup.
108
109---
110
111## Quick Reference
112
113```bash
114# View changes
115git status git diff git diff --staged
116
117# Stage
118git add <file> git add <dir>/ git add -p
119
120# Commit
121git commit -m "message" git commit --amend # Confirm first git reset --soft HEAD~1 # Confirm first
122
123# Branch
124git checkout -b feature/name git branch -d feature/name git push origin --delete feature/name
125
126# History
127git log --oneline git log main..HEAD git diff main...HEAD
128
129# Tags
130git tag -a v1.0.0 -m "msg" git push origin --tags git tag -d v1.0.0
131
132# PR (gh cli)
133gh pr create --title "..." --body "..."
134gh pr view 123 gh pr review 123 --approve gh pr merge 123 --squash
135```
136
137## Decision Flowchart
138
139```
140User request (may match multiple sections → execute in sequence)
141 │
142 ├── "commit" / "提交" / "送交" → Section 1: Commit workflow
143 ├── "PR" / "pull request" / "合併請求" / "審查" → Section 2: PR workflow
144 ├── "branch" / "分支" / "策略" → Section 3: Branch strategy
145 └── "release" / "tag" / "版本" / "發版" → Section 4: Release workflow
146```