Claude Code 드리프트 감지: CC-Canary 소개
요약
Claude Code 사용 시 모델 성능 저하나 행동 변화 (드리프트) 를 조기에 발견할 수 있는 오픈소스 도구 'CC-Canary'가 출시되었습니다. 네트워크 연결 없이 로컬 JSONL 로그만 분석하여 비용, 토큰 사용량, 사고율 등 핵심 지표를 시각화하고 GitHub 이슈용 포렌식 리포트를 생성합니다.
핵심 포인트
- Claude Code의 `~/.claude/projects/` 디렉토리 내 JSONL 로그를 스캔해 모델 드리프트를 감지합니다.
- 비용 (USD), 토큰, 사고율 등 핵심 지표를 🟢🟡🔴 색상으로 표시한 포렌식 리포트를 생성합니다.
- 네트워크/계정 없이 로컬에서 실행되며, Claude 가 자체적으로 리포트 서론을 작성하는 하이브리드 방식입니다.
- 0.x 프리알파 버전으로 출력 형식이 변경될 수 있으나 즉시 설치 및 테스트가 가능합니다.
Drift detection for Claude Code, packaged as two installable Agent Skills
Reads the JSONL session logs Claude Code already writes to ~/.claude/projects/, detects whether the model has been drifting on your own work, and produces a shareable forensic report.
No network, no account, no telemetry, no background daemon. Runs on the data already on your disk.
Status: 0.x / pre-alpha — output format and metric set may change.
| Skill | Invocation | Output |
|---|---|---|
| cc-canary | /cc-canary [window] | forensic markdown writeup (./cc-canary-<date>.md) — paste-ready for GitHub issues or gists |
| cc-canary-html | /cc-canary-html [window] | same report as a dark-theme HTML dashboard (./cc-canary-<date>.html), auto-opens in your browser |
Window defaults to 60d. Accepts 7d / 14d / 30d / 60d / 90d / 180d.
Each report includes:
- Verdict — HOLDING / SUSPECTED REGRESSION / CONFIRMED REGRESSION / INCONCLUSIVE
- Headline metrics table (pre vs post, with 🟢/🟡/🔴 band verdicts)
- Weekly trend bars — cost (USD, verified against ccusage to the cent), read:edit ratio, reasoning loops, tokens/turn
- Cross-version comparison — same user, different model versions, controlling for task mix
- Auto-detected inflection date — composite health-score break
- Findings with model-side / user-side / ambiguous classification
- Appendices — hour-of-day thinking depth, word-frequency shift, three-period thinking-visibility transition, per-turn behavior rates, and more
npx skills add delta-hq/cc-canary
Install just one:
npx skills add delta-hq/cc-canary --skill cc-canary
npx skills add delta-hq/cc-canary --skill cc-canary-html
Then from any Claude Code session:
/cc-canary 60d
/cc-canary-html 30d
Requirements
- python3 ≥ 3.8 on your PATH.
- macOS / Linux / WSL for the
cc-canary-htmlauto-open step (it falls back to printing the path ifopen/xdg-open/startfails).
How it works
- Scan. A bundled Python script (stdlib only — no pip, no Node) walks
~/.claude/projects/**/*.jsonl, filters by window and excludes subagent sessions by default. - Dedupe. Assistant messages are deduped on
(message.id, requestId)— same scheme ccusage uses, because Claude Code writes the same message into multiple JSONLs when sessions are resumed or branched. - Aggregate. Per-session metrics: tool-mix, read:edit ratio, reasoning-loop phrases, self-admitted errors, premature stops, interrupts, token usage, cost (current Claude 4.x rates), hour-of-day thinking depth.
- Detect inflection. Composite health score per day; argmax of
|before − after|over candidate dates with a 0.75σ floor. Falls back to median-timestamp split if no break clears. - Pre-render the report. Script writes a markdown / HTML skeleton with every table and bar chart filled in. Only ~20 short narrative slots (marked
<!-- C: ... -->) are left for Claude to fill — verdict line, summary, per-finding reasoning, root-cause, appendix paragraphs. - Fill & save. Claude reads the skeleton, writes the narrative, saves the final file.
Total runtime: ~2.5s for the script + 10–20s for Claude to fill narrative.
Metrics in the headline table
(with published healthy/transition/concerning bands where applicable):
- Read:Edit ratio — file reads per edit. Proxy for how thoroughly the model investigates before mutating.
- Write share of mutations —
Write / (Edit + Write). High share = model rewriting files instead of surgical edits. - Reasoning loops / 1K tool calls — phrases like "let me try again", "oh wait", "actually,".
- Frustration rate — rate of frustration words in your prompts.
- Thinking redaction rate — fraction of thinking blocks that are redacted vs visible.
- Mean thinking length — reasoning-depth proxy (via cryptographic signature length, r=0.97 with content length when visible).
- API turns per user turn — how many API calls the model makes per user message.
- Tokens per user turn — total token volume (input + output + cache) per user message.
Plus appendices with additional signals: premature stopping, self-admitted errors, shortcut vocabulary, user interrupts, hour-of-day thinking depth, per-word frequency shift, three-period thinking-visibility transition, per-turn behavior rates.
Custom runs via Bash flags
The script accepts flags you can pass via Bash (python3 scripts/compute_stats.py …) for custom runs:
| Flag | Default | Purpose |
|---|---|---|
--window {Nd} | 60d | Window size (7d / 14d / 30d / 60d / 90d / 180d) |
--include-agents | off | Include subagent sessions (default: excluded — they have no natural user prompts) |
--min-user-words N | 10 | Drop sessions with fewer user-prompt words than this (filters trivial sessions) |
--render-md PATH | — | Write the markdown skeleton to PATH |
--render-html PATH | — | Write the HTML dashboard to PATH |
Privacy & Security
- Fully local. Zero network calls.
- The script reads
~/.claude/projects/*.jsonlonly. Nothing else. - Narrative prose is written by Claude during the skill invocation (inside your Claude Code session); it has access only to the on-disk files you explicitly point it at.
- User-prompt content is truncated to ≤180 chars before being included in the skeleton, and redacted for
/Users/…paths, emails, hex-like tokens. - Output files (
./cc-canary-<date>.{md,html}) live in the directory where you invoked the skill. Nothing is uploaded anywhere.
Contributing
Issues, metric suggestions, and PRs welcome: github.com/delta-hq/cc-canary/issues.
Output format and metric set may change during 0.x.
Canaries were used in coal mines to detect early signs of danger. cc-canary does the same for drift in your Claude Code sessions.
AI 자동 생성 콘텐츠
본 콘텐츠는 HN Claude Code의 원문을 AI가 자동으로 요약·번역·분석한 것입니다. 원 저작권은 원저작자에게 있으며, 정확한 내용은 반드시 원문을 확인해 주세요.
원문 바로가기