SkillsApr 28, 2026·2 min read

/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.

TL;DR
/commit-push-pr is a Claude Code slash command that runs git status, explicit staging, a conventional-commit message, push with upstream, and gh pr create in one shot. It is inspired by Boris Cherny's documented setup and ships the same safety contract: never git add -A, never amend a published commit, never --no-verify, and stop before pushing to main, force-pushing, or staging more than 20 files at once.
§01

What /commit-push-pr Does in One Shot

/commit-push-pr is a community-written Claude Code slash command that compresses the daily ship sequence — git status, git diff, git add <file>, git commit, git push, gh pr create — into a single keystroke. After Claude finishes a feature, you type /commit-push-pr "Add audit logging for admin panel" and Claude walks the exact 8-step contract embedded in the prompt: summarize the diff, stage explicitly named files, generate a conventional-commit message, create the commit, set upstream if missing, push, open the PR via GitHub CLI, and print the PR URL.

The pattern is documented by Boris Cherny on howborisusesclaudecode.com as one of his most-used shortcuts. The Pragmatic Engineer interview with Boris confirms the slash-command-driven workflow is core to how the creator of Claude Code himself ships code daily. Anthropic's own slash-command documentation specifies that custom commands live in .claude/commands/*.md and accept arguments via the $ARGUMENTS placeholder, which is exactly the wiring this skill uses.

This page is the canonical reference for the open-source equivalent — Boris's private slash-command file is not published, so the TokRepo Skill Factory community wrote a behavior-equivalent version with the same safety contract.

§02

Why a Slash Command Beats a Bash Alias

A shell alias like alias ship='git add -A && git commit -m wip && git push' skips the three things that matter most: a meaningful commit message, explicit file staging, and a PR description tied to the diff. The /commit-push-pr slash command keeps Claude in the loop so the commit message follows the Conventional Commits 1.0.0 specification (feat:, fix:, refactor:, docs:), the staging list excludes secrets and large binaries, and the PR body contains a Summary plus a Test Plan checklist generated from the actual changes.

Five concrete defaults make this safer than a bash one-liner:

  1. Never git add -A or git add . — files are listed by name, so a stray .env or dist/ blob never reaches origin.
  2. Never --amend — published commits stay immutable; pre-commit hook failures result in a fresh follow-up commit, not a force-push-amend dance.
  3. Never --no-verify — pre-commit hooks run; if they fail, you fix the cause, not the symptom.
  4. Stop before pushing to main/master — the command halts and asks, because pushing to main bypasses PR review entirely.
  5. Stop before staging more than 20 files — a 20+ file commit usually means a stale workspace, not a feature.

These defaults map 1:1 to the rules in Anthropic's official Claude Code best-practices guidance, which calls out --no-verify and force-pushing as red-flag operations.

§03

Install /commit-push-pr in 3 Steps

The install path is the standard Claude Code custom-command location described in the Anthropic Claude Code docs.

  1. Save the command file. Drop the markdown file at .claude/commands/commit-push-pr.md for project scope, or ~/.claude/commands/commit-push-pr.md for user-global scope. Anthropic's slash-command spec treats both locations as valid; project scope wins on conflict.
  2. Reload commands. Run /commands reload inside Claude Code, or restart the session. The command appears in the / autocomplete list with the description field as its hint.
  3. Ship a branch. After Claude finishes coding, run /commit-push-pr "Add audit logging for admin panel". The optional argument becomes the PR title; if omitted, Claude auto-generates one from the commit message.

The full prompt template (verbatim from the skill) is shown in the next section.

§04

The Prompt Template (Behavior Contract)

Below is the actual commit-push-pr.md content. Every step is non-skippable and the order is enforced.

---
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)

The YAML frontmatter description and argument-hint follow the Claude Code slash-command schema documented by Anthropic, so the command shows up in autocomplete with the right hint label.

§05

Conventional Commits, Built In

Step 3 of the contract — "Generate a one-line commit message in conventional-commit form" — is the single biggest change-logging upgrade. Conventional Commits 1.0.0 defines the prefixes feat:, fix:, refactor:, docs:, chore:, test:, perf:, build:, ci:, style:, plus optional scope and ! for breaking changes. Tools like release-please, semantic-release, and git-cliff parse these prefixes to compute the next semver bump and generate a CHANGELOG.

Here is the example session from the skill:

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

Note how the commit message leads with the why (multi-tenant audit log with retention policy) rather than the what (added 4 files). That is a direct rule from the prompt: "Lead with WHY, not WHAT."

§06

How the GitHub CLI Step Works

Step 7 invokes gh pr create, which is GitHub's official command-line tool for creating pull requests. The GitHub CLI manual specifies that gh pr create --title "..." --body "..." opens a PR against the default base branch, automatically inferring head from the current branch. The skill passes the title via $ARGUMENTS (or auto-generates it) and constructs the body as:

  • A short Summary section (1–3 bullet points derived from the diff).
  • A Test Plan checklist (markdown checkboxes pulled from changed test files or implied from changed source files).

For GitLab users, the skill explicitly notes you swap gh pr create for glab mr create — the GitLab CLI command for opening merge requests, documented in the official glab reference.

§07

Comparison: One-Shot Slash vs Manual vs Aliases

CapabilityManual git + ghBash alias ship/commit-push-pr
Conventional Commits prefixManual typingHardcoded wipGenerated from diff
Explicit file stagingYes (if disciplined)No (-A typical)Always (rule 2)
Refuse --amend on published commitsManual disciplineNot enforcedHard rule (rule 4)
Refuse --no-verifyManual disciplineNot enforcedHard rule (rule 4)
Stop before push to mainManual disciplineNot enforcedHard rule
PR body with Summary + Test PlanManual writeNoneGenerated from diff
Sets upstream on first pushManual -u originOften forgottenAuto (rule 5)
Token cost per ship00~3–8k tokens

The ~3–8k token cost is the trade-off: each invocation reads the diff, drafts a message, and composes a PR body. For teams already inside Claude Code, the time savings dwarf the token cost — a typical manual ship takes 2–5 minutes of context-switching.

§08

Edge Cases the Contract Handles

The "Stop and ask me before" block covers three high-risk operations:

  • Force-pushing. Force-push rewrites history on the remote, which destroys other developers' work if they have already pulled the branch. The Pro Git book chapter on rewriting history covers the failure mode in detail.
  • Pushing to main/master. Direct pushes to the trunk branch bypass PR review, CI gates, and protected-branch rules. GitHub's branch-protection documentation lists "Require a pull request before merging" as the canonical guard.
  • Committing more than 20 files at once. A 20+ file commit usually means the workspace contains uncommitted leftovers from a previous task, or a generated artifact (e.g., dist/, node_modules/, generated SDK files) leaked into staging.

When any of these fire, Claude pauses and prints the diff summary so you can decide.

§09

Pairing /commit-push-pr With Review and Verification

/commit-push-pr only ships — it does not review. Pair it with a code-review subagent and an end-to-end verification step for a complete pre-merge pipeline:

  1. Run /go-verify (or equivalent) to land the diff with simplification and verification baked in.
  2. Run /commit-push-pr to ship the cleaned diff to a PR.
  3. Spawn a review subagent on the open PR for an architectural pass.
  4. Auto-respond to PR review comments with a babysit loop while you go to lunch.

The TokRepo featured catalog includes companion skills for each step (linked at the bottom of this page).

§10

FAQ Quick Answers

The skill ships with five built-in FAQs covering staging, branch protection, amend behavior, attribution to Boris, and CLI dependencies. They are reproduced in the structured FAQ section below.

§11

Source Acknowledgement

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

Boris Cherny is the original creator of Claude Code at Anthropic. The Pragmatic Engineer and Get Push To Prod interviews (2025) document his daily slash-command-driven workflow, including the /commit-push-pr, /go-verify, and /loop patterns now widely re-implemented in the community.

Frequently Asked Questions

Will /commit-push-pr run git add -A on my workspace?+

No. Rule 2 of the prompt forbids git add -A and git add . The command stages files by explicit name only, which prevents accidentally shipping .env files, build artifacts, or large binaries to the remote.

What happens if I run it on the main or master branch?+

The command stops and asks before pushing. Pushing directly to main bypasses pull request review and any branch-protection CI gates, so the prompt treats main and master as confirm-required targets, not auto-targets.

Does it amend the previous commit when a hook fails?+

Never. Rule 4 forbids git commit --amend in all cases. If a pre-commit hook fails, the commit did not happen, so amending would modify the prior commit. The fix is to address the hook failure and create a fresh new commit on top.

Is this Boris Cherny's actual slash command file?+

No. Boris's private slash-command file is not open-sourced. This entry is a community-written behavior-equivalent based on the publicly documented pattern from howborisusesclaudecode.com and the Pragmatic Engineer interview with Boris.

Do I need GitHub CLI installed to use this skill?+

Yes for the PR step. Step 7 invokes gh pr create from GitHub CLI. For GitLab repos, swap gh pr create for glab mr create. Steps 1 through 6 only require git, so commit and push work even without gh installed.

Can I skip pre-commit hooks with --no-verify?+

The skill never passes --no-verify. Rule 4 enforces this. If a hook is wrong, fix the hook or temporarily disable it in your local Git config, then run the command again. Skipping hooks via the slash command is not supported by design.

🙏

Source & Thanks

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

Citations:

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.