spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / scripts / validate-all-hooks.sh
49 lines · 1.4 KBRaw
1#!/bin/bash
2# Validate all hooks.json files in the repository
3# This script can be run in CI to ensure all plugins have valid hook configurations
4
5set -euo pipefail
6
7SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8REPO_ROOT="$(dirname "$SCRIPT_DIR")"
9VALIDATOR="$REPO_ROOT/plugins/plugin-dev/skills/hook-development/scripts/validate-hook-schema.sh"
10
11echo "🔍 Validating all hooks.json files in the repository..."
12echo ""
13
14# Find all hooks.json files
15mapfile -t HOOKS_FILES < <(find "$REPO_ROOT/plugins" -name "hooks.json" -type f 2>/dev/null)
16
17if [ ${#HOOKS_FILES[@]} -eq 0 ]; then
18 echo "No hooks.json files found"
19 exit 0
20fi
21
22echo "Found ${#HOOKS_FILES[@]} hooks.json file(s)"
23echo ""
24
25errors=0
26for hooks_file in "${HOOKS_FILES[@]}"; do
27 relative_path="${hooks_file#$REPO_ROOT/}"
28 echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
29 echo "📄 $relative_path"
30 echo ""
31
32 if bash "$VALIDATOR" "$hooks_file"; then
33 echo ""
34 else
35 echo ""
36 ((errors++))
37 fi
38done
39
40echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
41echo ""
42
43if [ $errors -eq 0 ]; then
44 echo "✅ All ${#HOOKS_FILES[@]} hooks.json file(s) are valid!"
45 exit 0
46else
47 echo "❌ $errors hooks.json file(s) have validation errors"
48 exit 1
49fi