inspecto 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # cc-audit
2
+
3
+ **Claude Code session quality analyzer — grade sessions, detect regressions, catch cache bugs.**
4
+
5
+ > AMD's AI director manually analyzed 7,000 Claude Code sessions to prove it got worse.
6
+ > `cc-audit` automates that analysis for every developer.
7
+
8
+ Three tools already count tokens (`ccusage`, `claude-usage`, `Claude-Code-Usage-Monitor`). They answer *"how much did I spend?"*
9
+
10
+ `cc-audit` answers a different question: **"Is Claude Code getting worse for me, and can I prove it?"**
11
+
12
+ ---
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install -g cc-audit
18
+ ```
19
+
20
+ Or run without installing:
21
+
22
+ ```bash
23
+ npx cc-audit
24
+ ```
25
+
26
+ Requires Node.js >= 18. Works on macOS, Linux, and Windows.
27
+
28
+ ---
29
+
30
+ ## Usage
31
+
32
+ ### Grade your most recent session
33
+
34
+ ```bash
35
+ npx cc-audit
36
+ ```
37
+
38
+ ```
39
+ cc-audit v1.0.0 — Claude Code Session Quality Analyzer
40
+
41
+ Session: 31f3f224 | my-app | 47 min | claude-opus-4-6
42
+
43
+ Overall grade: B+
44
+
45
+ Metric Value Status
46
+ ─────────────────────────────────────────
47
+ Reads/edit 4.2 ✓ healthy
48
+ Rewrite ratio 0.18 ✓ healthy
49
+ Cache hit rate 0.73 ✓ healthy
50
+ Task completion 0.95 ✓ healthy
51
+ Retry density 0.08 ✓ healthy
52
+ Tool diversity 0.52 ⚠ warning
53
+ Tokens/useful-edit 3,218 ✓ healthy
54
+ ```
55
+
56
+ ### Detect regressions over time
57
+
58
+ ```bash
59
+ npx cc-audit trend --since 14d
60
+ ```
61
+
62
+ Compares the most recent half of your sessions against the full period and flags metrics that have regressed by more than 30%.
63
+
64
+ ### Catch the prompt cache bug
65
+
66
+ ```bash
67
+ npx cc-audit cache-check
68
+ ```
69
+
70
+ On March 31, 2026, the leaked Claude Code source revealed two cache bugs that silently inflate token costs 10-20x. This command detects sessions where the cache hit rate is suspiciously low.
71
+
72
+ ### Compare projects
73
+
74
+ ```bash
75
+ npx cc-audit compare --projects my-app,api-gateway,shared-lib
76
+ ```
77
+
78
+ ### Global options
79
+
80
+ | Flag | Description |
81
+ |---|---|
82
+ | `--json` | Output structured JSON (for CI, piping, scripts) |
83
+ | `--data-dir <path>` | Custom Claude data directory (default: `~/.claude`) |
84
+ | `--project <name>` | Filter to a specific project |
85
+ | `--since <duration>` | Time range (e.g., `7d`, `14d`, `30d`) |
86
+
87
+ ---
88
+
89
+ ## The 7 Quality Metrics
90
+
91
+ Each metric is a pure function computed from your local session files. No data leaves your machine.
92
+
93
+ | # | Metric | What it detects | Healthy |
94
+ |---|---|---|---|
95
+ | **M1** | Reads-before-edit ratio | Claude editing without reading context first | ≥ 4.0 |
96
+ | **M2** | Rewrite ratio | Full-file rewrites instead of surgical edits | ≤ 0.25 |
97
+ | **M3** | Cache hit rate | Prompt cache bugs inflating token costs | ≥ 0.50 |
98
+ | **M4** | Task completion | "I'll do X" promises without follow-through | ≥ 0.90 |
99
+ | **M5** | Retry density | User repeating themselves (proxy for misunderstanding) | ≤ 0.10 |
100
+ | **M6** | Tool diversity | Over-reliance on a narrow set of tools (Shannon entropy) | ≥ 0.60 |
101
+ | **M7** | Tokens per edit | Token cost per productive action | ≤ 5,000 |
102
+
103
+ ---
104
+
105
+ ## How it works
106
+
107
+ Claude Code writes one JSONL session file per conversation to `~/.claude/projects/{project}/{sessionId}.jsonl`. Each line is a JSON record — user messages, assistant responses (streamed as multiple chunks), tool calls, and tool results.
108
+
109
+ `cc-audit` streams these files line-by-line (never loading 100MB+ files into memory), merges streaming chunks by `message.id`, extracts tool-use patterns and token usage, and computes the 7 metrics above.
110
+
111
+ The composite grade is a weighted average mapped to a letter grade from **A+** to **F**.
112
+
113
+ ---
114
+
115
+ ## Why this exists
116
+
117
+ In the last 30 days before this tool was built:
118
+
119
+ - **Apr 7, 2026** — A Reddit post about Claude Code's declining quality hit 1,060 upvotes
120
+ - **Apr 6, 2026** — AMD's Director of AI filed a GitHub issue with data from 6,852 sessions proving Claude Code reads code 3x less before editing and rewrites entire files 2x more often than before
121
+ - **Mar 31, 2026** — Claude Code's source leaked via npm, revealing 2 cache bugs that silently inflate costs 10-20x
122
+ - **Mar 26, 2026** — Users on the $100/mo plan reported burning through limits in 90 minutes instead of 5 hours
123
+
124
+ The tools that track token spending tell you *what* you used. `cc-audit` tells you *whether it was worth it*.
125
+
126
+ ---
127
+
128
+ ## Development
129
+
130
+ ```bash
131
+ git clone https://github.com/rahulbhardwaj94/cc-audit.git
132
+ cd cc-audit
133
+ npm install
134
+ npm test
135
+ npm run build
136
+ node dist/index.js
137
+ ```
138
+
139
+ Architecture:
140
+
141
+ ```
142
+ src/
143
+ ├── parser/ # Streaming JSONL reader + session builder (merges streaming chunks)
144
+ ├── metrics/ # 7 pure-function quality metrics + composite grader
145
+ ├── anomaly/ # Baseline computation + regression detection + cache anomaly
146
+ ├── reporter/ # Terminal (chalk + cli-table3) and JSON output modes
147
+ ├── commands/ # audit, trend, cache-check, compare
148
+ └── utils/ # Levenshtein, paths, duration parsing, formatting
149
+ ```
150
+
151
+ Key technical details:
152
+ - **Streaming parse**: `readline` + `createReadStream` — never loads full files into memory
153
+ - **Chunk deduplication**: Assistant responses come as multiple JSONL records sharing `message.id`; content blocks are merged and only the final chunk's `output_tokens` is used
154
+ - **No external APIs**: All analysis is local. No network calls. Works offline
155
+ - **Real token cost**: `input_tokens` is always a streaming placeholder — actual input = `cache_read_input_tokens + cache_creation_input_tokens`
156
+
157
+ ---
158
+
159
+ ## License
160
+
161
+ MIT