Generic alert primitive

threshold-hook

A tiny CLI and package for threshold-based alerts in cron and CI.

Use it when you already have the number and just need sane alerting.

Value

Built for scripts and workflows where you want to

  • compare a value against a threshold
  • avoid repeated alert spam
  • send Slack, Discord, or generic webhook alerts
  • handle crossing, reminders, cooldowns, and recovery cleanly
Why this exists

A lot of automation problems are smaller than a monitoring stack.

Sometimes you already have the metric.

You just need a clean way to decide when to alert.

Example

Pipe in a number. Set a cap and threshold. Only alert when it actually matters.

Raw numeric stdin
echo 87 | threshold-hook --cap=100 --threshold=0.8 --webhook="$WEBHOOK_URL"
Extract from stdin JSON
curl -s https://example.com/metrics.json \
  | threshold-hook \
      --json-path=data.total \
      --cap=100 \
      --threshold=0.8 \
      --label="queue depth"
Use threshold-hook when
  • your script already produces a number
  • you want threshold alerts with dedupe and cooldowns
  • you want something tiny and predictable in cron or CI
Don't use threshold-hook if
  • you need provider-specific spend logic for OpenAI and Anthropic
  • you want dashboards, tracing, or full observability
  • you need distributed or shared alert state

The npm package and public GitHub repo are both live now.

Need the spend-specific tool for OpenAI and Anthropic? Use capped-cost.