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가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
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
Run the tracker from the project root:
node plugins/ruflo-cost-tracker/scripts/track.mjsThe 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.Inspect the markdown summary — total cost, per-model and per-tier breakdowns, and the persisted memory key.
Verify persistence —
mcp__plugin_ruflo-core_ruflo__memory_search({ query: "session-", namespace: "cost-tracking" })should list the new record.cost-reportstep 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.
댓글
- …
이 저장소의 다른 스킬
agent-adaptive-coordinator
81k작업량이 바뀔 때 에이전트 무리를 나누고 재배치해, 작업에 맞는 배치를 고르도록 에이전트를 돕습니다.
agent-agent
81k큰 목표를 순서가 있는 행동 계획으로 나누고, 조건이 바뀌면 다시 계획하도록 에이전트를 가르칩니다.
agent-agentic-payments
81kAI 쇼핑을 위한 지출 위임장을 관리합니다. 지출 상한, 시간 창, 판매자 규칙, 서명된 승인을 포함합니다.
agent-analyze-code-quality
81k에이전트가 파일을 바꾸지 않고, 코드 품질 문제와 코드 냄새, 기술 부채, 리팩터링 아이디어를 찾아 검토하도록 돕습니다.