Commit, push, open a PR
Invoking this skill is the user's request to commit. $0 sets how far to go:
| Argument | Does |
|---|---|
none or commit | commit, then ask whether to push and open a PR |
push | commit and push |
pr | commit, push, open a PR |
Anything after it is extra instruction from the user: $ARGUMENTS.
1. Read the project's rules first
- Read
CLAUDE.md/AGENTS.md(root and nearest folder),CONTRIBUTING.md, any commitlint config, and.github/pull_request_template.md. - Run
git log --oneline -15to see the format actually in use. - Project rules win over the defaults below: commit format, branch names, base branch, production branches, PR template, labels, files that must never be committed.
2. Check the state before touching anything
git status --short --branch # also shows the upstream, if any
git branch --show-current
git diff --stat; git diff --cached --stat
Stop and ask when any of these is true:
- The branch is a production branch (
main,master,production,release*, or what the project names) and the user didn't say in this message to commit there. Offer a branch:<type>/<ticket>-<slug>. - Detached HEAD, or a merge, rebase or cherry-pick is in progress.
- Something is already staged that you did not stage.
3. Choose and stage the files
- Commit only the work in hand. Leave unrelated edits, and any file the project marks as permanently local, unstaged.
- Never commit
.envfiles, secrets, database dumps, exports, or build output. - Separate deliverables get separate commits: code, tests, docs.
- Stage explicit paths only:
git add -- <path> <path>. Nevergit add -A,git add .orgit commit -a. - Confirm with
git diff --cached --name-only. Scangit diff --cachedfor keys, tokens and connection strings; stop if you find one.
4. Write the message
- Format: the project's own, else Conventional Commits:
type(scope): imperative summary, at most 72 characters before any ticket suffix, no trailing period. - Body: why the change was needed first, then a bullet list of the changes.
- Links: ticket ids as their URLs. Commit references link to
<repo-url>/commit/<full 40-char SHA>; get the SHA withgit rev-parse <short>and the repo URL fromgit remote get-url origin. - No AI attribution of any kind: no co-author trailer, no "generated with" line.
- Pass the message with a heredoc or
-F <file>.
5. Commit
- If a hook fails, fix the cause, re-stage, and make a new commit. Never
--no-verify; never--amendunless asked. - Show
git log -1 --stat.
6. Push (only for push or pr)
- Always an explicit refspec:
git push -u origin HEAD:refs/heads/<branch>. - Why: a branch made with
git worktree add -b X origin/devtracksorigin/dev, so a baregit pushwould push straight todev. - Never force-push. Never push to a production branch unless the user said so in this message.
7. Open the PR (only for pr)
- Base: the project's integration branch from its CLAUDE.md, else
gh repo view --json defaultBranchRef -q .defaultBranchRef.name. - Title: the commit subject style.
- Body, written to a temp file and passed with
--body-file:- every paragraph and bullet on one unwrapped line (GitHub turns each newline into a line break);
- Summary: why;
- Changes: bullets;
- Verification: the commands actually run and their measured results, plus anything not verified;
- Links: tickets, related PRs, docs, full-SHA commit links.
- Follow the project's PR template and labels. Never merge unless asked.
8. Report
Branch, each commit as a full-SHA link, the PR URL, and anything left uncommitted on purpose.