P
PreToolUse (Bash)
HookFires on
PreToolUsematchingBashImmediately before a tool runs — this is where an action can be denied.
Where this sits in a session
- Session start→
- Prompt submitted→
- Prompt expansion→
- Before tool use→
- After tool use→
- Notification→
- Before compaction→
- Subagent finished→
- Turn finished→
- Session end
Observes only — Emits messages or context. It never returns a permission decision.
What it runs
Executed automatically when the event fires — no prompt, no confirmation.
command
${CLAUDE_PLUGIN_ROOT}/scripts/check-active-incidents.shcommand
${CLAUDE_PLUGIN_ROOT}/scripts/check-active-incidents.shInstall it yourself
Paste into .claude/settings.json to run this hook without installing the whole plugin. Adjust the paths to point at your own copy of the scripts.
settings.json
{
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/check-active-incidents.sh"
},
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/check-active-incidents.sh"
}
],
"matcher": "Bash"
}
]
}
}Source
Read this before installing — it runs on your machine with your permissions.
#!/bin/bash
# PreToolUse hook: warn about active incidents before git commit/push.
# hooks/hooks.json now filters to the relevant Bash commands, so this script
# only needs to perform the incident check.
ROOTLY_TOKEN="${CLAUDE_PLUGIN_OPTION_ROOTLY_API_TOKEN:-${ROOTLY_API_TOKEN:-}}"
if [ -z "$ROOTLY_TOKEN" ]; then
exit 0 # Silent if not configured
fi
# Check for active high-severity incidents
# Uses JSON:API filter syntax per Rootly REST API spec
# Configurable base URL via ROOTLY_API_URL for self-hosted instances
ROOTLY_URL="${ROOTLY_API_URL:-https://api.rootly.com}"
RESPONSE=$(curl -s \
-H "Authorization: Bearer $ROOTLY_TOKEN" \
-H "Content-Type: application/vnd.api+json" \
"$ROOTLY_URL/v1/incidents?filter[status]=started&filter[severity]=critical&page[size]=50" \
--max-time 2 2>/dev/null)
if [ $? -ne 0 ]; then
exit 0 # Silent on network failure
fi
# Count incidents from JSON:API response (data is an array)
if command -v jq &>/dev/null; then
COUNT=$(echo "$RESPONSE" | jq '.data | length' 2>/dev/null)
elif command -v python3 &>/dev/null; then
COUNT=$(echo "$RESPONSE" | python3 -c "
import sys, json
try:
data = json.load(sys.stdin)
print(len(data.get('data', [])))
except:
print('0')
" 2>/dev/null)
else
exit 0
fi
if [ "$COUNT" != "0" ] && [ "$COUNT" != "null" ] && [ -n "$COUNT" ]; then
echo "WARNING: $COUNT active critical incident(s) detected. Run /rootly:status for details before deploying."
fi
Shipped by 1 plugin
Installing any of these installs this hook.
Reviews
Log in to leave a review.
No reviews yet — be the first.
Explore related
Other things in this space — across every part of the ecosystem, not just hooks.