cost-session
하는 일
이 스킬은 AI 세션 하나를 메시지 단위로 나눠 어떤 답변이 가장 비쌌는지 보여 줍니다. 한 세션이 왜 비쌌는지 알고 싶은 사람을 위한 스킬입니다.
사용하는 경우
- ✓세션이 유난히 비싸다고 표시되어 그 이유를 알고 싶을 때.
- ✓가장 최근 세션에서 가장 비싼 메시지를 보고 싶을 때.
- ✓캐시 쓰기가 비용의 큰 부분을 차지했는지 알고 싶을 때.
스킬 링크
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-session/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“지난 AI 세션에서 어떤 메시지가 가장 비쌌고, 이유가 무엇인지 알려 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 세션 기록을 읽고 토큰 종류별로 각 답변의 비용을 계산한 뒤, 비용이 높은 순으로 정렬합니다. 그 세션의 일반적인 비용보다 훨씬 높은 답변에는 표시를 붙입니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
When cost-anomaly flags a session as a >3.5σ outlier, the next question is "which MESSAGES were expensive?". cost-session answers that.
| Question | Skill |
|---|---|
| "Which sessions cost the most?" | cost-conversation |
| "Which sessions are outliers?" | cost-anomaly |
| "Which messages in THIS session were expensive?" | cost-session ← this |
Algorithm
Implementation: scripts/session.mjs.
- Resolve session jsonl:
--session-id <id>(scans~/.claude/projects/*/) or--latest(default; picks most-recently-modified jsonl). - Parse all assistant messages with
usageblocks. - Cost each message via shared PRICING (
_prices.mjs). - Sort descending by
cost_usd, surface top-N (default 20). - Compute p50/p90/p99 of message costs for in-session percentile context.
- Flag the top message if it's >2× the p99 — that's an in-session outlier.
Why this matters: cache writes are the silent cost
Example real session, top message:
| # | Model | In | Out | Cache W | Cache R | Cost |
| 1 | opus-4-7 | 6 | 569 | 881898 | 0 | $16.58 |
Without the Cache W column it looks like "569 output tokens cost $16" — that's wrong by 380×. The actual cost is ephemeral 1h cache write at opus pricing: 881,898 tokens × $18.75/1M = $16.54.
Operators reading the table see immediately: "the model wrote 881K tokens to ephemeral cache". From there the question becomes "why did we cache 881K tokens of context for a 6-input request?" — that's a real engineering signal.
Drill-down workflow
# Step 1: find outliers across all sessions
cost anomaly --alert-on-outliers 1 || cost anomaly # see which session-ids
# Step 2: drill into the flagged session
cost session --session-id <flagged-id> --top 10
# Step 3: open that jsonl at the timestamp the top message reports,
# inspect the prompt + tool calls
Percentile context
Top of output:
| p50 (median) message | $0.85 |
| p90 message | $1.45 |
| p99 message | $1.74 |
Lets operators ask "is this top message a 2× outlier or a 380× one?" without having to compute it themselves. The "top is >2× p99" footer fires when the answer is "yes, this is an in-session outlier worth investigating".
--since filter
Useful for drilling into a specific time range within a long session:
cost session --since 2026-06-16T13:00:00Z --top 5
Only messages with timestamp >= --since are considered.
Edge cases
- No costed assistant messages → "No costed assistant messages" + exit 0.
--session-idnot found in any project's jsonls → exit 2 with error.--topmust be a positive integer → exit 2.
자주 묻는 질문
특정 세션을 고를 수 있나요?
네. 세션 ID를 주거나, 기본값인 가장 최근에 바뀐 세션을 사용할 수 있습니다.
몇 개의 메시지를 보여 주나요?
기본은 상위 20개이며, 다른 숫자를 고를 수도 있습니다.
캐시 쓰기가 왜 중요한가요?
출력 양만 보면 놓치기 쉬운 큰 비용을 캐시 쓰기가 만들 수 있기 때문입니다.
상세 정보
작성자의 원본 설명
Per-message cost breakdown within a single session. The drill-down companion to cost-anomaly — when an outlier session is flagged, this surfaces the specific expensive messages so operators can see whether the cost came from output tokens, cache writes, or model escalations.
repo: ruvnet/ruflo
인기도
- GitHub 스타
- 81k
- 순위
- #1609
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
agent-adaptive-coordinator
81k작업량이 바뀔 때 에이전트 무리를 나누고 재배치해, 작업에 맞는 배치를 고르도록 에이전트를 돕습니다.
agent-agent
81k큰 목표를 순서가 있는 행동 계획으로 나누고, 조건이 바뀌면 다시 계획하도록 에이전트를 가르칩니다.
agent-agentic-payments
81kAI 쇼핑을 위한 지출 위임장을 관리합니다. 지출 상한, 시간 창, 판매자 규칙, 서명된 승인을 포함합니다.
agent-analyze-code-quality
81k에이전트가 파일을 바꾸지 않고, 코드 품질 문제와 코드 냄새, 기술 부채, 리팩터링 아이디어를 찾아 검토하도록 돕습니다.