Create commit with AI-generated message for staged changes only
Create an AI-generated commit message for staged changes only. Use this when you've staged specific files and want an atomic commit without unstaged changes.
/plugin marketplace add olioapps/claude-code-plugins/plugin install git-actions@olio-pluginsadditional contextArguments: /git-actions:commit-staged [CUSTOM_INSTRUCTIONS]
Examples:
/git-actions:commit-staged - Standard commit/git-actions:commit-staged use conventional commits - Override style/git-actions:commit-staged max 50 chars no body - Length constraintCurrent: !git status --short
Check repo state:
git rev-parse --git-dir 2>/dev/null || echo "NOT_A_REPO"
git status --short
git diff --cached --quiet && echo "NO_STAGED" || echo "HAS_STAGED"
Abort if:
git diff --cached --name-status
git diff --cached --stat
git diff --cached --unified=3 | head -n 300
git log --oneline -10
git branch --show-current
File summary:
10 files: group by directory/type
Use commit-writer agent.
Context:
- mode: staged
- files: [summary]
- stats: [+X -Y lines]
- diff: [truncated preview]
[IF USER PROVIDED CUSTOM INSTRUCTIONS:]
USER INSTRUCTIONS (HIGHEST PRIORITY):
"""
[custom instructions verbatim]
"""
Agent returns structured output:
---SUBJECT---
[subject]
---BODY---
[body or empty]
---FOOTER---
[footer or empty]
---END---
Parse response into SUBJECT, BODY, FOOTER. Validate:
If validation fails → Report parse error, retry (max 2 attempts)
## Proposed Commit
**Subject:** [subject]
[**Body:** [body] if exists]
[**Footer:** [footer] if exists]
**Files:** [summary] ([stats])
[⚠️ **Non-atomic warning** if flagged by agent]
Use AskUserQuestion: "How to proceed with this commit?"
Options:
On approval:
# Construct message using HEREDOC
git commit -m "$(cat <<'EOF'
[SUBJECT]
[BODY if exists]
[FOOTER if exists]
EOF
)"
Check commit result and handle hooks:
If commit succeeds:
git status --short
git log -1 --format="%H %s"
If pre-commit hook fails:
If commit fails (other reasons):
On cancel: ❌ "Cancelled. Staged changes remain staged."
YOU (handler): check repo, verify staged files exist, gather context, invoke agent, present message, get approval, execute commit, handle errors
Agent: analyze changes, generate message matching repo style, return structured output
Agent does NOT orchestrate or execute. You do NOT format messages.
/git-actions:commit-staged # Commit staged files only
/git-actions:commit-staged use conventional commits format
# Agent will use feat:/fix: format even if repo doesn't normally
/git-actions:commit-staged keep subject under 40 chars, no body
# Forces short subject, omits body
/git-actions:commit-staged emphasize refactoring changes
# Agent highlights refactoring aspects
# Partial staging workflow (atomic commits)
git add src/auth/*.ts # Stage specific files
/git-actions:commit-staged # Commit just those
# Result: atomic commit for auth changes only
git add src/tests/*.test.ts # Stage tests
/git-actions:commit-staged # Separate test commit
# Result: separate commit for tests
# Iterative development
git add feature1.ts
/git-actions:commit-staged # First feature
git add feature2.ts feature3.ts
/git-actions:commit-staged # Second feature
# Result: two atomic commits
# Review before commit
git add -p # Interactive staging
/git-actions:commit-staged # Commit selected chunks
# No staged files
/git-actions:commit-staged
# Error: "No staged changes. Use '/git-actions:commit-all' or stage files manually."
# Staged and unstaged mix
git add file1.ts # file1.ts staged
# file2.ts unstaged
/git-actions:commit-staged # Commits only file1.ts