Home
cd ../playbooks
Developer ToolsBeginner

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.

5 minutes
By AnthropicSource
#git#commit#pull-request#github-cli#branch-cleanup#official

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.

Or install from your terminal:
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.

README.md

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 gh CLI, authenticated, for the push-PR workflow (gh auth login)
  • Run git fetch --prune first if the cleanup workflow reports nothing to clean — branches only show as [gone] after the remote tracking refreshes
  • Combine them: /commit during development, /commit-push-pr when ready to ship, /clean_gone weekly 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.

$Related Playbooks

Developer Tools

Hookify Guardrails

Create custom Claude Code guardrails with lightweight markdown rule files instead of hand-editing hooks.json — pattern matching, no restart required, rules live-load on the next tool call.

5 minutes
Beginner
Developer Tools

GEO Schema: Structured Data for AI Citation

Audit and generate schema.org JSON-LD built for AI comprehension, with a sameAs entity graph, knowsAbout topics, and a 0-100 scoring rubric

10 minutes
Intermediate
Developer Tools

GEO Technical SEO Audit: 8 Categories, 100 Points

A scored technical audit covering crawlability, indexability, security, Core Web Vitals, and the server-side rendering check that decides whether AI crawlers see your content at all

15 minutes
Advanced
Developer Tools

GEO Toolkit Updater

Pull the latest geo-seo-claude skills, agents, scripts, and schema templates from upstream, with a diff summary before anything is overwritten

5 minutes
Beginner
Developer Tools

GPT Taste Skill: Strict Anti-Slop UI Rules

A stricter, more deterministic anti-slop frontend ruleset with GSAP motion patterns, despite the GPT-oriented name it works as a standard CLAUDE.md in Claude Code

5 minutes
Intermediate
Developer Tools

GitHub Contributor

A phase-based playbook for shipping pull requests maintainers actually merge — discovery, CONTRIBUTING compliance, PR-size checks, minimal diffs, and post-submission interaction.

20 minutes
Intermediate
Developer Tools

GitHub Operations

Comprehensive GitHub operations using the gh CLI and REST/GraphQL APIs — PRs, issues, repositories, workflows, and bulk operations across public and Enterprise GitHub.

10 minutes
Intermediate
Developer Tools

i18n Expert

Set up, audit, and enforce internationalization in UI codebases — install the i18n framework, replace hard-coded strings, ensure locale coverage, and validate key parity and pluralization.

20 minutes
Intermediate
Developer Tools

Idea-to-Design Brainstorming Gate

A hard approval gate before any implementation — classify every request as a Spike, Bounded change, or Architectural project, then design collaboratively and never write code until the design is explicitly approved.

5 minutes
Intermediate
Developer Tools

Improve: Audit Your Codebase and Write the Plans

Turns Claude into a read-only senior advisor that audits a repo, ranks findings by leverage, and writes self-contained implementation plans to disk for cheaper models to execute

10 minutes
Intermediate
Developer Tools

Image-to-Code: Design Reference to Implementation

An image-first workflow that forces Claude to establish a visual reference, deeply analyze it, and only then write frontend code that matches it

10 minutes
Intermediate
Developer Tools

Imagegen Frontend Mobile: App Screen & Flow Reference Generator

An image-direction rule set that produces premium, consistent iOS/Android app screen mockups and multi-screen user flows, ready to hand to a coding agent for implementation

10 minutes
Intermediate

Browse all Developer Tools playbooks →