Files
dotfiles/.claude/hooks/pre-edit-block.sh
Ismo Vuorinen cff83e4738 refactor(claude): migrate hooks to external scripts and add new hooks
Replace inline command strings in settings.json with external scripts
in .claude/hooks/ for readability and maintainability. Consolidate
three PostToolUse formatters into one script and add markdown/yaml
formatting. Add new hooks: SessionStart context banner, Stop lint
gate, async Bats test runner, idle desktop notification, and
PostToolUseFailure logger.
2026-03-20 04:38:18 +02:00

24 lines
636 B
Bash
Executable File

#!/usr/bin/env bash
# Pre-edit guard: block vendor/lock files and secrets.d real fish files.
# Receives tool input JSON on stdin.
fp=$(jq -r '.tool_input.file_path // empty')
[ -z "$fp" ] && exit 0
case "$fp" in
*/fzf-tmux | */yarn.lock | */.yarn/*)
echo "BLOCKED: $fp is a vendor/lock file — do not edit directly" >&2
exit 2
;;
*/secrets.d/*.fish)
case "$(basename "$fp")" in
*.example.fish | *.fish.example) exit 0 ;;
esac
echo "BLOCKED: do not edit $fp directly — it is gitignored." >&2
echo "Copy the matching .fish.example file and edit that locally." >&2
exit 2
;;
esac
exit 0