본문으로 건너뛰기
Skillpedia
기타81k · #1591

cost-anomaly

하는 일

이 스킬은 다른 세션과 비교했을 때 지출이 평소보다 훨씬 많은 AI 세션을 찾습니다. 어떤 세션이 비용 급증을 일으켰는지 알고 싶은 사람을 위한 스킬입니다.

사용하는 경우

  • ✓한 AI 세션의 비용이 다른 세션보다 훨씬 많아 보일 때.
  • ✓전체 기록에서 비정상적으로 비싼 세션 목록이 필요할 때.
  • ✓비정상 세션이 나타나면 실패하는 점검을 원할 때.

스킬 링크

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-anomaly/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-anomaly/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 AI 세션 중에 다른 것보다 비용이 훨씬 많이 든 것이 무엇인지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 각 세션의 지출을 전형적인 지출과 비교합니다. 한 번의 큰 세션이 결과를 쉽게 흔들지 못하는 방법을 씁니다. 나머지보다 훨씬 높은 세션을 점수와 함께 나열합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Per-session outlier detection — the diagnostic counterpart to cost-burn's aggregate-trend signal.

Question Skill
"Is the AGGREGATE rate accelerating?" cost-burn
"Which SPECIFIC sessions are anomalous outliers?" cost-anomaly ← this
"Could we have spent less in aggregate?" cost-counterfactual
"When will we hit budget?" cost-projection

Algorithm

Implementation: scripts/anomaly.mjs.

  1. Read all session-* records from cost-tracking namespace.
  2. Filter to --since window (default: all-time).
  3. Compute median(total_cost_usd) and MAD = median(|x - median|).
  4. Per-session modified z-score (Iglewicz-Hoaglin 1993): z = 0.6745 * (x - median) / MAD
  5. Flag sessions with |z| > --threshold (default 3.5).

Why MAD and not mean + sigma?

Approach What breaks
mean + sigma A single $50 session inflates BOTH mean and sigma so badly that subsequent outliers hide inside the new "normal" band. Catastrophic on small samples.
median + MAD Both estimators ignore up to 50% of the data — the outliers themselves can't shift them. Robust on n=10. The canonical cutoff |z| > 3.5 is from Iglewicz-Hoaglin (1993).

Smoke transcript (5 baseline sessions $0.08-$0.12 + 1 outlier $5.00)

| Sessions considered | 5 |
| Threshold (|modified z|) | 3.5 |
| Median spend | $0.100000 |
| MAD | $0.010000 |
| Min / Max | $0.080000 / $5.000000 |
| **Outliers found** | **1** |

## Outlier sessions
| Session | Spend | Deviation | Modified z | Direction |
| outlier- | $5.000000 | +$4.900000 | 330.505 | high |

Exit codes

$ cost anomaly --alert-on-outliers 1
⚠ ALERT: found 1 outlier session(s) (|modified z| > 3.5); threshold was ≥1
exit 1

$ cost anomaly --alert-on-outliers 5
✓ found 1 outlier session(s); under threshold ≥5 — OK
exit 0

CI integration

# Fail the build if any session this week is a >3.5σ outlier
cost anomaly --since 7d --alert-on-outliers 1 || investigate-bad-session

Most useful when paired with cost-burn:

cost burn  --alert-on-acceleration-pct 50  || page-oncall   # rate-of-change alert
cost anomaly --alert-on-outliers 1         || investigate   # point-anomaly alert

Together they cover "is the average shifting?" AND "is there a single rogue session?" — both can fire independently.

Edge cases

  • n < 3: emit "Insufficient data" message, exit 0. MAD on 1-2 samples is meaningless.
  • MAD = 0: ≥50% of sessions share the exact same spend, so z-scores collapse. Emit explainer instead of dividing by zero. Common cause: dry-run sessions all at $0.
  • Low-direction outliers: usually crashed or dropped sessions, not over-spending. The output table explicitly labels direction so operators interpret correctly.
  • Very small MAD: even tiny absolute deviations produce huge z-scores. The $5 outlier with MAD=$0.01 yields z=330 — that's correct, not a bug.

Direction column

Direction Likely cause Action
high Long session, stuck in expensive tier, or runaway loop cost report + cost conversation to investigate
low Crash, dropped session, or unfinished work Verify the session completed normally
자주 묻는 질문

무엇을 이상치로 보나요?

기본적으로 점수가 3.5를 넘으면 표시합니다. 실행할 때 이 기준을 바꿀 수 있습니다.

세션이 왜 비쌌는지 보여 주나요?

직접 보여 주지는 않습니다. 이상치를 가리키며, 관련 스킬이 그 세션을 메시지 단위로 나눠 볼 수 있습니다.

이상치가 있으면 자동으로 실패하나요?

네. 선택 설정을 켜면 이상치가 있을 때 오류 코드를 반환하므로, 자동 점검에 유용합니다.

상세 정보

작성자의 원본 설명

MAD-based outlier detection on session spend: lists anomalous sessions with modified-z scores, with an optional --alert-on-outliers exit code for CI. Use when asked which individual session is the cost outlier; cost-burn covers the aggregate trend.

repo: ruvnet/ruflo

인기도

GitHub 스타
81k
순위
#1591
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬