Files
claude-workflow/hooks/pre-bash-checks.sh
T
martinandClaude Sonnet 4.6 fa89f8963f hooks: Globale Bash-Sicherheitsprüfungen hinzufügen
pre-bash-checks.sh als PreToolUse-Hook auf Bash:
- Blockiert direkten git commit auf main (Pflicht: Feature-Branch)
- Blockiert apt mit -y Flag (verboten, User soll selbst bestätigen)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-04 10:36:40 +02:00

18 lines
779 B
Bash
Executable File

#!/bin/bash
# Globale Sicherheitsprüfungen vor jedem Bash-Tool-Aufruf.
cmd=$(jq -r '.tool_input.command // ""')
# Git-Branch-Schutz: kein direkter Commit auf main
if echo "$cmd" | grep -q 'git commit'; then
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
if [ "$branch" = "main" ]; then
printf '{"continue":false,"stopReason":"BLOCKIERT: Direkter Commit auf main verboten (globale Regel). Bitte zuerst Feature-Branch erstellen: git checkout -b session/YYYY-MM-DD-titel"}\n'
exit 0
fi
fi
# apt -y verboten
if echo "$cmd" | grep -qE '\bapt\b' && echo "$cmd" | grep -q -- ' -y'; then
printf '{"continue":false,"stopReason":"BLOCKIERT: apt -y ist verboten. Bitte ohne -y ausfuehren, damit du die Zusammenfassung selbst bestaetigen kannst."}\n'
fi