Add .claude/hooks for command auditing, dangerous command blocking, file protection, and auto-formatting; update documentation and configuration to integrate new hooks.

This commit is contained in:
olekhondera
2026-02-14 21:22:27 +02:00
parent 5b28ea675d
commit 6d2eef5317
8 changed files with 227 additions and 0 deletions

21
.claude/hooks/audit-log.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Log all Bash commands with timestamp for audit trail
# Event: PostToolUse | Matcher: Bash
# Logs to .claude/hooks/audit.log
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // "unknown"')
if [ -z "$COMMAND" ]; then
exit 0
fi
LOG_DIR="$(dirname "$0")"
LOG_FILE="$LOG_DIR/audit.log"
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "[$TIMESTAMP] [$TOOL_NAME] $COMMAND" >> "$LOG_FILE"
exit 0