Files
claude-foundations/scripts/install-hooks.sh
Paul O'Reilly d3a92326de Add composable multi-language linting and formatting system
PostToolUse hook auto-formats files after Edit/Write/MultiEdit with
git-blob checkpoints for safe revert. Pre-commit hook for staged files.
Canonical formatter scripts for py, sh, ts, sql, json (+ symlinks for
js, yaml, md). Install and setup scripts for project opt-in.

Includes best-practices/linting.md, HOOKS.md docs, README.md, and
session log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 11:50:36 +13:00

47 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Symlink all hooks from claude-foundations/hooks/ into ~/.claude/hooks/
# and print the settings.json configuration to add.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
HOOKS_SRC="$(cd "$SCRIPT_DIR/../hooks" && pwd)"
HOOKS_DST="$HOME/.claude/hooks"
mkdir -p "$HOOKS_DST"
echo "Installing hooks from $HOOKS_SRC$HOOKS_DST"
echo ""
for HOOK in "$HOOKS_SRC"/*.sh; do
NAME="$(basename "$HOOK")"
ln -sf "$HOOK" "$HOOKS_DST/$NAME"
echo "$NAME"
done
echo ""
echo "Hooks symlinked. Ensure your ~/.claude/settings.json includes:"
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..." }]
}
]
}
}
EOF