git-commit
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
Git Commit
Context
- Current branch: !
git branch --show-current - Staged changes (stat): !
git diff --cached --stat - Staged changes (full): !
git diff --cached - Recent commits on this branch: !
git log --oneline -20
Step 1 — Determine the issue number
Try these in order, and stop as soon as one gives a confident answer:
-
Parse the branch name. Look for a pattern like
PROJ-123,#123, or a bare number set off by/or-(e.g.feature/456-login-fix,bugfix/789,123-refactor-auth). Extract the identifier exactly as it appears (keep the prefix if there is one, e.g.PROJ-123, don't strip it to just123). -
If the branch name is ambiguous or has no identifier, scan the recent commits above for an existing
[<issue>]prefix used earlier on this same branch. If one or more commits share the same identifier, use that — consistency with the branch's own history wins over a fresh guess. -
If step 1 and step 2 disagree, or if neither produces a confident match, ask the user with the
AskUserQuestiontool (not free-text — keep it selectable to save keystrokes). Offer these options:- Any confident-but-conflicting candidates from steps 1 and 2 (e.g.
PROJ-123from the branch,PROJ-456from recent commits) as one option each, so the user picks with a single click. - Skip — commit with no issue-number prefix.
The user can always type their own key via the tool's built-in "Other" free-text option, so don't add a separate "enter a key" choice. Do not guess or invent an issue number — an incorrect one is worse than asking.
- Any confident-but-conflicting candidates from steps 1 and 2 (e.g.