Skip to main content
skill CX Codex

anomaly-alert — Claude Code skill: what it does, how to install

Flags anomalous Claude Code sessions by checking spending spikes and tool execution errors via local Agent Monitor.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill anomaly-alert -a claude-code
Open on GitHub

What anomaly-alert does

The skill queries a local Agent Monitor instance running on http://localhost:4820 to inspect the last 500 sessions, analytics, and pricing data. It calculates baselines including mean values, standard deviations, percentiles, and interquartile ranges across historical runs. Without Agent Monitor active on port 4820, data collection fails immediately.

Outlier detection checks for sessions exceeding calculated thresholds, such as spending jumps over two standard deviations or consecutive tool failures. The tool flags cache miss spikes, unexpected context compaction, and abnormal turn counts. Every finding is categorized as Critical, Warning, or Info, providing an explanation alongside actionable troubleshooting steps.

What it helps with

  • detect unexpected cost spikes across historical agent runs
  • flag cache miss surges and uneven token consumption
  • pinpoint runs with consecutive tool execution failures
  • identify sessions with extreme turn counts or zero duration

Example prompts for the agent

  • Check for anomalies across all session metrics: $ARGUMENTS="all"
  • Detect cost spikes using strict threshold filtering: $ARGUMENTS="cost strict"
  • Analyze error rate deviations in recent runs: $ARGUMENTS="errors"

How to install anomaly-alert

1Skills CLI (Vercel)

npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill anomaly-alert -a claude-code

2Manually: put the files in place

~/.claude/skills/anomaly-alert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/anomaly-alert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about anomaly-alert

How to install anomaly-alert in Claude Code?

Run npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill anomaly-alert -a claude-code in your terminal.

What does anomaly-alert do?

It checks session telemetry against statistical baselines to catch unusual spending, tool crashes, token drifts, and run durations.

What prerequisites does anomaly-alert require?

A local Agent Monitor service must be running at http://localhost:4820 with accessible endpoints for sessions, analytics, and cost data.

Source text

SKILL.md · MIT
---
name: anomaly-alert
description: >
  Identify anomalous sessions using Agent Monitor data — cost outliers from
  the pricing engine, token anomalies (cache miss spikes, compaction baseline
  surges), unusual event type ratios (PreToolUse/PostToolUse gaps, APIError
  clusters), behavioral deviations from workflow intelligence (complexity
  score outliers, error propagation anomalies), and sessions with abnormal
  metadata (extreme turn_count, high thinking_blocks, zero turn_duration).
---

# Anomaly Alert

Detect anomalous sessions in Claude Code Agent Monitor data.

## Input

The user provides: **$ARGUMENTS**

This may be:
- "all" or empty (default: check all anomaly types)
- "cost" for cost anomalies only
- "duration" for duration anomalies only
- "errors" for error rate anomalies only
- A sensitivity level: "strict" (1σ), "normal" (2σ), "relaxed" (3σ)

## Procedure

1. **Fetch baseline data** from `http://localhost:4820`:
   - `GET /api/sessions?limit=500` — historical sessions for baseline
   - `GET /api/analytics` — aggregated metrics
   - `GET /api/pricing/cost` — cost data per session

2. **Compute baselines** for each metric:
   - Mean, median, standard deviation
   - P25, P75, P90, P95, P99 percentiles
   - Interquartile range (IQR) for robust outlier detection

3. **Detect anomalies** using statistical thresholds:

   ### Cost Anomalies
   - Sessions costing >2σ above mean
   - Single sessions exceeding daily average
   - Sudden cost spikes (session-over-session increase >200%)

   ### Duration Anomalies
   - Sessions lasting >2σ above mean duration
   - Extremely short sessions (<1 minute) that still incur cost
   - Sessions with unusual active-vs-idle ratios

   ### Error Rate Anomalies
   - Sessions with error rates >2σ above baseline
   - New error types not seen in previous sessions
   - Sessions with >3 consecutive tool failures

   ### Behavioral Anomalies
   - Unusual tool combinations not seen before
   - Sessions with abnormally high compaction counts
   - Model switches mid-session (if unexpected)
   - Sessions with no tool usage (pure conversation)

   ### Token Anomalies
   - Input/output token ratio far from historical norm
   - Cache miss rate significantly higher than average
   - Token usage growing faster than session count

4. **Classify each anomaly**:
   - **🔴 Critical**: Likely indicates a real problem requiring attention
   - **🟡 Warning**: Unusual but may be expected for certain tasks
   - **🔵 Info**: Interesting deviation worth noting

## Output Format

Present as an **Anomaly Report**:

```
═══════════════════════════════════════════════
  ANOMALY DETECTION REPORT
  Analyzed: N sessions | Baseline: last 30 days
  Anomalies found: N (🔴 N critical, 🟡 N warn, 🔵 N info)
═══════════════════════════════════════════════
```

For each anomaly:
- Session ID and timestamp
- Anomaly type and severity
- Observed value vs expected range
- Possible explanation
- Recommended action (if any)

© hoangsonww · MIT · hoangsonww/Claude-Code-Agent-Monitor

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set60

regression-watch Compares an older baseline window of session history with a recent one and reports which metrics got worse: errors, cache, compactions, cost per session. CX Codex +1 ★ 1,121repo stars pattern-detect Analyzes agent sessions via Agent Monitor to find recurring tool sequences, error cascades, and delegation habits. Generates a ranked report with recommendations. CX Codex +1 ★ 1,121repo stars optimization-suggest This skill reviews Claude Code session history and ranks ways to cut costs, improve speed, and prevent errors. Use it to plan changes based on recorded activity. CX Codex +1 ★ 1,121repo stars benchmark The benchmark skill takes one session or a few recent ones and compares them with the rolling average from Agent Monitor data: cost, tokens, tool count and workflow complexity. Each metric comes back as a percentile of the population. CX Codex +1 ★ 1,121repo stars transcript-grep Search a session’s conversation for text or a regex and inspect each hit in context. Handy when you need to track down a prompt, tool call, or error. CX Codex +1 ★ 1,121repo stars session-debug Pulls a single Claude session out of Agent Monitor and reports its event chain, subagent tree, token spend and failures. CX Codex +1 ★ 1,121repo stars hook-diagnostics Troubleshoots Claude Code hook registration, agent monitor reachability, and event ingestion. Useful when events stop appearing in the dashboard. CX Codex +1 ★ 1,121repo stars health-check This skill checks Agent Monitor’s API, database, WebSocket, endpoints, hooks, and data freshness. Use it to spot issues in a monitoring setup. CX Codex +1 ★ 1,121repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor