#!/bin/bash # Installation script for Claude Code Monitor hooks set -e echo "Claude Code Monitor - Hook Installation Script" echo "================================================" echo "" # Get the absolute path to this project PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)" HOOKS_DIR="$PROJECT_DIR/.claude/hooks" # Target hooks directory (user's home Claude config) TARGET_DIR="$HOME/.claude/hooks" # Create target directory if it doesn't exist echo "Creating hooks directory at $TARGET_DIR..." mkdir -p "$TARGET_DIR" # Copy all hook scripts echo "Installing hook scripts..." for hook in pre_tool_use post_tool_use session_start session_end subagent_stop user_prompt; do echo " - Installing ${hook}.sh..." cp "$HOOKS_DIR/${hook}.sh" "$TARGET_DIR/${hook}.sh" chmod +x "$TARGET_DIR/${hook}.sh" done echo "" echo "Hook scripts installed successfully!" echo "" echo "Next steps:" echo "===========" echo "" echo "1. Add the following configuration to your ~/.claude/settings.json:" echo "" cat << EOF { "hooks": { "PreToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "$TARGET_DIR/pre_tool_use.sh" }] }], "PostToolUse": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "$TARGET_DIR/post_tool_use.sh" }] }], "SessionStart": [{ "hooks": [{ "type": "command", "command": "$TARGET_DIR/session_start.sh" }] }], "SessionEnd": [{ "hooks": [{ "type": "command", "command": "$TARGET_DIR/session_end.sh" }] }], "SubagentStop": [{ "hooks": [{ "type": "command", "command": "$TARGET_DIR/subagent_stop.sh" }] }], "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "$TARGET_DIR/user_prompt.sh" }] }] } } EOF echo "" echo "2. Start the Claude Code Monitor backend:" echo " cd $PROJECT_DIR && docker-compose up -d" echo "" echo "3. Open the dashboard in your browser:" echo " http://localhost:3000" echo "" echo "Installation complete!"