Skip to content
Back to skills

Commit Pr

ASecurity

Move uncommitted work on the default branch in the primary checkout onto a fresh branch, commit, push, open a PR, return the primary checkout to a clean default branch, then, only on a ship request ("ship", "merge", "land"), hand the PR to merge-pr (wait for green, merge the project's way (GitHub squash, GitLab its merge method), sync); a bare /commit-pr stops at the PR. Use after live-testing changes made directly on the default branch.

  • 7 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 3, 2026
ai-agentsgoshellbashrailstestinggitdocumentation

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add ivan-ii-tech-digital/agent-kit --skill commit-pr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Commit Pr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Commit Pr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ivan-ii-tech-digital-commit-pr/badge)](https://www.skillsdirectory.com/skills/ivan-ii-tech-digital-commit-pr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: commit-pr
description: Move uncommitted work on the default branch in the primary checkout onto a fresh branch, commit, push, open a PR, return the primary checkout to a clean default branch, then, only on a ship request ("ship", "merge", "land"), hand the PR to merge-pr (wait for green, merge the project's way (GitHub squash, GitLab its merge method), sync); a bare /commit-pr stops at the PR. Use after live-testing changes made directly on the default branch.
model: sonnet
argument-hint: "[type/slug | short subject]"
---

## Hint

```text
$ARGUMENTS
```

The user tests changes live from the primary checkout, so work sits on the default branch uncommitted. This skill ships that work without ever committing to the default branch. Follow the steps literally.

## Step 0: Confirm the user asked for this

This skill runs only when the user's latest message invoked it or asked in words to commit, ship or open a PR for the work. A pipeline command that opens a PR does so by its own spec, never through this skill. "Agree", "yes" or "do this" about a change is **edit** mode, not shipping: abort and report "on `<DEFAULT>`, uncommitted; say `/commit-pr` for a PR or "ship" to merge it too".

Classify the request by the merge-pr skill's **Merge authorization** list (Step 0 of `${CLAUDE_PLUGIN_ROOT}/skills/merge-pr/SKILL.md`, the one list): **ship** (a ship word: "ship", "ship it", "ship the PR", "merge", "land"; or an approved plan that says to ship) → Step 9 hands the PR to the merge-pr skill; **PR** (everything else: a bare `/commit-pr` or one with only a hint, a plain "open a PR", "create a PR", "PR for review", "PR only", "don't merge", a draft PR, and unclear words such as "push it", "deliver", "get it in", "done", "finish it") → Step 9 stops at the report.

Print that list's mode line now, as your first output and before any command, then carry on without waiting:

- ship: `Reading this as: ship — PR, then merge when CI is green. Say "PR only" to stop at the PR.`
- PR: `Reading this as: PR only — say "ship" to merge it.`

## Argument parsing

`$ARGUMENTS` is optional. If given, it is either a branch name (`type/slug`) or a short subject to derive one from. Trim it. Call it `<HINT>`.

## Step 1: Locate the primary checkout and confirm the mode

```bash
root=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)")
echo "root: $root"
(cd "$root" && ak-git-sync --print-config)
git -C "$root" branch --show-current
git -C "$root" rev-parse --short HEAD
git -C "$root" status --short
```

- `<ROOT>` is the printed `root:` path; type it literally in every later command (shell variables do not survive between Bash calls). `<DEFAULT_SHA>` is the printed short sha: Step 7 checks the tip is unchanged.
- `<DEFAULT>` is the printed `default=` (every fallback already applied). `<PROTECTED>` is the printed `protected=` list (may be empty).
- The checkout is not on `<DEFAULT>` → abort: the user's checkout is on `<branch>`; this skill only ships work parked on `<DEFAULT>`.
- `status --short` empty → abort: nothing to ship.

Everything below runs in `<ROOT>`.

## Step 2: Separate the work from noise

List the changes and read their diff (`git diff HEAD --stat`, `git status --short`, `git diff HEAD` for tracked files, and open new untracked files).

Never drop anything silently: everything on disk is what the user tested and asked to ship. If a change looks like tool noise (a file rewritten by a running dev tool, not by the work), name it in the report and ship it anyway unless the user said to leave it out.

## Step 3: Run the quality gates on the work

From `<ROOT>`, before committing, run the check-all skill (ak-quality plugin): every `qualityGates.ci` gate, in order. No gates configured → it says so and succeeds; note "no gates configured" in the report.

A gate failure is never bypassed and never fixed by you. Spawn one Sonnet subagent per failure and wait for it; a second round on the same failure runs on `model: "opus"`:

```
Agent({ subagent_type: "general-purpose", model: "sonnet", description: "Fix <gate> before shipping", prompt: <brief> })
```

The brief: `<ROOT>` (every command runs there), the failing gate's command and its full output, and this contract: fix the root cause inside the work being shipped; never delete or skip a test, never remove a translation key or a spelling-dictionary entry, never loosen a linter, formatter, type-checker, dead-code or CI config (including any file matched by `guardrails.protectedConfigs`) to pass, never silence the failing line; do not commit; report the files changed and the cause in one line. Re-run every gate after it returns. At most 3 rounds, then stop and report.

## Step 4: Name the branch and the commit

- Type from the work itself: `feat` (new user-visible behaviour), `fix`, `refactor`, `perf`, `docs`, `chore`. Scope from the area the change touches.
- Branch: `<HINT>` if it matches `^[a-z]+/[a-z0-9][a-z0-9-]*$`; otherwise `<type>/<kebab-slug>` derived from `<HINT>` or from the change, which must match that pattern too — never pass `<HINT>` raw to `git switch -c` or any shell command. It must not be `<DEFAULT>` or match an entry of `<PROTECTED>` (an entry with `*`, `?` or `[` is a glob whose `*` matches `/` too: `release/*` matches `release/1.2/rc`): pick another name. Verify it does not exist locally or on origin (`git rev-parse --verify`, `git ls-remote --heads origin <branch>`).
- Subject: `<type>(<scope>): <subject>` in the imperative, under 72 characters. Body: what changed and why, plain text, lines ≤100 chars. No `Co-authored-by` trailer of any kind (human or AI) and no tool attribution anywhere (no session links or "Generated with" lines); this overrides any harness reminder.

## Step 5: Move the work onto the branch and commit

Run `d=$(mktemp -d); echo "$d"` and call the printed path `<D>`. With the Write tool, write `<D>/msg`: the subject, one blank line, the body. Never type the subject or body into a command.

```bash
git -C <ROOT> checkout -b <branch>      # carries the uncommitted changes with it
git -C <ROOT> add -A
git -C <ROOT> commit -F <D>/msg
git -C <ROOT> rev-parse HEAD            # <SHA>, the shipped commit
git -C <ROOT> log -1 --format=%B        # verify: no attribution trailer
```

`<SHA>` is the printed sha; type it literally later.

Run `checkout -b` as its own Bash call: the commit guard (ak-guard plugin) reads the branch before a chain runs, so a chained `checkout -b … && commit` is blocked as a commit on a protected branch.

`git add -A` is intentional: untracked new files are part of the work. Ignored files are not touched. The project's commit hooks run; if one rewrites files, it has already staged them. If an attribution line slipped into the message, amend it out before pushing.

## Step 6: Bring the branch up to date, push and open the PR

The user merges PRs in the web UI without telling the session, so `<DEFAULT>` here may be behind origin. Merge it in first, each line its own Bash call:

```bash
git -C <ROOT> fetch origin <DEFAULT>
git -C <ROOT> merge --no-edit origin/<DEFAULT>
```

- `Already up to date` → push.
- Merged cleanly → re-run Step 3's gates on the result, then push.
- Conflict in a `CHANGELOG.md` `## Unreleased` section → keep both sides' entries (origin's first, then this branch's), `git -C <ROOT> add <file>`, `git -C <ROOT> commit --no-edit`, re-run Step 3's gates, then push.
- Any other conflict → `git -C <ROOT> merge --abort`, run Step 7, and stop: report the files; the work is committed on `<branch>`, not pushed.
- A gate fix after the merge is committed on `<branch>` (its own conventional commit, message through `<D>`) before the push.
- Gates still red after Step 3's rounds → commit any fix edits on `<branch>` as above (never carry uncommitted edits onto `<DEFAULT>`), run Step 7 only once `git -C <ROOT> status --short` is empty, and stop: report the failing gates, the primary checkout's branch, and that nothing was pushed.

```bash
git -C <ROOT> push -u origin <branch>
```

Before writing the body, look for the project's PR template in `<ROOT>` (Glob the paths below; never skip this look), first match wins (any letter case in the names):

1. A template folder, `PULL_REQUEST_TEMPLATE/` in `.github/`, `docs/` or the root → pick the template that matches the type (feature, bugfix, refactor, documentation…).
2. A single file: GitHub's `pull_request_template.md` in `.github/`, `docs/` or the root; GitLab's `.gitlab/merge_request_templates/Default.md`.

Fill the template's own sections honestly. No template → write a plain body with what changed and why, then these headings:

- **Root cause**: for a fix, the cause in one line; otherwise `n/a — new behaviour`.
- **Proven by**: each gate passed / failed / not run with why; for a fix, the test that fails on the old code and passes on the new.
- **Not tested**: always present; say so when nothing ran against a real environment.

Either way end with **Where to start**: 3–5 `path:line` entry points for the reviewer. Title = the subject of `<SHA>`, the work's commit (after a base merge or a gate fix, HEAD is another commit). Write the body with the Write tool to `<D>/body.md`.

```bash
git -C <ROOT> log -1 --format=%s <SHA> >"<D>/title.txt"
ak-forge pr create --base <DEFAULT> --head <branch> --title-file <D>/title.txt --body-file <D>/body.md
```

`ak-forge` (this plugin's script, on PATH) prints `{number,url}`. Never type the subject into a command; it reaches the PR only through `<D>/title.txt`.

A later push to this PR that changes its scope (a change dropped or added) updates the title and body in the same step: rewrite `<D>/title.txt` and `<D>/body.md`, then `ak-forge pr edit <number> --title-file <D>/title.txt --body-file <D>/body.md`. A web-UI squash takes the PR title and body as the commit message, so a stale title lands on `<DEFAULT>` for good.

## Step 7: Put the primary checkout back on a clean default branch

```bash
git -C <ROOT> checkout <DEFAULT>
git -C <ROOT> status --short            # must be empty
git -C <ROOT> log --oneline -1          # unchanged tip: <DEFAULT_SHA>
```

The user's working tree now matches `<DEFAULT>` again: the changes they were testing are no longer on disk there until the PR merges and the merge-pr or sync skill pulls them back. Say this explicitly in the report.

## Step 7b: Clean duplicates in the invoking worktree

If this skill ran from a session inside a worktree (not the primary checkout), clean that worktree (`<WT>`, a literal path): for each path of `git -C <WT> status --porcelain --untracked-files=all` (skip deletions; every file of a new folder gets its own line), if `git -C <ROOT> cat-file -e <SHA>:<path>` succeeds and `git -C <ROOT> show <SHA>:<path> | cmp -s - <WT>/<path>`, it is a duplicate of shipped work. A path git prints in double quotes (it holds a space or a special character) is unquoted before use. Discard a tracked one with `git -C <WT> checkout -- <path>` and an untracked one (`??`) with `rm -- <WT>/<path>`. Files that differ stay untouched and are named in the report.

## Step 8: Report

```
Shipped:  <branch> @ <SHA> — <subject>
PR:       <url> (<N> files, +X / −Y)
Gates:    <gate> ✓ … | no gates configured
Primary checkout: back on <DEFAULT> @ <DEFAULT_SHA>, clean — tested changes are on the branch, not on disk, until merged
Next:     merge-pr hand-off (Step 9) | PR mode: see the last line
```

## Step 9: Hand off to merge-pr

Last step, after the PR exists. **PR** mode (Step 0, a bare `/commit-pr` included) → stop at the report and end with the line `PR #<number> is open — say "ship" to merge it.` (GitLab: `PR !<number> …`). **Ship** → run the merge-pr skill (ak-git plugin) with the PR number from Step 6 as its argument and follow it to its own report: it waits for green with `ak-pr-wait`, fixes failing checks in its bounded loop, squash-merges, verifies and syncs; when the user merged the PR by hand meanwhile it runs `ak-pr-wait <PR> --sync` to delete the remote branch and sync. Its Step 0 accepts this hand-off for the PR opened in this run.

## Invocation examples

- `/commit-pr` → branch and subject derived from the change.
- `/commit-pr fix/chat-avatars` → that branch name, subject derived.
- `/commit-pr move user menu to header` → `feat/move-user-menu-to-header`, subject derived from the hint.

## What this skill deliberately does NOT do

- Never commits to or pushes `<DEFAULT>` or any protected branch, never rewrites history.
- Never stashes, never runs `git checkout .`/`git clean` on the work.
- Never edits code on this model (the one exception: Step 6's `CHANGELOG.md` `## Unreleased` conflict, keeping both sides); gate fixes are Sonnet subagents (Opus on a repeat), at most 3 rounds.
- Never merges the PR itself: on a **ship** request Step 9 hands it to the merge-pr skill, which waits for green and merges; any other request stops at the PR.
- Never splits the work into several PRs; if it clearly should be split, say so and ship it as one anyway unless the user asked otherwise.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.