Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 28, 2026·2 min de lecture

/commit-push-pr — One-Shot Commit + Push + PR Slash Command

Open-source slash command that runs git status, commits, pushes, and opens a PR in one shot. Inspired by Boris Cherny's /commit-push-pr setup.

Introduction

/commit-push-pr is a one-shot ship command. Boris Cherny calls it out by name on howborisusesclaudecode.com as one of the most-used shortcuts in his daily setup: instead of typing git status && git diff && git add && git commit && git push && gh pr create every time, you type /commit-push-pr and Claude handles the entire ship sequence with a final review prompt before push.

The community version below adds the same default safety: it stages explicitly, generates a sensible commit message from the diff, and asks for confirmation before opening the PR.

Works with: Claude Code 1.x, GitHub CLI (gh).


How /commit-push-pr Works

Save to .claude/commands/commit-push-pr.md:

---
description: Run status, commit, push, and open a PR in one shot
argument-hint: [PR title]
---

You will ship the current branch end-to-end. Follow this exact sequence — do not skip steps:

1. Run `git status --short` and `git diff --stat`. Show me the change summary.
2. Stage explicitly named files only — never `git add -A` or `.`. Skip `.env`, secrets, large binaries.
3. Generate a one-line commit message in conventional-commit form (feat:/fix:/refactor:/docs:). Lead with WHY, not WHAT.
4. Create the commit (NEVER amend, NEVER `--no-verify`).
5. If the local branch has no upstream, set it: `git push -u origin <branch>`.
6. Push.
7. Run `gh pr create`:
   - Title: $ARGUMENTS if provided, else auto-generated from the commit message.
   - Body: a short Summary section + a Test Plan checklist derived from the diff.
8. Print the PR URL.

Stop and ask me before:
- Force-pushing
- Pushing to main/master
- Committing more than 20 files at once (likely a stale workspace)

Behavior contract

  • Never amends a previously published commit.
  • Never uses --no-verify to skip hooks.
  • Never stages with -A or . (security: avoids accidental secrets).
  • Always asks before pushing to main/master.

Example session

You:    "/commit-push-pr Add multi-tenant audit logs"
Claude: -> git status: 4 files changed, 312 insertions
        -> Stages: src/audit/{logger,schema}.ts tests/audit.spec.ts migrations/0042_audit.sql
        -> Commit: "feat(audit): multi-tenant audit log with retention policy"
        -> Push to origin/feat-audit-logs
        -> gh pr create: PR #482 opened
        -> https://github.com/acme/api/pull/482

FAQ

Q: Will this git add -A? A: No — it stages files by name. Avoids accidentally shipping .env or build artifacts.

Q: What if I'm on main/master? A: It will stop and ask before pushing. Pushing to main directly bypasses PR review.

Q: Does it amend the previous commit? A: Never. Always creates a NEW commit. Pre-commit hook failures result in a fresh commit, not an amend.

Q: Is this Boris's actual command? A: No — community-written equivalent. Boris's private slash command file is not open-sourced. This entry captures the documented pattern.

Q: Do I need GitHub CLI? A: Yes — the PR step uses gh pr create. For GitLab, swap in glab mr create.


🙏

Source et remerciements

Inspired by Boris Cherny's /commit-push-pr slash command on howborisusesclaudecode.com.

Citations:

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires