---
name: commit-push-and-open-a-pr
description: "Stages only the files that belong, writes an accurate commit message, pushes the branch, and opens a pull request with a body reviewers can use. Use when a developer has local changes ready to share and needs the right files staged, a clear commit message, a push, and a pull request opened. Do not use for resolving merge conflicts or addressing review feedback. Related topics: coding, devops."
---

# Commit, Push and Open a PR

Stages only the files that belong, writes an accurate commit message, pushes the branch, and opens a pull request with a body reviewers can use.

## When to use

Use this skill when a developer has local changes ready to share and needs the right files staged, a clear commit message, a push, and a pull request opened. Do not use it for resolving merge conflicts or addressing review feedback.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Inspect the working tree and list changed and untracked files.
3. Stage only files that belong to the change and flag secrets, build output, and unrelated edits.
4. Read the staged diff for leftover debug code, then write the commit message in the chosen style.
5. Push the branch with upstream tracking without force.
6. Open the pull request with summary, change list, test notes, and risk, and return hashes and link.

## Inputs

- **What I changed and why** (longer free text)
- **Branch to push** (free text, e.g. "Name or new name")
- **Base branch** (free text, e.g. "main")
- **Commit style** (choose one: Conventional commits, Plain sentence, Ticket prefix)
- **Files to leave out** (longer free text)
- **Open as draft** (choose one: Yes, No)

## Output

The commit hashes and messages, the pushed branch name, and the pull request link with its title and body.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Commit, Push and Open a PR

Package my current changes into a commit and pull request.

- What I changed and why: {{What I changed and why}}
- Branch to push: {{Branch to push}}
- Base branch: {{Base branch}}
- Commit style: {{Commit style}}
- Files to leave out: {{Files to leave out}}
- Open as draft: {{Open as draft}}

Inspect the working tree first and list changed and untracked files. Stage only files that belong to this change, and flag anything that looks like a secret, a build artifact, or an unrelated edit instead of committing it. Review the staged diff once for leftover debug lines. Write the commit message in the chosen style: a subject under 72 characters in the imperative, then a body that explains why the change was made. If the change has two unrelated parts, make two commits. Push the branch with upstream tracking, never force pushing unless I ask. Open the pull request with a title, a summary, a short list of changes, how it was tested, and any risk. Return the commit hashes and the PR link.

## Pitfalls

- Using git add on everything, which commits a stray env file or build artifact.
- A message that says what changed but not why.
- Force pushing over a branch someone else has built on.
