Skip to main content
skill CX Codex

anomaly-detection — skill for Claude Code, Codex, Gemini CLI

anomaly-detection detects outliers in time-series metrics from CSV, cloud monitoring, and other sources. Chooses smoothing and algorithms automatically, or accepts your tuning parameters.

Apache-2.0 ★ 151 updated 2026-10-12

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add gemini-cli-extensions/sre
/plugin install sre-extension@sre
Open on GitHub

What anomaly-detection does

The skill ingests data from your source, selects or asks which metrics to analyze, applies preprocessing when needed, and runs anomaly detection. It defaults to Isolation Forest but supports KNN and Z-Score with user-provided tuning. Python scripts handle data preparation, multiple detection methods, and quality validation—if the result flags more than 5% of points as anomalous, the skill auto-switches to stricter settings (moving-average smoothing and Z-Score threshold 3.0+) to reduce false positives.

Output includes PNG plots with anomalies marked and a list of timestamps where anomalies occur. Requires a Python virtual environment sre-extension-anomaly-detection with the necessary machine learning libraries.

What it helps with

  • spot spikes in CPU, memory, or response-time metrics over hours or days
  • correlate anomalies across multiple metrics in the same time window
  • export anomaly reports from application logs in CSV format
  • tune detector sensitivity for noisy or clean datasets
  • visualize time-series data with anomalies highlighted on plots

Example prompts for the agent

  • Find anomalies in my metrics.csv for CPU and memory over the last 24 hours
  • Detect outliers in response_time using z-score algorithm with threshold 2.5
  • Analyze Cloud Monitoring data, apply moving-average smoothing with window 7, then isolation_forest

How to install anomaly-detection

1Plugin marketplace

/plugin marketplace add gemini-cli-extensions/sre
/plugin install sre-extension@sre

This installs the whole sre-extension plugin with all its skills

2Skills CLI (Vercel)

npx skills add gemini-cli-extensions/sre --skill anomaly-detection -a claude-code

3Manually: put the files in place

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

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

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

Questions about anomaly-detection

How do I install anomaly-detection in Claude Code?

Run these commands in order: /plugin marketplace add gemini-cli-extensions/sre, then /plugin install sre-extension@sre, then npx skills add gemini-cli-extensions/sre --skill anomaly-detection -a claude-code. Open the SKILL.md file at ~/.claude/skills/anomaly-detection/SKILL.md.

What does anomaly-detection do?

It analyzes time-series data (metrics, logs) and identifies unusual values using machine learning. It smooths noise, picks the best detection method, validates quality, and returns plots plus a list of anomalous timestamps.

What does the skill require to work?

An active Python virtual environment sre-extension-anomaly-detection with dependencies for Isolation Forest, KNN, or Z-Score. Data sources can be CSV files or Cloud Monitoring.

Source text

SKILL.md · Apache-2.0
---
name: anomaly-detection
description: 🐉 Detects anomalies in time-series data from various sources.
metadata:
  author: Google
  version: 0.1.0
  status: published
---

# Anomaly Detection Skill

You are an expert SRE Detective. Your job is to analyze time-series metrics and pinpoint anomalous behavior with minimal user friction.

**Inputs:**

*   `source_type`: String indicating the data source (e.g., "csv", "cloud_monitoring").
*   `source_details`: A dictionary or list containing the necessary information to access the data source.
    *   For `source_type: "csv"`: A list of file paths.
*   `context`: (Optional) String, either free-form text describing the issue or an issue tracker ID like a GitHub issue or Jira ticket.
*   `metrics`: (Optional) List of strings, specific metric names to analyze from the source.
*   `smoothing`: (Optional) String, method for smoothing (e.g., "moving_average", "exponential"). USER OVERRIDE.
*   `window`: (Optional) Integer, window for moving average. USER OVERRIDE.
*   `alpha`: (Optional) Float, alpha for exponential smoothing. USER OVERRIDE.
*   `algorithm`: (Optional) String, anomaly detection algorithm (e.g., "knn", "zscore", "isolation_forest"). USER OVERRIDE.
*   `n_neighbors`: (Optional) Integer for KNN detector. USER OVERRIDE.
*   `threshold`: (Optional) Float, for Z-Score. USER OVERRIDE.
*   `contamination`: (Optional: Float or "auto") For Isolation Forest. USER OVERRIDE.

**Workflow:**

1.  **Get Data:**
    *   Call `@skills/data_ingestion` with `source_type` and `source_details`.
    *   Save output to `.gemini/tmp/user/merged_data.json`.

2.  **Select Metrics:** (Same as before - infer from query/context, ask if needed)
    *   Let `available_metrics` be `metadata.available_metrics` from `merged_data.json`.
    *   If `metrics` input is provided, validate they are in `available_metrics`. Use these valid metrics.
    *   If `metrics` input is NOT provided, analyze the user's initial query and `context` for metric names. Try to match keywords with `available_metrics`.
    *   If no clear metrics can be inferred, or if there's ambiguity, use `ask_user` to prompt the user to select one or more metrics from `available_metrics`.
    *   Let `selected_metrics` be the list of metrics to analyze.

3.  **Process Each Selected Metric:** Iterate through each `metric_name` in `selected_metrics`:

    a.  **Filter Metric Data:** Create a temporary JSON file (`/tmp/single_metric_data.json`) containing only the "timestamp" and the current `metric_name` column from `merged_data.json`. You can write a short Python script to extract the relevant column based on the metric index in the `"columns"` list, ignoring rows where the metric value is `null`.

    b.  **Automated Preprocessing:**
        *   **Check for User Override:** If `smoothing` parameter is provided, use the specified method and parameters.
        *   **Automated Choice:** If no override, the agent should *autonomously* decide if smoothing is needed. Heuristic: calculate the point-to-point change percentage. If a significant number of points exceed a threshold (e.g., >20% change), apply a default `moving_average` with a small window (e.g., 3 or 5).
        *   Log the decision: "No smoothing applied" or "Applied Moving Average smoothing with window=3".
        *   If smoothing is applied, run `scripts/preprocess_data.py` as before, outputting to `/tmp/preprocessed_data.json`.
        *   Input to next step is `/tmp/preprocessed_data.json` or `/tmp/single_metric_data.json`.
        *   Let this be `data_for_detection.json`.

    c.  **Automated Algorithm Selection:**
        *   **Check for User Override:** If `algorithm` parameter is provided, use the specified algorithm.
        *   **Automated Choice:** Default to `isolation_forest` as it's generally robust. Contamination set to "auto".
        *   Let `chosen_algorithm` be the selected method.

    d.  **Detect Anomalies:** Execute the script for `chosen_algorithm`:
        *   All detection scripts take `data_for_detection.json` as input and output to `/tmp/detected_data.json`.
        *   **Example (Isolation Forest):**
            ```bash
            source $HOME/.venvs/sre-extension-anomaly-detection/bin/activate &&
            python3 .gemini/skills/anomaly_detection/scripts/detect_isolation_forest.py \
            /tmp/data_for_detection.json --contamination auto \
            > /tmp/detected_data.json
            ```
        *   Adjust command and parameters for knn or zscore if overridden.

    e.  **Evaluate Noise & Auto-Tune (Self-Reflection) - MANDATORY:**
        *   **Requirement:** You MUST evaluate the noise level of the detection result for EVERY metric, without exception.
        *   **Calculation:** Use `jq` to count the total points and the anomaly points in `/tmp/detected_data.json`.
        *   **Noise Threshold:** If the anomaly count exceeds **5%** of the total data points, the result is considered "noisy" (false positives).
        *   **Autonomous Fallback:** If noisy, you MUST discard the result, log "Detection too noisy ({count} anomalies), applying autonomous auto-tuning", and loop back to **Step 3.b**.
        *   **Auto-Tune Parameters:** Force **Smoothing** to `moving_average` (window=5) and **Algorithm** to `zscore` (threshold=3.0).
        *   **Quality Check:** After re-running, ensure the new result is within reasonable bounds (e.g., < 2% of points). If still noisy, increase the Z-Score threshold iteratively (e.g., to 4.0 or 5.0) until the signal is clear.

    f.  **Plot Anomalies:** Execute `scripts/plot_anomalies.py` and move the output to the destination directory.
        *   **Example:**
            ```bash
            PLOT_FILE=$(python3 .gemini/skills/anomaly_detection/scripts/plot_anomalies.py /tmp/detected_data.json) &&
            mkdir -p data && mv "$PLOT_FILE" data/${metric_name}_anomalies.png
            ```

    g.  **Extract Results Summary:** Use `jq` to extract the exact timestamps where an anomaly was detected to summarize the findings.
        *   **Example:**
            ```bash
            jq -r '.timeseries[] | select(.[2] == true) | .[0]' /tmp/detected_data.json | head -n 5
            ```

4.  **Correlate & Explain:** Synthesize the detected anomalies, matching up the time windows across multiple metrics. Explain which anomalies correlate and what the underlying cause might be.

5.  **Report Results:** Provide a clear summary to the user including the algorithm used, any preprocessing applied, the time windows of the anomalies, and the path to the generated plots.

© Google · Apache-2.0 · gemini-cli-extensions/sre

Similar skills

All skills for AI and ML →
Anomaly Detection aj-geddes Anomaly Detection is a Claude Code skill that finds outliers, fraud, and system faults with statistical tests, isolation forests, and deep learning. It generates Python analysis pipelines. CX Codex +1 534installs kibana-anomaly-detection elastic kibana-anomaly-detection investigates Elastic ML anomalies, explains detector scores, and troubleshoots failed datafeeds. Useful for root-cause analysis across Elasticsearch jobs. CX Codex +1 3,500installs huawei-cloud-cdn-traffic-anomaly-analysis huaweicloud huawei-cloud-cdn-traffic-anomaly-analysis pulls a CDN domain's billing mode and traffic metrics through the hcloud CLI, then compares the current window with a three-month baseline to flag days that break the pattern. CX Codex +1 159installs elasticsearch-anomaly-detection elastic elasticsearch-anomaly-detection is a Claude Code skill that configures and starts Elasticsearch ML anomaly detection jobs for tracking volume surges or outages in time-series data. CX Codex +1 1,500installs signals-scout-anomaly-detection PostHog signals-scout-anomaly-detection — a skill for Claude Code detects anomalies across saved PostHog insights, including sudden spikes, metric drops, and broken trends. Tracks key dashboards against seasonality-matched baselines. CX Codex +1 318installs sre-engineer https://github.com/Jeffallan sre-engineer defines quantitative SLOs, calculates error budgets, configures Prometheus alerts, and automates operational toil. Useful when running scalable production services. CX Codex +1 5,700installs

From the same set17

The whole set →
postmortem-aggregator postmortem-aggregator turns Post Mortem files in a folder into incident statistics and updates POMO_AGGREGATED.md. Use it to spot recurring causes across incidents. CX Codex +1 ★ 151repo stars gcp-mcp-setup gcp-mcp-setup — a skill for Claude Code, Codex, and Gemini CLI that wires up Google Managed MCP servers (OneMCP) to your CLI environment. It enables APIs, generates an API key, and writes the MCP config to the right settings file. CX Codex +1 ★ 151repo stars generic-mitigations generic-mitigations guides your agent to halt production outages quickly using standard SRE strategies before diving into root-cause analysis. CX Codex +1 ★ 151repo stars monitoring-graphs monitoring-graphs — a skill for Claude Code, Codex and Gemini CLI that generates annotated incident graphs in Python. Use it to visualize outages, plot error spikes, or correlate metrics with incident milestones. CX Codex +1 ★ 151repo stars investigation-entrypoint The investigation-entrypoint skill for Claude Code, Codex, and Gemini CLI coordinates GCP incident investigations across GKE and Cloud Run. CX Codex +1 ★ 151repo stars postmortem-generator postmortem-generator is a Claude Code skill that turns incident context into a postmortem, timeline, action items, and a Google Doc draft. It starts after investigation and root-cause work. CX Codex +1 ★ 151repo stars gcp-architecture-discovery gcp-architecture-discovery — a skill that walks a GCP project outward from the service that broke and writes down what it finds: compute, networks, databases, buckets. The map stays on disk between sessions. CX Codex +1 ★ 151repo stars sre-extension The sre-extension plugin for Claude Code supports Google Cloud outage investigations, log analysis, and post-mortem generation. CX Codex ★ 151repo stars

Project sponsors

Companies that keep this analytics open