Communitygithub.com

비용 추적

로컬 ECC 비용 추적기 메트릭 로그에서 Claude Code의 토큰 사용량, 지출 및 예산을 추적하고 보고합니다. 사용자가 비용, 지출, 사용량, 토큰, 예산 또는 모델, 세션, 날짜별 비용 분석에 대해 물을 때 사용하세요.

비용 추적란 무엇인가요?

이 기술은 Claude Code 세션의 비용 및 사용량 데이터를 분석하고 보고하는 방법을 제공합니다. ECC의 `stop:cost-tracker` 훅이 생성하는 `~/.claude/metrics/costs.jsonl` JSONL 파일을 읽어 각 세션 종료 시점의 누적 비용 스냅샷을 기록합니다. 사용자가 지출 총액, 특정 세션 비용, 토큰 사용량, 예산 초과 여부 등을 질문할 때 적합하며, 노드(Node.js) 기반 스크립트를 통해 데이터를 안전하게 조회하고 분석합니다. 이 기술은 모델별, 세션별, 날짜별 비용 분석, CSV 내보내기, 예산 보고서 생성 등 실용적인 비용 관리 기능을 지원합니다. Claude Code 환경에서 비용 투명성을 높이고 예산 초과를 방지하는 데 유용한 도구입니다.

지원 대상✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/cost-tracking

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

비용 추적은(는) 무엇을 하나요?

이 기술을 사용하여 ECC의 stop:cost-tracker 훅이 기록하는 메트릭 로그에서 Claude Code 비용 및 사용량 내역을 분석하세요.

데이터 위치

추적기는 세션이 종료될 때마다 하나의 JSON 객체를 ~/.claude/metrics/costs.jsonl 파일에 추가합니다. 각 행은 해당 세션의 누적 스냅샷이므로, 총 지출을 계산하려면 session_id별 최신 행을 가져와 모든 세션의 합계를 구해야 합니다. 모든 행을 단순히 합산하면 중복 계산이 발생합니다.

행 스키마:

필드의미
timestamp스냅샷의 ISO 타임스탬프
session_idClaude Code 세션 식별자
transcript_path세션 기록 파일 경로
model사용된 모델
input_tokens / output_tokens토큰 수
cache_write_tokens / cache_read_tokens프롬프트 캐시 토큰 수
estimated_cost_usd세션의 USD 누적 예상 비용

estimated_cost_usd를 수동 계산보다 우선 사용하세요. 모델 및 캐시 가격은 변경될 수 있으며, 추적기가 신뢰할 수 있는 출처입니다.

사용 시기

  • 사용자가 "얼마나 썼지?", "이 세션 비용은 얼마야?" 또는 "내 토큰 사용량은?"과 같이 질문할 때
  • 사용자가 예산, 지출 한도, 초과 사용 또는 비용 제어에 대해 언급할 때
  • 사용자가 모델, 세션, 날짜별 비용 분석이나 CSV 내보내기를 원할 때

작동 방식

먼저 로그 파일이 존재하는지 확인하세요 (node 사용. sqlite3 사용 금지 — 추적기는 JSONL을 기록하며 node는 크로스 플랫폼입니다):

node -e 'const fs=require("fs"),os=require("os"),p=require("path");const f=p.join(os.homedir(),".claude","metrics","costs.jsonl");console.log(fs.existsSync(f)?"cost log found":"cost log not found: "+f)'

로그가 없으면 사용량 데이터를 임의로 생성하지 마세요. stop:cost-tracker 훅이 활성화된 상태에서 첫 번째 세션이 종료된 후 비용 추적이 활성화된다는 점을 사용자에게 알리세요.

예시 — 요약, 모델별, 최근 7일

node -e '
const fs=require("fs"),os=require("os"),path=require("path");
const f=path.join(os.homedir(),".claude","metrics","costs.jsonl");
if(!fs.existsSync(f)){console.log("cost log not found: "+f);process.exit(0);}
const rows=fs.readFileSync(f,"utf8").split(/\r?\n/).filter(Boolean).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(Boolean);
const bySession=new Map();
for(const r of rows){const k=r.session_id||r.transcript_path||r.timestamp;const p=bySession.get(k);if(!p||String(r.timestamp)>String(p.timestamp))bySession.set(k,r);}
const latest=[...bySession.values()];
const cost=r=>Number(r.estimated_cost_usd)||0, day=r=>String(r.timestamp||"").slice(0,10), sum=a=>a.reduce((s,r)=>s+cost(r),0), f4=n=>"$"+n.toFixed(4);
const today=new Date().toISOString().slice(0,10), yest=new Date(Date.now()-864e5).toISOString().slice(0,10);
console.log("today: "+f4(sum(latest.filter(r=>day(r)===today)))+" | yesterday: "+f4(sum(latest.filter(r=>day(r)===yest)))+" | total: "+f4(sum(latest))+" ("+latest.length+" sessions)");
const m=new Map();for(const r of latest){const k=r.model||"(unknown)";m.set(k,(m.get(k)||0)+cost(r));}
console.log("by model:");[...m.entries()].sort((a,b)=>b[1]-a[1]).forEach(([k,v])=>console.log("  "+f4(v)+"  "+k));
'

세션 세부 분석이나 CSV 내보내기를 위해 동일한 latest 집합 (또는 CSV의 경우 원시 행)을 반복하여 필요한 필드를 출력하세요.

보고 지침

비용 데이터를 제시할 때는 오늘 지출과 어제 지출, 전체 세션 합계, 모델별 분석 및 세션 수를 포함하세요. 1달러 미만 금액은 소수점 4자리, 더 큰 금액은 소수점 2자리로 표시하세요.

안티 패턴

  • 모든 행을 합산하지 마세요. 각 행은 세션별 누적이므로 먼저 session_id별 최신 행으로 축소해야 합니다.
  • estimated_cost_usd가 있으면 원시 토큰 수로 비용을 추정하지 마세요.
  • 확인하지 않고 로그가 존재한다고 가정하지 마세요.
  • 사용자에게 보여주는 답변에 현재 모델 가격을 하드코딩하지 마세요.
  • 임의 코드를 실행하는 검증되지 않은 훅이나 플러그인을 설치하지 마세요.

관련 항목

  • /cost-report - 동일한 메트릭 로그를 사용하는 명령형 보고서
  • cost-aware-llm-pipeline - 모델 라우팅 및 예산 설계 패턴
  • token-budget-advisor - 컨텍스트 및 토큰 예산 계획
  • strategic-compact - 반복 토큰 지출을 줄이기 위한 컨텍스트 압축

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

관련 스킬