name: commit description: Create a conventional commit from current workspace changes. Use when the user asks to run $commit, asks to commit changes, or asks for a commit message from the current diff. metadata: short-description: Minimal commit workflow
Commit
Use this skill for a small, safe commit workflow. If the user only wants a commit message from the current diff, generate the message and stop before committing.
Workflow
- Inspect state:
git status --short- If there are no changes, stop and report.
- Determine scope:
- If the user included
--all, stage all changes withgit add -A. - Otherwise, treat the currently staged changes as the commit candidate.
- If both staged and unstaged changes exist, call out that only staged changes will be
committed unless
--allwas requested.
- If the user included
- Validate staged content:
git diff --cached --stat- If nothing is staged, stop and report.
- Generate message:
- Prefer conventional format:
<type>(<scope>): <summary> scopeis optional.- Follow the 50/72 rule: subject line is a hard 50-character maximum.
- Body lines are a hard 72-character maximum.
- Include a blank line between the subject and body.
- Include a body whenever useful context is available; omit it only for trivial or purely mechanical commits.
- Body should explain why the change was made, what changed, and relevant validation, risk, or scope notes.
- Valid types:
feat,fix,docs,refactor,test,chore,ci,build. - Do not include AI attribution text.
- Apply any user guidance (for example: "focus on API changes").
- Before committing, check that every generated message line satisfies the subject/body length limits.
- Prefer conventional format:
- Determine outcome:
- If the user asked only for a commit message, return the generated message and stop.
- Otherwise continue with the commit workflow.
- Commit:
- Use a quoted heredoc to pass the full message on stdin; do not create a
temporary commit-message file and do not use one-line
-mstrings. - Pattern:
git commit -F - <<'EOF' <type>(<scope>): <summary> <wrapped body> EOF
- Use a quoted heredoc to pass the full message on stdin; do not create a
temporary commit-message file and do not use one-line
- Report result:
- Show commit hash and subject:
git log -1 --oneline
- Show commit hash and subject:
Failure Handling
- If nothing is staged:
Commit aborted: no staged changes. Stage files first or rerun with --all. - If the commit message is missing or invalid: generate a valid message and retry once.
- If
git commitfails: show the git error and stop.
Notes
- This skill does not push changes.
--allis opt-in because staging unrelated work by default is unsafe in a dirty tree.