#!/usr/bin/env bash # Symlink all hooks from claude-foundations/hooks/ into ~/.claude/hooks/, # and symlink skill-helper scripts from claude-foundations/scripts/ into ~/.claude/scripts/. # Prints the settings.json configuration to add for hooks. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" HOOKS_SRC="$(cd "$SCRIPT_DIR/../hooks" && pwd)" HOOKS_DST="$HOME/.claude/hooks" SCRIPTS_DST="$HOME/.claude/scripts" # --------------------------------------------------------------------------- # Hooks # --------------------------------------------------------------------------- mkdir -p "$HOOKS_DST" echo "Installing hooks: $HOOKS_SRC → $HOOKS_DST" for HOOK in "$HOOKS_SRC"/*.sh; do NAME="$(basename "$HOOK")" ln -sf "$HOOK" "$HOOKS_DST/$NAME" echo " ✓ $NAME" done # --------------------------------------------------------------------------- # Skill-helper scripts (scripts that skills reference via ~/.claude/scripts/) # Not all claude-foundations scripts go here — only the ones used by skills. # --------------------------------------------------------------------------- mkdir -p "$SCRIPTS_DST" echo "" echo "Installing skill-helper scripts: $SCRIPT_DIR → $SCRIPTS_DST" SKILL_HELPERS=( "extract-transcripts.py" "list-transcripts-here.sh" ) for SCRIPT in "${SKILL_HELPERS[@]}"; do SRC="$SCRIPT_DIR/$SCRIPT" if [ -f "$SRC" ]; then ln -sf "$SRC" "$SCRIPTS_DST/$SCRIPT" echo " ✓ $SCRIPT" else echo " ✗ $SCRIPT (not found at $SRC)" fi done echo "" echo "Done. Ensure your ~/.claude/settings.json (and profile settings.json files) include:" echo "" cat <<'EOF' { "hooks": { "PreCompact": [ { "matcher": "auto", "hooks": [{ "type": "command", "command": "~/.claude/hooks/pre-compact-backup.sh", "timeout": 15, "statusMessage": "Backing up transcript before compaction..." }] }, { "matcher": "manual", "hooks": [{ "type": "command", "command": "~/.claude/hooks/pre-compact-backup.sh", "timeout": 15, "statusMessage": "Backing up transcript before compaction..." }] } ], "PostToolUse": [ { "matcher": "Edit|Write|MultiEdit", "hooks": [{ "type": "command", "command": "~/.claude/hooks/post-edit-lint.sh", "timeout": 30, "statusMessage": "Formatting and linting..." }] } ], "PreToolUse": [ { "matcher": "ExitPlanMode", "hooks": [{ "type": "command", "command": "~/.claude/hooks/require-plan-file.sh" }] } ] } } EOF echo "" echo "Note: hooks are referenced as ~/.claude/hooks/ (default profile path) in all profile settings.json files." echo "Note: skill-helper scripts are installed to ~/.claude/scripts/ only — profiles reference this shared path."