Shell
#!/bin/bash
# Auto Commit: Stages and suggests commits at logical milestones
FILE_PATH="$1"
FILE_EXT="${FILE_PATH##*.}"
# Skip for non-code files
case "$FILE_EXT" in
md|txt|gitignore)
exit 0
;;
esac
# Check if we're in a git repo and not on main
if git rev-parse --git-dir > /dev/null 2>&1; then
CURRENT_BRANCH=$(git branch --show-current)
if [[ "$CURRENT_BRANCH" != "main" ]] && [[ "$CURRENT_BRANCH" != "master" ]]; then
# Count uncommitted changes
CHANGES=$(git status --porcelain | wc -l | tr -d ' ')
# Auto-stage after significant work (5+ file changes)
if [ "$CHANGES" -ge 5 ]; then
echo "📦 Auto-staging changes for commit..."
echo "💡 Claude will commit these changes with a meaningful message"
echo "CLAUDE_ACTION: suggest_commit"
fi
fi
fi
exit 0