Langsung ke konten
Skillpedia
Lain-lain81k Β· #1611

cost-track

Fungsinya

Skill ini membaca log sesi coding AI Anda yang sedang berjalan dan menyimpan catatan pemakaian token dan biayanya. Skill ini untuk orang yang ingin pengeluaran AI mereka tercatat dari waktu ke waktu.

Kapan dipakai

  • βœ“Saat Anda selesai mengerjakan pekerjaan besar dan ingin mencatat biayanya.
  • βœ“Saat Anda ingin menyimpan total akhir di akhir sesi.
  • βœ“Saat Anda ingin memeriksa pengeluaran secara berkala selama sesi panjang.

Link skill

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

Salin 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

Gunakan skill ini untuk membantu saya: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-track/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œCatat berapa biaya sesi ini supaya bisa saya lihat di laporan saya nanti.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill menemukan log sesi yang aktif, menjumlahkan pemakaian token untuk setiap model, menghitung biaya dari daftar harga, lalu menyimpan totalnya. Anda juga bisa menjalankannya sebagai uji coba yang tidak menyimpan apa pun.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Cost Track

Reads the active Claude Code session jsonl (~/.claude/projects/<encoded-cwd>/<session>.jsonl), tallies assistant-message usage per model, computes USD cost using REFERENCE.md pricing, and writes a structured record to the cost-tracking AgentDB namespace. This is the producer that gives cost-report and cost-optimize real data to consume.

When to use

  • After a meaningful chunk of work, to capture spend for the report.
  • At session-end to persist the final tally.
  • Periodically during long sessions (cron-friendly β€” see /loop 30m).

Steps

  1. Run the tracker from the project root:

    node plugins/ruflo-cost-tracker/scripts/track.mjs
    

    The script auto-discovers the session jsonl from the current working directory. To pin a specific session: TRACK_SESSION=/path/to/session.jsonl. To dry-run (no memory write): TRACK_DRY_RUN=1.

  2. Inspect the markdown summary β€” total cost, per-model and per-tier breakdowns, and the persisted memory key.

  3. Verify persistence β€” mcp__plugin_ruflo-core_ruflo__memory_search({ query: "session-", namespace: "cost-tracking" }) should list the new record. cost-report step 1 reads from this namespace.

Record shape (in cost-tracking namespace)

Key: session-<sessionId>. Value (JSON):

{
  "sessionId": "1dba3b8c-...",
  "cwd": "/Users/cohen/Projects/ruflo",
  "startedAt": "2026-05-04T...",
  "endedAt": "2026-05-05T...",
  "messageCount": 234,
  "byModel": {
    "claude-opus-4-7": {
      "tier": "opus",
      "input_tokens": 12345,
      "output_tokens": 6789,
      "cache_creation_input_tokens": 800000,
      "cache_read_input_tokens": 2000000,
      "messages": 50,
      "cost_usd": 1.23
    }
  },
  "byTier": { "haiku": 0.0, "sonnet": 0.45, "opus": 1.23, "unknown": 0 },
  "total_cost_usd": 1.68,
  "capturedAt": "2026-05-05T..."
}

Pricing source of truth

The script's PRICING constant mirrors REFERENCE.md "Model pricing (USD per 1M tokens)". Update both together when prices change. Cache-write tokens are billed at cache_write rate; cache-read tokens at cache_read (per Anthropic billing docs).

Env overrides

Env Default Purpose
TRACK_CWD process.cwd() Override which project's sessions to scan
TRACK_SESSION most-recent jsonl Pin a specific session file
TRACK_OUT unset Also write the JSON summary to this path
TRACK_DRY_RUN=1 unset Skip the memory store call
TRACK_QUIET=1 unset Suppress markdown output
TRACK_NAMESPACE cost-tracking Override target namespace

Cross-references

  • cost-report (consumer) β€” reads records produced by this skill
  • REFERENCE.md "Cost attribution formula" β€” the math the script implements
  • cost-budget-check (consumer; landing in P2) β€” reads totals to evaluate alerts
Pertanyaan umum

Di mana log sesi ditemukan?

Skill mencarinya di folder Claude Code untuk proyek yang sedang Anda kerjakan, kecuali Anda menunjuk ke file tertentu.

Bisakah saya mengujinya tanpa menyimpan?

Bisa. Opsi uji coba mencetak hasilnya tanpa menulis apa pun ke memori.

Laporan mana yang memakai data ini?

Skill laporan biaya dan optimasi biaya membaca catatan yang disimpan skill ini.

Detail

Deskripsi asli dari pembuat

Auto-capture per-session token usage from the Claude Code session jsonl and persist to the cost-tracking namespace

repo: ruvnet/ruflo

Popularitas

Bintang GitHub
81k
Peringkat
#1611
Lisensi
MIT
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa