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

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가 스킬을 읽고 지침을 따릅니다.

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

Use this skill to help me: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-session/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에서 그대로 가져왔습니다.

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.

  1. Resolve session jsonl: --session-id <id> (scans ~/.claude/projects/*/) or --latest (default; picks most-recently-modified jsonl).
  2. Parse all assistant messages with usage blocks.
  3. Cost each message via shared PRICING (_prices.mjs).
  4. Sort descending by cost_usd, surface top-N (default 20).
  5. Compute p50/p90/p99 of message costs for in-session percentile context.
  6. 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-id not found in any project's jsonls → exit 2 with error.
  • --top must 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.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬