본문으로 건너뛰기
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가 스킬을 읽고 지침을 따릅니다.

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

Use this skill to help me: https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-cost-tracker/skills/cost-track/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 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

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬