inspecto 1.0.11 → 1.0.13
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 +101 -14
- package/dist/index.js +645 -101
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ The others answer *"how much did I spend?"*
|
|
|
27
27
|
|
|
28
28
|
`inspecto` answers: **"Is Claude Code getting worse for me — and can I prove it?"**
|
|
29
29
|
|
|
30
|
-
<img width="427" height="338" alt="Screenshot 2026-04-11 at 6 00 37
|
|
30
|
+
<img width="427" height="338" alt="Screenshot 2026-04-11 at 6 00 37 PM" src="https://github.com/user-attachments/assets/81777511-dd45-4ae0-8382-8e008dd98a7a" />
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
---
|
|
@@ -57,7 +57,7 @@ npx inspecto
|
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
```
|
|
60
|
-
inspecto v1.0.
|
|
60
|
+
inspecto v1.0.13 — Claude Code Session Quality Analyzer
|
|
61
61
|
|
|
62
62
|
Session: 31f3f224 | my-app | 47 min | claude-opus-4-6
|
|
63
63
|
|
|
@@ -72,6 +72,7 @@ npx inspecto
|
|
|
72
72
|
Retry density 0.08 ✓ healthy
|
|
73
73
|
Tool diversity 0.52 ⚠ warning
|
|
74
74
|
Tokens/useful-edit 3,218 ✓ healthy
|
|
75
|
+
...
|
|
75
76
|
```
|
|
76
77
|
|
|
77
78
|
### Detect regressions over time
|
|
@@ -90,6 +91,31 @@ npx inspecto cache-check
|
|
|
90
91
|
|
|
91
92
|
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.
|
|
92
93
|
|
|
94
|
+
### Discover projects and sessions
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# List all projects with session counts and last-active dates
|
|
98
|
+
npx inspecto list
|
|
99
|
+
|
|
100
|
+
# Show the 20 most recent sessions across all projects
|
|
101
|
+
npx inspecto list --sessions
|
|
102
|
+
|
|
103
|
+
# Show all sessions for a specific project
|
|
104
|
+
npx inspecto list --project my-app
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
Projects (9 found)
|
|
109
|
+
|
|
110
|
+
─────────────────────────────────────────────
|
|
111
|
+
Project Sessions Last active
|
|
112
|
+
─────────────────────────────────────────────
|
|
113
|
+
my-app 47 2026-06-08
|
|
114
|
+
api-gateway 12 2026-06-01
|
|
115
|
+
shared-lib 3 2026-05-28
|
|
116
|
+
─────────────────────────────────────────────
|
|
117
|
+
```
|
|
118
|
+
|
|
93
119
|
### Compare projects
|
|
94
120
|
|
|
95
121
|
```bash
|
|
@@ -104,18 +130,69 @@ npx inspecto compare --projects my-app,api-gateway,shared-lib
|
|
|
104
130
|
npx inspecto cache clear # delete the cache file (~/.claude/inspecto-cache.db)
|
|
105
131
|
```
|
|
106
132
|
|
|
107
|
-
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## CI integration
|
|
108
136
|
|
|
109
|
-
|
|
137
|
+
`inspecto` exits with a non-zero code when quality drops below acceptable thresholds:
|
|
138
|
+
|
|
139
|
+
| Command | Exits 1 when… |
|
|
110
140
|
|---|---|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
|
141
|
+
| `inspecto audit` | Overall grade is D or F (score < 67) |
|
|
142
|
+
| `inspecto trend` | Any metric has status `regression` |
|
|
143
|
+
| `inspecto cache-check` | Any session has a cache anomaly |
|
|
144
|
+
| `inspecto compare` | Never (comparison is informational) |
|
|
145
|
+
|
|
146
|
+
Use `--no-fail` on any command to always exit 0 — useful for scripts that want the output without failing the pipeline:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# In a pre-push hook — warn but don't block
|
|
150
|
+
npx inspecto audit --no-fail
|
|
151
|
+
|
|
152
|
+
# In CI — fail the build on regressions
|
|
153
|
+
npx inspecto trend --since 14d
|
|
154
|
+
|
|
155
|
+
# Export metrics for a dashboard without blocking
|
|
156
|
+
npx inspecto audit --format csv --no-fail >> metrics.csv
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## Output formats
|
|
162
|
+
|
|
163
|
+
All commands default to terminal output with color and tables. For scripting:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Structured JSON
|
|
167
|
+
npx inspecto audit --json
|
|
168
|
+
npx inspecto trend --json
|
|
169
|
+
|
|
170
|
+
# CSV (RFC 4180)
|
|
171
|
+
npx inspecto audit --format csv
|
|
172
|
+
npx inspecto trend --format csv
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`audit --format csv` produces one row per metric: `name,value,status,label`
|
|
176
|
+
|
|
177
|
+
`trend --format csv` produces one row per metric: `name,recentAvg,fullAvg,changePercent,status`
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Global options
|
|
182
|
+
|
|
183
|
+
| Flag | Commands | Description |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| `--json` | all | Output structured JSON |
|
|
186
|
+
| `--format <fmt>` | `audit`, `trend` | Output format: `json` or `csv` |
|
|
187
|
+
| `--no-fail` | `audit`, `trend`, `cache-check`, `compare` | Always exit 0 |
|
|
188
|
+
| `--data-dir <path>` | all | Custom Claude data directory (default: `~/.claude`) |
|
|
189
|
+
| `--project <name>` | `audit`, `trend`, `compare`, `list` | Filter to a specific project |
|
|
190
|
+
| `--since <duration>` | `trend`, `cache-check` | Time range (e.g., `7d`, `14d`, `30d`) |
|
|
191
|
+
| `--sessions` | `list` | Show sessions view instead of projects view |
|
|
115
192
|
|
|
116
193
|
---
|
|
117
194
|
|
|
118
|
-
## The
|
|
195
|
+
## The 12 Quality Metrics
|
|
119
196
|
|
|
120
197
|
Each metric is a pure function computed from your local session files. No data leaves your machine.
|
|
121
198
|
|
|
@@ -128,6 +205,11 @@ Each metric is a pure function computed from your local session files. No data l
|
|
|
128
205
|
| **M5** | Retry density | User repeating themselves (proxy for misunderstanding) | ≤ 0.10 |
|
|
129
206
|
| **M6** | Tool diversity | Over-reliance on a narrow set of tools (Shannon entropy) | ≥ 0.60 |
|
|
130
207
|
| **M7** | Tokens per edit | Token cost per productive action | ≤ 5,000 |
|
|
208
|
+
| **M8** | Subagent overhead | Fraction of turns delegated to subagents | < 0.60 |
|
|
209
|
+
| **M9** | Tool error rate | Rate of tool calls returning errors | ≤ 5% |
|
|
210
|
+
| **M10** | Thinking utilization | Fraction of turns using extended thinking | ≥ 30% |
|
|
211
|
+
| **M11** | MCP usage | Count of MCP tool turns (informational) | — |
|
|
212
|
+
| **M12** | Session cost | Total estimated session cost | ≤ $2.00 |
|
|
131
213
|
|
|
132
214
|
---
|
|
133
215
|
|
|
@@ -144,6 +226,9 @@ Once inspecto shows you where your sessions are degrading, here's how to fix eac
|
|
|
144
226
|
| **Retry density high** | You're repeating yourself — Claude keeps misunderstanding | You're probably under-specifying. Provide a concrete example of the output you want in the first message. If retries persist across sessions, the root cause is usually a missing `CLAUDE.md` or a context window that's too wide. |
|
|
145
227
|
| **Tool diversity low** | Claude over-relies on a narrow tool set (e.g. only Bash) | Prompt explicitly: *"Use the most specific tool available. Prefer Read over Bash for file reads. Prefer Edit over Write for modifications."* This is also a sign of a degraded model — track it over time with `inspecto trend`. |
|
|
146
228
|
| **Tokens/edit high** | High token burn per productive action | Shorten your context. Close irrelevant files in the IDE, trim `CLAUDE.md` to essentials, and use `--project` to scope sessions to one repo at a time. |
|
|
229
|
+
| **Tool error rate high** | Claude's tool calls are frequently failing | Usually means Claude is passing bad arguments or calling tools on files that don't exist. Add stricter preconditions in `CLAUDE.md`: *"Verify a file exists before reading it. Verify a path before writing."* |
|
|
230
|
+
| **Thinking utilization low** | Extended thinking is rarely being used | For complex tasks, prompt Claude to think before acting: *"Think carefully before making any changes."* Low thinking utilization often correlates with shallow analysis and increased retry density. |
|
|
231
|
+
| **Session cost high** | Spending more than expected per session | Scope sessions narrowly — one task, one repo. Use `--project` to avoid scanning large unrelated projects. Frequent cache misses compound cost; check `cache-check` if cost spiked unexpectedly. |
|
|
147
232
|
|
|
148
233
|
**The single highest-leverage fix:** a well-structured `CLAUDE.md`. It front-loads context so Claude reads less at runtime, forces it to follow project conventions, and survives session restarts without re-explaining yourself.
|
|
149
234
|
|
|
@@ -153,9 +238,9 @@ Once inspecto shows you where your sessions are degrading, here's how to fix eac
|
|
|
153
238
|
|
|
154
239
|
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.
|
|
155
240
|
|
|
156
|
-
`inspecto` 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
|
|
241
|
+
`inspecto` 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 12 metrics above.
|
|
157
242
|
|
|
158
|
-
The composite grade is a weighted average mapped to a letter grade from **A+** to **F**.
|
|
243
|
+
The composite grade is a weighted average mapped to a letter grade from **A+** to **F**. Grades below **D+** (score < 67) trigger a non-zero exit code in CI mode.
|
|
159
244
|
|
|
160
245
|
---
|
|
161
246
|
|
|
@@ -188,11 +273,12 @@ Architecture:
|
|
|
188
273
|
```
|
|
189
274
|
src/
|
|
190
275
|
├── parser/ # Streaming JSONL reader + session builder (merges streaming chunks)
|
|
191
|
-
├── metrics/ #
|
|
276
|
+
├── metrics/ # 12 pure-function quality metrics + composite grader
|
|
192
277
|
├── anomaly/ # Baseline computation + regression detection + cache anomaly
|
|
193
|
-
├── reporter/ # Terminal (chalk + cli-table3) and
|
|
194
|
-
├── commands/ # audit, trend, cache-check, compare
|
|
278
|
+
├── reporter/ # Terminal (chalk + cli-table3), JSON, and CSV output modes
|
|
279
|
+
├── commands/ # audit, trend, cache-check, compare, list
|
|
195
280
|
├── cache/ # SQLite grade-result cache (node:sqlite, ~/.claude/inspecto-cache.db)
|
|
281
|
+
├── config/ # .inspecto.json config loader + per-metric threshold/weight overrides
|
|
196
282
|
└── utils/ # Levenshtein, paths, duration parsing, formatting, concurrency helper
|
|
197
283
|
```
|
|
198
284
|
|
|
@@ -203,6 +289,7 @@ Key technical details:
|
|
|
203
289
|
- **Real token cost**: `input_tokens` is always a streaming placeholder — actual input = `cache_read_input_tokens + cache_creation_input_tokens`
|
|
204
290
|
- **Concurrency**: `trend` and `compare` parse up to 16 session files in parallel (semaphore-limited) so large histories don't block
|
|
205
291
|
- **Grade cache**: computed `GradeResult` objects are persisted in `~/.claude/inspecto-cache.db` (SQLite via `node:sqlite`). Cache key = `sha256(path:mtime)`. Re-runs over unchanged sessions skip parsing entirely — typically 2–3× faster
|
|
292
|
+
- **CI exit codes**: `audit` exits 1 on D/F grades, `trend` exits 1 on any regression, `cache-check` exits 1 on any anomaly. All suppressed by `--no-fail`
|
|
206
293
|
|
|
207
294
|
---
|
|
208
295
|
|