What problem does it solve?
This Skill automates the creation and registration of hook scripts with standardized error handling and proper placement in settings.json, reducing setup mistakes and manual configuration time.
Core Features & Use Cases
- Create Hook Script: Includes mandatory error handling pattern and a safe shebang.
- Set Permissions: Ensure the script is executable.
- Register in settings.json: Add the hook with the correct matcher and trigger.
- Restart Reminder: Warn when changes require a Claude restart.
- Test Instructions: Provide steps to verify the hook executes correctly.
Quick Start
Use the register-hook.sh script to create a hook named "log-bash-commands" with trigger "PreToolUse" and matcher "Bash", and provide the script content as needed. The script would include:
#!/bin/bash
set -euo pipefail
trap 'echo "ERROR in log-bash-commands.sh at line $LINENO: Command failed: $BASH_COMMAND" >&2; exit 1' ERR
JSON_INPUT=$(cat)
COMMAND=$(echo "$JSON_INPUT" | jq -r '.tool_input.command // empty')
echo "[$(date -Iseconds)] $COMMAND" >> /tmp/bash-log.txt