From 39711c1ba4ec53ddaea17610f7041aae7da1445b Mon Sep 17 00:00:00 2001 From: Dan Mordechay Date: Sun, 23 Nov 2025 14:07:36 +0200 Subject: [PATCH] feat: trigger ldd by hook and skill keywords --- go-linter-driven-development/hooks/hooks.json | 14 +++++++ .../hooks/user-prompt-submit.sh | 39 +++++++++++++++++++ .../skills/linter-driven-development/SKILL.md | 12 ++++++ 3 files changed, 65 insertions(+) create mode 100644 go-linter-driven-development/hooks/hooks.json create mode 100755 go-linter-driven-development/hooks/user-prompt-submit.sh diff --git a/go-linter-driven-development/hooks/hooks.json b/go-linter-driven-development/hooks/hooks.json new file mode 100644 index 0000000..07e229c --- /dev/null +++ b/go-linter-driven-development/hooks/hooks.json @@ -0,0 +1,14 @@ +{ + "hooks": { + "UserPromptSubmit": [ + { + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PLUGIN_ROOT}/hooks/user-prompt-submit.sh" + } + ] + } + ] + } +} diff --git a/go-linter-driven-development/hooks/user-prompt-submit.sh b/go-linter-driven-development/hooks/user-prompt-submit.sh new file mode 100755 index 0000000..f2ccec1 --- /dev/null +++ b/go-linter-driven-development/hooks/user-prompt-submit.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# Read hook input from stdin +input=$(cat) +user_message=$(echo "$input" | jq -r '.message') + +# Signal 1: Go file mentioned or Go project context +is_go_work=$(echo "$user_message" | grep -qiE '\.go|go\.mod|go\.sum|golang' && echo "true" || echo "false") + +# If not mentioned, check if working directory has Go files +if [ "$is_go_work" = "false" ]; then + project_dir=$(echo "$input" | jq -r '.cwd') + # Check for go.mod or .go files (safe with set -e) + if [ -f "$project_dir/go.mod" ] || find "$project_dir" -maxdepth 1 -name "*.go" -type f 2>/dev/null | head -1 | grep -q .; then + is_go_work="true" + fi +fi + +# Signal 2: Code work verbs +is_code_work=$(echo "$user_message" | grep -qiE "implement|build|create|add|write|fix|refactor|update|change|modify|continue|finish|complete|ldd|linter|test" && echo "true" || echo "false") + +# Both signals → Use skill +if [ "$is_go_work" = "true" ] && [ "$is_code_work" = "true" ]; then + cat <