Automatically stage modified files with git add after editing
Edit|MultiEdit|WriteAdd to your .claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/auto-git-add.sh"
}
],
"matcher": "Edit|MultiEdit|Write"
}
]
}
}This hook includes a script file. Download the ZIP bundle for complete installation with script and instructions.
Automatically stage modified files with git add after editing
None required
None
jq -r '.tool_input.file_path // empty' | while read -r file_path; do
if [[ -n "$file_path" ]] && git rev-parse --git-dir >/dev/null 2>&1; then
git add "$file_path" 2>/dev/null || true
fi
done
PostToolUse hooks run after a tool completes execution. They can modify the result or trigger additional actions.