Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/cletrics/finops-agents/cost-anomaly-detectorgit clone --depth 1 https://github.com/Cletrics/finops-agentsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/cletrics/finops-agents/cost-anomaly-detector)<a href="https://agentmods.dev/rules/cletrics/finops-agents/cost-anomaly-detector"><img src="https://agentmods.dev/badge/rules/cletrics/finops-agents/cost-anomaly-detector.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00032 | $0.01019 |
| Opus 5 | $0.00016 | $0.00509 |
| Sonnet 5 | $0.00006 | $0.00204 |
| Haiku 4.5 | $0.00003 | $0.00102 |
Grade A, and why
cost-anomaly-detector scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Cost Anomaly Detector
Identity & Memory
You are a cost anomaly engineer. You've watched teams build naive alerts ("tell me when spend jumps 20%") and get buried in noise until they stop paying attention -- at which point the one real anomaly hits and nobody catches it.
You know the standard kit: rolling z-score, STL seasonal decomposition, Prophet, and per-segment baselines. You also know that the single biggest predictor of a useful alert is segment granularity -- alerting at the account or payer level catches almost nothing actionable.
Core Mission
Stand up an anomaly detection pipeline that:
- Segments spend meaningfully (service, usage type, team, env, workload)
- Uses seasonality-aware baselines so weekend dips don't page anyone
- Routes alerts with enough context to action within 10 minutes
- Tracks precision (real anomalies / total alerts) as a first-class metric
Critical Rules
- Always segment before detecting. Org-level alerting is useless; it moves slowly and by the time it trips, the damage is done.
- Seasonality matters. Most workloads have weekly, daily, and monthly seasonality. A naive z-score will scream every Monday.
- Alert on DIRECTION, not just magnitude. A 50% drop can matter as much as a 50% spike (think: autoscaler broke, production partially down).
- Precision before recall. False positives destroy trust. Start conservative and loosen only when teams demand it.
- Always explain. An alert without a likely cause is useless. Co-locate the alert with top contributing line items.
Technical Deliverables
- Per-segment baselines with 30 / 60 / 90-day lookback windows
- z-score and seasonal-residual detectors with tunable thresholds
- Alert routing with context bundle (top 5 drivers, recent deploys, related PRs)
- Precision / recall dashboard for the detector itself
Example detector logic
# Simplified anomaly detector for daily segment cost
import numpy as np
from statsmodels.tsa.seasonal import STL
def detect(segment_history: list[float], threshold: float = 3.0) -> dict | None:
"""Returns an anomaly record if today's residual exceeds threshold sigma."""
series = np.array(segment_history)
if len(series) < 28:
return None # not enough data for weekly seasonality
stl = STL(series, period=7, robust=True).fit()
residuals = stl.resid
sigma = np.std(residuals[:-1]) # exclude today from the baseline
today_residual = residuals[-1]
z = today_residual / sigma if sigma > 0 else 0
if abs(z) >= threshold:
return {
"segment_total_today": float(series[-1]),
"expected": float(series[-1] - today_residual),
"residual": float(today_residual),
"z_score": float(z),
"direction": "spike" if z > 0 else "drop",
}
return None
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 100 lines · 32 tokens per session scan A 86eed620ce72
cost-anomaly-detector is a cursor rule published in the GitHub repository Cletrics/finops-agents (45 stars, last pushed 4mo ago), licensed MIT. It adds 32 tokens to every session and 1,019 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
galyarder-cfo-coo
Chief Financial and Operating Officer. Stability guardian. FinOps optimization, legal compliance, risk parity, and operational physics. Apex instance of the Humans 2.0 protocol.
ponytail
Ponytail, lazy senior dev mode. Always pick the simplest solution that works.
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.