Provide this file (and ideally git-commit-msg.md) to have the AI: branch → commit → push → open a PR. Commit messages follow git-commit-msg.md. PR title/body derive from those commits (and the full branch diff).
- Inspect working tree / branch vs base (
master) - Create a branch if needed (or use current topic branch)
- Generate commit message via
git-commit-msg.md, then commit - Push branch to
originwith upstream tracking - Open a PR with
gh pr create— title + body derived from the commit(s)
- Attach both when possible:
git-commit-msg.md— commit message format (required for step 3)git-pull-request.md— this file (branch / push / PR)
- User must explicitly ask to open a PR / push / commit (or paste the quick prompt below). Do not push or create a PR unless instructed.
- Base branch defaults to
masterunless the user names another.
Run in parallel:
git status
git diff && git diff --cached
git diff --stat HEAD
git branch -vv
git rev-parse --abbrev-ref HEAD
git rev-parse --abbrev-ref @{upstream} 2>/dev/null || true
git log -5 --oneline
git log master..HEAD --oneline # commits already on branch (if any)
git diff master...HEAD --stat # full PR-bound diff once commits existDecide:
| Situation | Action |
|---|---|
| Uncommitted changes | Stage + commit (step 3) before push/PR |
On master / main with changes |
Create topic branch first (step 2) |
| Already on topic branch, clean, ahead of remote | Push + PR (steps 4–5) |
| No changes and no commits ahead of base | Stop — nothing to PR |
Prefer git switch over git checkout (branch moves only — safer, no path/restore confusion).
If still on master (or user asks for a new branch):
git switch -c <type>/<short-kebab-description>If switching onto an existing topic branch (no create):
git switch <type>/<short-kebab-description>Branch naming:
- Prefix with commit type:
feat/,fix/,refactor/,docs/,chore/,perf/,ci/,build/ - Short kebab case from the main change:
feat/form-status-button,fix/auth-redirect - Match the
type:that will lead the commit message
If already on a good topic branch, keep it.
Do not use git checkout -b / bare git checkout <branch> here. Use git restore / git restore --staged only if discarding or unstaging file changes (rare in this workflow; never confuse with branch switch).
Follow git-commit-msg.md exactly — do not invent a different commit style.
- Analyze staged + unstaged diffs (and
--stat) - Produce message:
type:+ newline + emoji bullets (scale by file count per that file) - Stage relevant files (never secrets:
.env, credentials, etc.) - Commit with HEREDOC:
git add <files>
git commit -m "$(cat <<'EOF'
type:
emoji bullet one
emoji bullet two
EOF
)"
git statusRules (same as commit guide + safety):
- Never
--no-verify/ skip hooks unless user asks - Never amend unless user asks and amend safety rules pass
- Never update git config
- If pre-commit fails: fix, then new commit (do not amend failed commit)
If multiple logical commits already exist on the branch, keep them; do not squash unless asked. Still use git-commit-msg.md for any new commit.
git push -u origin HEAD- First push on a branch: always
-u/--set-upstream(same thing) - Later pushes on same branch:
git pushis enough (upstream already set) - Prefer
HEADover hard-coding the branch name — tracks whatever is checked out - Never force-push to
master/main - Never
--force/--force-with-leaseunless user explicitly requests
Source of truth (in priority order):
- Commit messages on the branch (
git log master..HEAD) — already ingit-commit-msg.mdformat - Full diff vs base (
git diff master...HEAD) — for anything commits understate - Prefer synthesizing from commits; do not ignore extra commits or drift
- One line, ≤ ~72 chars preferred
- Pattern:
<type>: <imperative summary> - Use the same type as the primary / most impactful commit (
feat,fix,refactor, …) - Summary = compressed why/what of the branch — no emoji in the title
- If one commit: title can mirror that commit’s type + first-bullet gist
- If many commits: pick dominant type; summarize the theme (not a comma-list of every bullet)
Examples:
feat: shared StatusButton form submit feedback
fix: safe redirectTo on login after host auth fail
refactor: flatten D1 migrations while keeping snapshots
Always use this structure (HEREDOC for gh):
## Summary
- <bullet derived from commit emoji lines / theme>
- <bullet>
- <bullet>
## Test plan
- [ ] <concrete check>
- [ ] <concrete check>Summary bullets:
- Derive from emoji bullets across branch commits (and diff if needed)
- Strip leading emojis in Summary (or keep them — prefer keep emojis so PR body matches commit style)
- Keep the same priority order: most impactful first
- Scale like commits:
- 1 commit / small: 2–3 bullets
- Medium: 3–4
- Large / multi-commit: 5–7 (cap ~8; consolidate noise)
- Do not paste the raw
type:line into Summary; type belongs in the title
Test plan:
- Checklist of real verification steps for this diff (UI paths,
bun run typecheck/bun run check, migrate/seed if schema changed, etc.) - Prefer actionable
bun/ UI steps over vague “test everything”
gh pr create --title "<type>: <summary>" --body "$(cat <<'EOF'
## Summary
✨ …
🎨 …
🔧 …
## Test plan
- [ ] …
- [ ] …
EOF
)"After create:
- Return the PR URL to the user
- Do not merge unless asked
Optional flags (only if user asks):
--draft--base <branch>--reviewer <user>
Commit (git-commit-msg.md) |
Pull request |
|---|---|
Leading feat: / fix: / … |
Title prefix feat: / fix: / … |
| Emoji bullet lines | Summary bullets (same emojis, same order) |
| Multiple commits on branch | Merge themes into one title type; union bullets, dedupe |
| File-count scaling for bullets | Same scaling for Summary length |
| Common emoji meanings | Reuse from git-commit-msg.md |
Single-commit PR (ideal):
Commit:
feat:
✨ Added FormActionResult and StatusButton helpers
🎨 Wired auth and host forms to fetcher status
📝 Synced README badges and scripts
PR title:
feat: shared StatusButton form submit feedback
PR body Summary:
## Summary
✨ Added FormActionResult and StatusButton helpers
🎨 Wired auth and host forms to fetcher status
📝 Synced README badges and scriptsMulti-commit PR: fold bullets under one dominant type; drop duplicate themes.
- Do not commit or push secrets
- Do not force-push
master/main - Do not open a PR with an empty Summary or empty Test plan
- Do not use Interactive git (
-i) - Do not use
git checkoutfor branch create/switch — usegit switch/git switch -c - Do not rewrite published history unless user asks
- If push/PR fails on auth/network: report error; do not invent a “successful” URL
Copy into chat with git-commit-msg.md + this file attached:
Follow git-commit-msg.md and git-pull-request.md: inspect changes, git switch -c a topic branch if on master, commit using the emoji commit format, push -u to origin, and open a gh PR. Derive the PR title (type: summary, no emoji) and Summary bullets from the commit message(s); add a concrete Test plan. Return the PR URL.
Partial prompts:
- Commit only: attach
git-commit-msg.mdonly (or say “commit only”) - PR only (already pushed): “open PR from current branch using git-pull-request.md”
- Draft PR: add “create as draft”
- Branch not
master/main - Commit(s) follow
git-commit-msg.md - Remote tracking set (
-uon first push) - PR title =
type: summary(no emoji) - PR Summary bullets align with commit bullets
- Test plan present with checkboxes
- User received PR URL