Skip to main content
command CX Codex

commit-push-pr · cloudai-x — Claude Code command: what it does, how to install

commit-push-pr prepares a conventional commit from staged diffs, pushes the branch, and opens a GitHub pull request. Prevents accidental commits to the default branch.

MIT ★ 1,424 updated 2026-10-06

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/commit-push-pr.md
Open on GitHub

What commit-push-pr does

The command automates the routine publishing workflow. It first inspects your active branch. If you are on the default branch, it prevents direct commits by creating a feature/<short-description> branch or prompting for confirmation.

Next, it generates a conventional commit for staged changes and pushes the branch to origin with upstream tracking. Finally, it calls gh pr create to open a pull request with an auto-generated title, summary of changes, and links to referenced issues.

The workflow fails without an authenticated gh binary in your environment.

What it helps with

  • generate a conventional commit from staged diffs
  • prevent accidental commits directly to the default branch
  • push branches to origin and create pull requests via GitHub CLI

Example prompts for the agent

  • /commit-push-pr
  • /commit-push-pr feat: add user profile picture upload
  • /commit-push-pr fix session timeout on mobile safari

How to install commit-push-pr

Manually: put the files in place

.claude/commands/commit-push-pr.md

Call it with /commit-push-pr. For all projects use ~/.claude/commands/

Questions about commit-push-pr

How to install commit-push-pr in Claude Code?

Place the command file at .claude/commands/commit-push-pr.md in your project root.

What does commit-push-pr do?

It verifies the branch, creates a conventional commit from staged changes, pushes to remote, and runs gh pr create.

Which tools are required for commit-push-pr?

It requires git and an authenticated GitHub CLI gh installation in your environment.

Source text

commit-push-pr.md · MIT
---
allowed-tools: Bash(git:*), Bash(gh:*)
description: Commit staged changes, push to remote, and create a pull request
argument-hint: "[optional PR title or description hint]"
---

## Context

- Current branch: !`git branch --show-current`
- Default branch: !`git remote show origin 2>/dev/null | grep 'HEAD branch' | cut -d' ' -f5 || echo "main"`
- Git status: !`git status --short`
- Staged diff: !`git diff --cached`
- Unstaged diff: !`git diff`
- Commits ahead of origin: !`git log '@{u}..HEAD' --oneline 2>/dev/null || echo "No upstream branch"`
- Recent commits for style: !`git log --oneline -5 2>/dev/null || echo "No commits yet"`

## Task

Execute the full git workflow:

1. **Branch check**: If the current branch is the default branch (see the context above), do not commit or push to it. Create a feature branch first (`git checkout -b feature/<short-description>`), or stop and ask if the user really wants to work on the default branch.
2. **Commit**: If there are staged changes, create a conventional commit
3. **Push**: Push the current branch to origin (set upstream if needed)
4. **PR**: Create a pull request using `gh pr create`
   - Auto-generate title from commits
   - Include a summary of changes in the PR body
   - Link any related issues mentioned in commits

If any step fails, stop and report the issue.

$ARGUMENTS

© CloudAI-X · MIT · CloudAI-X/claude-workflow-v2

Similar slash commands

All slash commands for Git and GitHub →

commit-push-pr by other authors comes first.

From the same set46

The whole set →

Project sponsors

Companies that keep this analytics open