# /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. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: # /commit-push-pr — One-Shot Commit + Push + PR Slash Command ## Quick Use 1. Save the file below to `.claude/commands/commit-push-pr.md` in your project (or `~/.claude/commands/` for global). 2. Restart Claude Code (or `/commands reload`). 3. After Claude finishes a feature, run: ``` /commit-push-pr "Add audit logging for admin panel" ``` The optional argument becomes the PR title; if omitted, the command auto-generates one from the diff. > Inspired by Boris Cherny's `/commit-push-pr` slash command on howborisusesclaudecode.com — community-written equivalent. --- ## Intro `/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`: ```markdown --- 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 `. 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 & Thanks > Inspired by Boris Cherny's `/commit-push-pr` slash command on howborisusesclaudecode.com. Citations: - howborisusesclaudecode.com (slash commands section) - Pragmatic Engineer interview: https://newsletter.pragmaticengineer.com/p/building-claude-code-with-boris-cherny - Get Push To Prod: https://getpushtoprod.substack.com/p/how-the-creator-of-claude-code-actually ## 快速使用 1. 落 `.claude/commands/commit-push-pr.md` 2. `/commands reload` 3. 写完代码后:`/commit-push-pr "提交说明可选"` —— 一条命令走完 status / 暂存 / commit / push / 开 PR。 ## 边界 - 永不 `git add -A` / `.`(避免误传 `.env` 等密钥) - 永不 amend、永不 `--no-verify` - push 到 main/master 前先停下问你 --- Source: https://tokrepo.com/en/workflows/commit-push-pr-one-shot-slash-command-91a8fec2 Author: Skill Factory