From 5d8baea82562b7a81b48aff9e4a866ec670a0066 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Fri, 20 Mar 2026 21:55:37 +0200 Subject: [PATCH] feat(claude): add dotbot-validate and config-warn hooks --- .claude/hooks/post-edit-config-warn.sh | 15 ++++++++++++ .claude/hooks/post-edit-dotbot-validate.sh | 28 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 .claude/hooks/post-edit-config-warn.sh create mode 100755 .claude/hooks/post-edit-dotbot-validate.sh diff --git a/.claude/hooks/post-edit-config-warn.sh b/.claude/hooks/post-edit-config-warn.sh new file mode 100755 index 0000000..423a4b1 --- /dev/null +++ b/.claude/hooks/post-edit-config-warn.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Post-edit: warn when formatter/linter configs are changed, +# since they affect the entire repo's code style. + +fp=$(jq -r '.tool_input.file_path // empty') +[ -z "$fp" ] || [ ! -f "$fp" ] && exit 0 + +case "$(basename "$fp")" in + .editorconfig | biome.json | .prettierrc.json | .shellcheckrc | stylua.toml | .yamllint.yml) + echo "NOTE: Formatter/linter config changed ($fp)." >&2 + echo "Run 'pre-commit run --all-files' to verify consistency." >&2 + ;; +esac + +exit 0 diff --git a/.claude/hooks/post-edit-dotbot-validate.sh b/.claude/hooks/post-edit-dotbot-validate.sh new file mode 100755 index 0000000..60210dd --- /dev/null +++ b/.claude/hooks/post-edit-dotbot-validate.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Post-edit: validate Dotbot install.conf.yaml files after editing. +# Checks YAML syntax and verifies link targets exist. + +fp=$(jq -r '.tool_input.file_path // empty') +[ -z "$fp" ] || [ ! -f "$fp" ] && exit 0 + +case "$fp" in + *install.conf.yaml) ;; + *) exit 0 ;; +esac + +# YAML syntax check +if command -v yamllint > /dev/null; then + if ! output=$(yamllint -d relaxed "$fp" 2>&1); then + echo "Dotbot config YAML error in $fp:" >&2 + echo "$output" >&2 + exit 2 + fi +elif command -v python3 > /dev/null; then + if ! output=$(python3 -c "import yaml; yaml.safe_load(open('$fp'))" 2>&1); then + echo "Dotbot config YAML parse error in $fp:" >&2 + echo "$output" >&2 + exit 2 + fi +fi + +exit 0