cost-session

Ranks the most expensive messages within a single Claude session by token cost.

70.1k|8.4k|Updated Jun 2, 2025
One-click install
npx skills add https://github.com/ruvnet/claude-flow --skill cost-session
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cost-session
Source: https://github.com/ruvnet/claude-flow/tree/main/plugins/ruflo-cost-tracker/skills/cost-session
Command: npx skills add https://github.com/ruvnet/claude-flow --skill cost-session

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

When a session is flagged as a cost outlier, operators need to know which specific messages drove the spend. This Skill breaks down per-message costs inside one session, exposing whether the expense came from output tokens, ephemeral cache writes, or model escalations.

Core Features & Use Cases

  • Per-message cost ranking: Parses a session's jsonl transcript, prices every assistant message with usage data, and lists the top-N most expensive messages with input, output, cache write, and cache read token counts.
  • Percentile context: Computes p50, p90, and p99 message costs and flags the top message when it exceeds 2x the p99, identifying in-session outliers.
  • Flexible targeting: Select a session by ID or use the most recent one, and filter messages with a --since timestamp to drill into a specific time range.
  • Use Case: After cost-anomaly flags a session as a >3.5 sigma outlier, run this Skill on that session ID to discover that a single message wrote 881K tokens to ephemeral cache, explaining a $16.58 charge.

Quick Start

Ask the AI to show the top 10 most expensive messages in the latest Claude session and explain where the cost came from.

Frequently Asked Questions about cost-session

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find which messages cost the most in a Claude session?

Run the cost-session skill with a session ID or --latest to parse the session's jsonl transcript. It prices every assistant message with usage data and lists the top-N most expensive messages, defaulting to 20.

Why did a message with few output tokens cost so much?

The cost usually comes from ephemeral cache writes, not output tokens. A message writing 881K tokens to 1-hour cache at opus pricing costs about $16.54, which the Cache W column in the output table makes visible.

How does cost-session relate to cost-anomaly and cost-conversation?

cost-conversation ranks sessions by total cost, cost-anomaly flags statistical outlier sessions, and cost-session drills into one flagged session to show which specific messages drove the spend. It is the final step in the drill-down workflow.

Can I filter cost analysis to a specific time range in a session?

Yes, pass --since with an ISO timestamp such as 2026-06-16T13:00:00Z. Only messages with a timestamp at or after that value are costed and ranked, which is useful for long sessions.

What happens if the session ID is not found?

The skill exits with code 2 and an error when the given session ID is not found in any project's jsonl files. If a session simply has no costed assistant messages, it reports that and exits cleanly with code 0.