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

View File

@@ -0,0 +1,34 @@
#!/bin/bash
# Auto-format files after Edit/Write using Prettier
# Event: PostToolUse | Matcher: Edit|Write
# Silently skips if Prettier is not installed or file doesn't exist
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
if [ -z "$FILE_PATH" ] || [ ! -f "$FILE_PATH" ]; then
exit 0
fi
EXTENSIONS="ts tsx js jsx json css scss html md yaml yml"
FILE_EXT="${FILE_PATH##*.}"
SHOULD_FORMAT=false
for ext in $EXTENSIONS; do
if [ "$FILE_EXT" = "$ext" ]; then
SHOULD_FORMAT=true
break
fi
done
if [ "$SHOULD_FORMAT" = false ]; then
exit 0
fi
if command -v npx &>/dev/null && [ -f "node_modules/.bin/prettier" ]; then
npx prettier --write "$FILE_PATH" 2>/dev/null
elif command -v prettier &>/dev/null; then
prettier --write "$FILE_PATH" 2>/dev/null
fi
exit 0