本文へスキップ
Skillpedia
その他81k · #1611

cost-track

できること

このスキルは、現在のAIコーディングセッションのログを読み、そのトークン利用量とコストの記録を保存します。AIの支出を時間をかけて追跡したい人向けです。

使う場面

  • ✓大きな作業の区切りが終わり、かかったコストを記録したいとき。
  • ✓長いセッションの最後に、最終的な合計を保存したいとき。
  • ✓長いセッションの間、定期的なスケジュールでコストを確認したいとき。

スキルのリンク

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

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-track/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“このセッションにかかったコストを記録して、後でレポートに表示できるようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

スキルはアクティブなセッションのログを見つけ、モデルごとのトークン利用量を合計し、価格表からコストを計算して、合計を保存します。保存は行わないドライランとして実行することもできます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)を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
よくある質問

セッションのログはどこにありますか?

ファイルを指定しない限り、作業中のプロジェクトのClaude Codeフォルダーの中を探します。

保存せずにテストできますか?

はい。ドライランの設定で、メモリーに書き込まずに結果だけを表示できます。

どのレポートがこのデータを使いますか?

コストレポートとコスト最適化のスキルが、このスキルの保存した記録を読みます。

詳細

作者による元の説明

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

repo: ruvnet/ruflo

人気

GitHubのスター
81k
ランキング
#1611
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル