anomaly-detection
Rule-based anomaly detection for production systems with configurable thresholds, cooldown periods to prevent alert storms, and error pattern tracking for repeated failures.
npx skills add majiayu000/claude-skill-registry --skill anomaly-detection-dadbodgeoff-drift --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Implements rule-based anomaly detection with cooldowns and error pattern tracking for production systems. It supports detecting slow jobs, high failure rates, unhealthy workers, queue backlogs, repeated errors, and memory spikes, with per-rule cooldowns to prevent alert storms and decay-like behavior upon recovery.
How it works
- TypeScript implementation defines:
- Enums for AnomalyType and AnomalySeverity.
- Interfaces for AnomalyAlert, RuleContext, and AnomalyRule.
- A defined list ANOMALY_RULES containing rules with anomalyType, severity, description, a checkFn, a messageTemplate, and cooldownSeconds.
- An AnomalyDetector class with internal state (alerts, cooldowns, errorCounts, timeoutCounts, alertIdCounter).
- checkWorkerHealth(workerName, health) builds a RuleContext and iterates ANOMALY_RULES, skipping on cooldowns, applying rule.checkFn(ctx), creating alerts via createAlert, and setting cooldowns accordingly.
- checkJobExecution(workerName, jobId, durationMs, expectedDurationMs, success, error) tracks errors, checks for slow jobs, and repeated errors, creating alerts and setting cooldowns when rules fire.
- resolveAnomaly(alertId, resolution) marks an alert resolved with resolution text.
- getActiveAnomalies() returns unresolved alerts ordered by severity.
- Helper methods: trackError, createAlert, isOnCooldown, setCooldown.
- Python implementation mirrors the TS logic:
- Defines AnomalyType and AnomalySeverity enums, AnomalyAlert and RuleContext dataclasses, AnomalyRule dataclass.
- Uses a list ANOMALY_RULES with similar rules and cooldowns.
- AnomalyDetector class provides check_worker_health, check_job_execution, resolve_anomaly, get_active_anomalies, and internal tracking similar to TS, including _track_error, _create_alert, _is_on_cooldown, and _set_cooldown.
- Timezone-aware timestamps and consistent field naming (snake_case) in dataclasses.
When to use it
- When you need to detect slow job degradation before failures.
- When you want to track error rate creep over time.
- When you want to identify repeated error patterns.
- When you want to prevent alert fatigue with cooldowns.
What it can touch
- The skill uses only internal state and the provided analysis logic; it creates and returns AnomalyAlert objects, tracks cooldowns, and maintains error counts. It does not specify external file I/O or network access within the shown code.
Caveats
- The rules and cooldowns are defined in code (e.g., 300s for SLOW_JOB, 600s for HIGH_FAILURE_RATE).
- The repetition threshold for repeated errors is 5 occurrences, with a 900s cooldown.
- The memory spike rule uses a 1024 MB threshold.
- The Python and TypeScript versions align but may differ in exact type annotations and date handling details (timezone handling via datetime.timezone.utc in Python; Date.now in JS).
# Anomaly Detection Rule-based anomaly detection with cooldowns and error pattern tracking. ## When to Use This Skill - Detecting slow job degradation before failures - Tracking error rate creep over time - Identifying repeated error patterns - Preventing alert fatigue with cooldowns ## Core Concepts Production systems fail in subtle ways - jobs getting slower, error rates creeping up, same errors repeating. The solution: 1. **Configurable rules** with severity levels 2. **Cooldown periods** to prevent alert storms 3. **Error pattern tracking** for repeated failures 4. **Violation decay** to reward recovery ## Implementation ### TypeScript ```typescript enum AnomalyType { SLOW_JOB = 'slow_job', HIGH_FAILURE_RATE = 'high_failure_rate', WORKER_UNHEALTHY = 'worker_unhealthy', QUEUE_BACKLOG = 'queue_backlog', TIMEOUT_SPIKE = 'timeout_spike', REPEATED_ERROR = 'repeated_error', MEMORY_SPIKE = 'memory_spike', CPU_SPIKE = 'cpu_spike', } enum AnomalySeverity { CRITICAL = 'critical', HIGH = 'high', MEDIUM = 'medium', LOW = 'low', } interface AnomalyAlert { id: string; anomalyType: AnomalyType; severity: AnomalySeverity; workerName: string; jobId?: string; message: string; details: Record<str
- When to Use This Skill
- Core Concepts
- Implementation
- TypeScript
- Python
- Usage Examples
- Worker Job Monitoring
- Periodic Health Checks
- Best Practices
- Common Mistakes
- Related Patterns
What does the anomaly-detection skill do?
Rule-based anomaly detection for production systems with configurable thresholds, cooldown periods to prevent alert storms, and error pattern tracking for repeated failures.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill anomaly-detection-dadbodgeoff-drift --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
