절약
PRECC는 매 인터셉션에서 추정 토큰 절약량을 추적합니다. precc savings를 사용하여 PRECC가 얼마나 낭비를 방지했는지 확인하세요.
빠른 요약
$ precc savings
Session Token Savings
=====================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens
Breakdown:
Pillar 1 (cd prepends): <span data-stat="session_p1_tokens">3,204</span> tokens (<span data-stat="session_p1_count">6</span> corrections)
Pillar 4 (skill activations): <span data-stat="session_p4_tokens">1,560</span> tokens (<span data-stat="session_p4_count">4</span> activations)
RTK rewrites: <span data-stat="session_rtk_tokens">2,749</span> tokens (<span data-stat="session_rtk_count">11</span> rewrites)
Lean-ctx wraps: <span data-stat="session_lean_tokens">1,228</span> tokens (<span data-stat="session_lean_count">2</span> wraps)
상세 분석 (Pro)
$ precc savings --all
Session Token Savings (Detailed)
================================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens
Command-by-command:
# Time Command Saving Source
1 09:12 cargo build 534 tk cd prepend (cargo-wrong-dir)
2 09:14 cargo test 534 tk cd prepend (cargo-wrong-dir)
3 09:15 git status 412 tk cd prepend (git-wrong-dir)
4 09:18 npm install 824 tk cd prepend (npm-wrong-dir)
5 09:22 find . -name "*.rs" 387 tk RTK rewrite (output truncation)
6 09:25 cat src/main.rs 249 tk RTK rewrite (lean-ctx wrap)
7 09:31 cargo clippy 534 tk cd prepend (cargo-wrong-dir)
...
Pillar Breakdown:
Pillar 1 (context resolution): <span data-stat="session_p1_tokens">3,204</span> tokens <span data-stat="session_p1_pct">36.6</span>%
Pillar 2 (GDB debugging): 0 tokens 0.0%
Pillar 3 (mined preventions): 0 tokens 0.0%
Pillar 4 (automation skills): <span data-stat="session_p4_tokens">1,560</span> tokens <span data-stat="session_p4_pct">17.8</span>%
RTK rewrites: <span data-stat="session_rtk_tokens">2,749</span> tokens <span data-stat="session_rtk_pct">31.5</span>%
Lean-ctx wraps: <span data-stat="session_lean_tokens">1,228</span> tokens <span data-stat="session_lean_pct">14.1</span>%
절약량 추정 방법
각 수정 유형에는 PRECC 없이 발생했을 상황을 기반으로 한 예상 토큰 비용이 있습니다:
| 수정 유형 | 예상 절약 | 근거 |
|---|---|---|
| cd prepend | ~500 tokens | 오류 출력 + Claude 추론 + 재시도 |
| 스킬 활성화 | ~400 tokens | 오류 출력 + Claude 추론 + 재시도 |
| RTK rewrite | ~250 tokens | Claude가 읽어야 할 장황한 출력 |
| Lean-ctx wrap | ~600 tokens | 대용량 파일 내용 압축 |
| 마이닝된 예방 | ~500 tokens | 알려진 실패 패턴 회피 |
이것은 보수적인 추정치입니다. Claude의 오류에 대한 추론이 장황할 수 있으므로 실제 절약량은 종종 더 높습니다.
누적 절약
절약량은 PRECC 데이터베이스에서 세션 간에 유지됩니다. 시간이 지나면서 전체적인 영향을 추적할 수 있습니다:
$ precc savings
Session Token Savings
=====================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens
Lifetime savings: <span data-stat="total_tokens_saved">142,389</span> tokens across <span data-stat="total_sessions">47</span> sessions
상태 표시줄
설치 후 PRECC는 ~/.claude/settings.json에 statusLine 항목을 추가하여 Claude Code 상태 표시줄에 실시간 세션 메트릭이 표시되도록 합니다:
$0.42 spent | 1.2M in/out | 📊 last cmd: −1.2K | PRECC: 7 fixes | 5.8ms avg | this session: 320 saved over 7 cmds (~$0.05) | lifetime: 8.9K saved over 217 cmds (~$2.85)
레이블을 자신의 언어로 표시하려면 PRECC_LANG을 설정하세요 — 현지화 장을 참조하세요.
각 세그먼트:
| 세그먼트 | 소스 | 의미 | 세션 재시작 시 초기화되나요? |
|---|---|---|---|
$0.42 spent | cost.total_cost_usd | Claude Code가 보고한 누적 세션 비용 | 예 |
1.2M in/out | total_input_tokens + total_output_tokens | 세션 전체의 비캐시 입력 + 출력 토큰 | 예 |
📊 last cmd: −1.2K | 가장 최근 Bash 명령에 대한 PRECC 측정 | 원본을 재실행하여 측정한 실제 절감량 | 아니오 (세션 간 유지됨) |
PRECC: 7 fixes | metrics.log | 이번 세션의 수정 횟수 — 수정 개수만, 가짜 토큰 추정치 없음 | 예 |
5.8ms avg | PRECC 후크 지연 시간 p50 | PRECC가 각 도구 호출을 처리하는 데 소요한 시간 | 예 |
bash 18% of total | post_observations.log | Bash 출력에서 나온 세션 토큰의 비율 — PRECC의 절감액이 자연스럽게 전체 비용의 일부에 불과한 이유를 명확히 합니다 (PRECC는 Bash 출력만 최적화) | 예 |
this session: 320 saved over 7 cmds (~$0.05) | .lifetime_summary.json − baseline | 세션별 실제 델타. 델타가 0일 때 숨김(세션 시작) | 예 (기준이 다시 스냅샷됨) |
lifetime: 8.9K saved over 217 cmds (~$2.85) | .lifetime_summary.json | PRECC가 처음 설치된 이후 누적 절감 토큰과 재측정된 명령 수, 그리고 현재 토큰당 요율로 추정한 USD 가치 | 아니오 |
lifetime: 세그먼트는 마지막에 배치되어 Claude Code UI가 오른쪽 가장자리에서 바를 자를 때 가장 먼저 잘립니다.
비용과 토큰 수가 나누어지지 않는 이유
표시된 1.2M in/out은 $0.42 spent을 만들어낸 분모가 아닙니다. Claude Code의 cost.total_cost_usd는 API의 전체 토큰 분류에서 계산됩니다 — 기본 입력, 출력, 그리고 캐시 읽기와 캐시 생성까지 포함합니다. 세션 전체의 누적 캐시 토큰 수는 statusline 스키마에 노출되지 않으므로 PRECC는 보이는(비캐시) 부분만 표시할 수 있습니다.
파일 재읽기가 많은 긴 세션에서는 캐시 읽기가 보이는 토큰 수의 10배에 달할 수 있습니다. 그래서 둘을 비율로 짝짓는 것은 오해를 줄 수 있습니다 — 대신 PRECC는 이들을 독립 세그먼트로 표시합니다.
PRECC가 비용을 계산하지 않는 이유
비용 수치는 권위 있는 값입니다. PRECC는 Claude Code가 stdin을 통해 status 명령으로 보내는 JSON에서 cost.total_cost_usd를 그대로 읽습니다. 이는 Claude Code가 당신의 구독/사용 예산에서 차감하는 것과 동일한 숫자입니다. 내장된 /cost 슬래시 명령으로 언제든지 확인할 수 있습니다 — 두 값은 일치해야 합니다.
비용을 결정하는 요인
Claude Opus 4.6의 경우:
| Token type | Standard (≤200k context) | 1M context tier |
|---|---|---|
| Input | $15 / MTok | $30 / MTok |
| Output | $75 / MTok | $150 / MTok |
| Cache write | $18.75 / MTok | $37.50 / MTok |
| Cache read | $1.50 / MTok | $3 / MTok |
긴 세션에서 가장 큰 비용 요인은 보통 출력 토큰(특히 1M 컨텍스트 계층에서 토큰당 가장 비싼 유형), 반복되는 캐시 읽기(개별적으로는 저렴하지만 많은 턴에 걸쳐 빠르게 누적됨), 그리고 캐시 생성(파일 읽기당 한 번 기록되며 기본 입력 요율의 약 1.25배)입니다. PRECC는 Bash 출력을 압축하여 가시 토큰 비용을 줄이지만(📊 last cmd: 세그먼트가 명령당 절감액을 표시), Claude가 이미 로드한 파일의 캐시 읽기를 줄일 수는 없습니다.
안정적인 세션 카운트
“PRECC: N fixes” 세그먼트는 영속화된 세션 시작 이후의 이벤트를 셉니다. 세션 시작은 각 세션의 첫 statusline 새로 고침 시 ~/.local/share/precc/sessions/<session_id>.start에 기록됩니다. 이로 인해 카운트는 단조롭습니다 — 특정 새로 고침에서 cost.total_duration_ms가 없어도 세션 중간에 감소할 수 없습니다.
자동 새로 고침되는 누적 스냅샷
lifetime: 세그먼트는 ~/.local/share/precc/.lifetime_summary.json을 읽으며, 이 파일은 모든 PostToolUse 측정과 모든 precc savings 호출 시 재작성됩니다. this session: 세그먼트는 동일한 lifetime 파일을 읽지만, 각 세션의 첫 새로 고침 시 영속화된 세션별 기준값을 빼냅니다. 수동 새로 고침이 필요 없습니다 — 파일은 스스로 업데이트됩니다.
상태 표시줄 숨기기
기존 상태 표시줄을 유지하고 싶다면 ~/.claude/settings.json에 자신의 statusLine 명령을 설정하세요. PRECC 설치 프로그램은 사용자 지정 값을 감지하여 이후 업데이트에서 그대로 둡니다.
상호작용별 📊 PRECC 줄만(additionalContext 내) 숨기려면 셸 환경에서 PRECC_QUIET=1을 설정하세요.
Related research
PRECC’s three savings mechanisms each have a counterpart in the recent literature. These are related work — the ideas PRECC’s design draws on. Their reported figures are their measurements, not PRECC’s: PRECC only ever quotes numbers measured on your own machine (see “measured, not estimated”, above).
- Output/trajectory trimming (PRECC’s
diet+ bash-output compression) — Reducing Cost of LLM Agents with Trajectory Reduction (AgentDiet), FSE 2026, arXiv:2509.23586. Removes redundant/expired trajectory content post-hoc; reports −39.9–59.7% input tokens. PRECC applies the same idea pre-execution and deterministically (no extra LLM call). - Skills as programs (PRECC’s mined + builtin rewrite skills) — Harnessing LLM Agents with Skill Programs, arXiv:2605.17734. Frames reusable agent skills as executable program functions — the same analogy behind PRECC’s command-rewrite skills (a pattern → a deterministic rewrite).
- Context compression (PRECC’s
compress+lean-ctxwrapping) — Compress the Context, Keep the Commitments: A Formal Framework for Verifiable LLM Context Compression, arXiv:2605.17304. Recent work on compressing context without losing required information — the property PRECC’s deterministic, cache-stable rewrites aim to preserve.