cost-session
Fungsinya
Skill ini memecah satu sesi AI pesan demi pesan, dan menunjukkan balasan mana yang paling mahal. Skill ini untuk orang yang ingin memahami mengapa satu sesi terasa mahal.
Kapan dipakai
- βSaat sebuah sesi ditandai sangat mahal dan Anda ingin tahu alasannya.
- βSaat Anda ingin melihat pesan termahal di sesi terbaru Anda.
- βSaat Anda ingin tahu apakah penulisan cache menyebabkan sebagian besar biaya.
Link skill
https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-session/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βPesan mana di sesi AI terakhir saya yang paling mahal, dan kenapa?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Skill membaca log sesi, menghitung harga setiap balasan menurut jenis tokennya, lalu mengurutkan balasan dari yang termahal. Skill juga menandai balasan yang jauh di atas biaya tipikal sesi itu.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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.
Pertanyaan umum
Bisakah saya memilih sesi tertentu?
Bisa. Anda bisa memberi ID sesi, atau membiarkan skill memakai sesi yang terakhir berubah secara default.
Berapa banyak pesan yang ditampilkan?
Secara default 20 teratas, dan Anda bisa memilih jumlah lain.
Mengapa penulisan cache penting?
Penulisan cache bisa menambah biaya besar yang mudah terlewat jika Anda hanya melihat ukuran output.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 81k
- Peringkat
- #1609
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
agent-adaptive-coordinator
81kMembantu agent Anda membagi dan menyeimbangkan kembali sekelompok agent AI saat beban kerja berubah, dengan memilih tata letak yang sesuai tugas.
agent-agent
81kMengajari agent Anda mengubah tujuan besar menjadi rencana tindakan yang berurutan, dan menyusun ulang rencana saat kondisi berubah.
agent-agentic-payments
81kMembantu agent Anda mengelola mandat belanja untuk belanja AI, dengan batas pengeluaran, jendela waktu, aturan merchant, dan persetujuan yang ditandatangani.
agent-analyze-code-quality
81kMembantu agent Anda meninjau kualitas kode, menemukan bau kode, utang teknis, dan ide refaktor tanpa mengubah berkas.
Skill serupa
blucli
394kMembantu agent Anda menemukan, memutar, menjeda, mengelompokkan, dan mengatur volume speaker Bluesound dan NAD lewat perintah blu.
camsnap
394kMembantu agent Anda mengambil foto, klip pendek, atau peristiwa gerakan dari kamera jaringan dan webcam lokal yang sudah Anda atur.
eightctl
394kMembantu agent Anda memeriksa dan mengendalikan perangkat Eight Sleep, termasuk suhu, alarm, dan jadwal tidurnya.