name: commit description: Commit and push all changes with a conventional commit message. Validates staged files for unwanted artifacts before committing. Use when the user runs /commit or asks to commit their changes.
Commit
A zero-parameter workflow that validates, commits, and pushes changes.
Workflow
Step 1: Check for uncommitted surprises
Run git status and review all staged and untracked files. Flag any files that should NOT be committed:
- Binary files (images, compiled artifacts,
.pyc,.so,.dll,.exe) - Temporary files (
.tmp,.log,.bak,~suffixes) - Secrets or credentials (
.env,credentials.json, API keys, tokens) - OS junk (
.DS_Store,Thumbs.db) - Large generated files (
node_modules/,__pycache__/,*.lockthat aren't expected) - Editor artifacts (
.swp,.swo)
If any suspicious files are found, list them and ask the user to confirm before proceeding. Suggest adding them to .gitignore if appropriate.
If nothing suspicious, proceed without asking.
Step 2: Stage all changes
Run git add -A to stage everything (after user confirmation in Step 1 if needed).
Step 3: Generate a conventional commit message
Run git diff --cached and git diff --cached --stat to analyze staged changes.
Write a commit message following Conventional Commits:
<type>(<scope>): <short summary>
<body with details>
Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
Rules:
- Summary is imperative mood, lowercase, no period, max 72 chars
- Body wraps at 72 chars, explains why not what
- Pick the single most accurate type
- Scope is optional -- use only when it adds clarity
- Omit the body for trivial changes
Step 4: Commit
Commit with the generated message. Use a HEREDOC to pass the message:
git commit -m "$(cat <<'EOF'
<message here>
EOF
)"
Step 5: Push
Run git push. If no upstream is set, use git push -u origin HEAD.
Step 6: Confirm
Show the user the commit hash, message, and remote status.