Git Commit & PR Automation
Three streamlined git workflows: commit with an auto-drafted message matching your repo's style, ship a full commit-push-PR in one step, and clean up branches deleted on the remote.
You're mid-flow on a feature and git wants your full attention — stage files, write a message, remember the branch naming convention, push, then switch tabs to open a PR with a description nobody will read anyway. Every context switch costs you the thread you were pulling on.
Who it's for: developers who want cleaner git history, teams establishing commit conventions, engineers who create PRs frequently, anyone whose local branch list is cluttered with merged branches
Example
"Ship this as a PR" → New branch created if you're on main, a commit written to match your repo's existing message style, pushed to origin, and a PR opened with a summary and test-plan checklist covering the whole branch history — not just the last commit
CLAUDE.md Template
New here? 3-minute setup guide → | Already set up? Copy the template below.
npx ccplaybooks add git-commit-pr-automation# Git Commit & PR Automation
## Your Role
You handle my git mechanics so I don't context-switch out of the work. Three workflows: commit, ship a PR, and clean up stale branches.
---
## Workflow 1: Commit
When I ask you to commit:
Get new playbooks like this one
One email a week with new Claude Code workflows. Free, like everything here.
No spam. Unsubscribe anytime.
What This Does
Three focused git workflows in one CLAUDE.md: /commit for a single well-formed commit, /commit-push-pr for the full ship sequence, and a [gone]-branch cleanup routine. Each reads actual repo context — git status, git diff, recent commit style — before acting, rather than guessing at conventions.
Quick Start
Step 1: Navigate to Your Repository
cd ~/your-project
Step 2: Download the Template
Click Download above, then:
mv ~/Downloads/CLAUDE.md ./
Step 3: Use It
claude
Then say: "Commit these changes", "Ship this as a PR", or "Clean up my stale branches".
The Three Workflows
Commit
Reads git status, git diff HEAD, current branch, and the last 10 commits to learn your message style — then stages relevant files and commits, matching your repo's conventions rather than imposing generic ones.
Commit, Push, and Open a PR
Creates a new branch if you're on main (never commits directly to the default branch), commits, pushes to origin, and opens a PR with gh pr create. The PR description covers the entire branch history, not just the latest commit — summary bullets plus a checkable test plan.
Clean Up Gone Branches
Finds local branches whose remote counterpart was deleted (git branch -v shows [gone]), removes any associated worktrees first, then deletes the branches. Safe to run repeatedly — it only ever touches branches already gone from the remote.
Tips & Best Practices
- Never commits secrets —
.env,credentials.json, and anything with a hardcoded key gets excluded automatically - Requires
ghCLI, authenticated, for the push-PR workflow (gh auth login) - Run
git fetch --prunefirst if the cleanup workflow reports nothing to clean — branches only show as[gone]after the remote tracking refreshes - Combine them:
/commitduring development,/commit-push-prwhen ready to ship,/clean_goneweekly for maintenance
Troubleshooting
Commit comes back empty — verify you actually have staged or unstaged changes with git status.
PR creation fails — confirm gh is installed and authenticated, and that the repo has an origin remote pointing to GitHub.
Cleanup finds no [gone] branches — run git fetch --prune to refresh remote-tracking branches first.