CodeepCodeep
← back to marketplace

commit-and-pr

v1.0.0

Stage the right changes, write a conventional commit derived from the actual diff, push to a fresh branch (never straight to main/master), and open a PR with gh including a summary and test plan; falls back to printing the push command and PR URL when gh is missing or the remote is not GitHub.

by VladoIvankovic · 0 installs · updated 6/16/2026

Install

/skills install VladoIvankovic/commit-and-pr

Runs in any Codeep session (TUI, Zed, or VS Code extension). Writes to .codeep/skills/commit-and-pr/SKILL.md in your project.

SKILL.md

---
name: commit-and-pr
description: Stage the right changes, write a conventional commit derived from the actual diff, push to a fresh branch (never straight to main/master), and open a PR with gh including a summary and test plan; falls back to printing the push command and PR URL when gh is missing or the remote is not GitHub.
allowed-tools: [execute_command, read_file, write_file]
triggers: ["commit and open a pr", "create a pull request", "commit my changes and push", "open pr with gh", "stage commit push pr"]
version: 1.0.0
author: Codeep
---

Take the current working-tree changes and turn them into a clean commit on a new branch, then a PR. Drive everything through `execute_command` (git/gh only).

## Steps
1. Inspect state. Run `git status --short --branch` and `git diff --stat`. If there is nothing to commit, stop and report it.
2. Read the real changes. Run `git diff` (unstaged) and `git diff --staged`. Base the commit message on what the diff ACTUALLY does — never invent or pad.
3. Stage deliberately. Stage only files belonging to this change: `git add <path> …`. Avoid `git add -A` unless every change is in scope. Do NOT stage secrets, `.env`, build artifacts, or unrelated edits. Verify with `git diff --staged --stat`.
4. Branch first — never commit on main/master. Run `git rev-parse --abbrev-ref HEAD`. If it is `main`/`master` (or the default branch), create one: `git switch -c <type>/<short-slug>` (e.g. `feat/login-retry`, `fix/null-deref`). Derive the slug from the diff.
5. Commit with Conventional Commits. Subject `type(scope): summary`, imperative, ≤72 chars. Types: feat, fix, docs, refactor, perf, test, build, ci, chore. Add a body explaining WHY when non-trivial. Use repeated `-m` flags: `git commit -m "fix(api): handle empty token" -m "Return 401 instead of 500 when Authorization header is blank."`.
6. Push and set upstream: `git push -u origin <branch>`. If push is rejected, run `git pull --rebase` then push again.
7. Open the PR. Check gh first: `gh auth status`. If authenticated AND the remote is GitHub (`git remote get-url origin` contains `github.com`), write the body to a temp file with `write_file`, then:
   `gh pr create --base <default-branch> --head <branch> --title "<subject>" --body-file <tmp>`
   The body MUST contain a `## Summary` (bullets of what changed and why) and a `## Test plan` (exact commands run + result, e.g. `npm test`, manual steps). Print the returned PR URL.

## On failure / fallback
- No gh, gh not authenticated, or non-GitHub remote: do NOT fail. Print the exact next steps for the user — the push command `git push -u origin <branch>`, and the compare URL. For GitHub-style remotes that's `https://github.com/<owner>/<repo>/compare/<default-branch>...<branch>?expand=1`; for GitLab use `/-/merge_requests/new?merge_request[source_branch]=<branch>`. Include the proposed title and body so they can paste it.
- Pre-commit hook fails: read its output, fix the reported issue if trivial (lint/format), re-stage, retry once. Otherwise report the failure verbatim.
- Detached HEAD or dirty unrelated files: stop and surface the situation rather than guessing.

## Notes
- Never use interactive git/gh flags (`-i`, `--interactive`, editor prompts) — always pass content via `-m`/`--body-file`.
- Quote multi-word `-m` values; keep the subject line a single line.
- Resolve `<default-branch>` from `git symbolic-ref refs/remotes/origin/HEAD` (fallback `main`).
- Done when: changes are committed on a non-default branch, the branch is pushed with upstream set, and either a PR URL is printed or the exact manual push+PR instructions are shown.