claudectx 1.1.0 → 1.1.2

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 CHANGED
@@ -28,6 +28,10 @@ A typical Claude Code session costs **$2–$15 in tokens**. Most of it is wasted
28
28
  | Full file reads for small questions | 70% overhead from unnecessary lines | `claudectx mcp` |
29
29
  | No prompt caching configured | Paying 10× for static context | `claudectx optimize --cache` |
30
30
  | No cross-session memory | Repeating the same context every session | `claudectx compress` |
31
+ | Dead `@refs` and stale sections in CLAUDE.md | Silent token waste on every request | `claudectx drift` |
32
+ | Unknown cost before running a big task | Surprise bills after the fact | `claudectx budget` |
33
+ | Cache cold at session start | First request always a full miss | `claudectx warmup` |
34
+ | No visibility into team-wide spend | Can't attribute cost across devs | `claudectx teams` |
31
35
 
32
36
  ### Where your tokens actually go
33
37
 
@@ -59,6 +63,23 @@ claudectx compress
59
63
 
60
64
  # Review your token spend for the last 7 days
61
65
  claudectx report
66
+
67
+ # --- v1.1.0 additions ---
68
+
69
+ # Know the cost before you start a task
70
+ claudectx budget "src/**/*.ts" "tests/**/*.ts"
71
+
72
+ # Pre-warm your prompt cache so the first request is free
73
+ claudectx warmup --api-key $ANTHROPIC_API_KEY
74
+
75
+ # Find dead references and stale sections in CLAUDE.md
76
+ claudectx drift
77
+
78
+ # Convert CLAUDE.md to Cursor / Copilot / Windsurf format
79
+ claudectx convert --to cursor
80
+
81
+ # Export your usage data for team-wide cost attribution
82
+ claudectx teams export
62
83
  ```
63
84
 
64
85
  ## Installation
@@ -229,6 +250,124 @@ DAILY USAGE
229
250
 
230
251
  ---
231
252
 
253
+ ### `claudectx budget` — Know the cost before you start
254
+
255
+ Before running a big task, see exactly which files will be read, how many tokens they'll consume, and what it'll cost.
256
+
257
+ ```bash
258
+ claudectx budget "src/**/*.ts" # Estimate all TypeScript files
259
+ claudectx budget "**/*.py" --threshold 20000 # Warn if total exceeds 20K tokens
260
+ claudectx budget "src/**" --model opus --json # JSON output for scripting
261
+ ```
262
+
263
+ Output shows per-file token counts, cache hit likelihood (based on your recent reads), total cost estimate, and `.claudeignore` recommendations for files that are large but rarely useful.
264
+
265
+ ---
266
+
267
+ ### `claudectx warmup` — Pre-warm the prompt cache
268
+
269
+ Start each session with a cache hit instead of a full miss. Sends a silent priming request to Anthropic so your CLAUDE.md is cached before Claude Code touches it.
270
+
271
+ ```bash
272
+ claudectx warmup --api-key $ANTHROPIC_API_KEY # 5-min cache TTL (default)
273
+ claudectx warmup --ttl 60 --api-key $ANTHROPIC_API_KEY # 60-min extended TTL (2× write cost)
274
+ claudectx warmup --model sonnet --api-key $ANTHROPIC_API_KEY # use a specific model
275
+ claudectx warmup --cron "0 9 * * 1-5" # Install as weekday 9am cron job
276
+ claudectx warmup --json # JSON output for scripting
277
+ ```
278
+
279
+ Reports tokens warmed, write cost, savings per cache hit, and break-even request count.
280
+
281
+ > **Note on `--cron`:** The API key is **not** embedded in the cron job. At runtime, the job reads `ANTHROPIC_API_KEY` from your environment. Set it in `~/.profile` or `~/.zshenv` so cron can see it.
282
+
283
+ ---
284
+
285
+ ### `claudectx drift` — CLAUDE.md stays fresh, not stale
286
+
287
+ Over time CLAUDE.md accumulates dead references and sections nobody reads. `drift` finds them.
288
+
289
+ ```bash
290
+ claudectx drift # Scan current project
291
+ claudectx drift --days 14 # Use 14-day read window (default: 30)
292
+ claudectx drift --fix # Interactively remove flagged lines (creates CLAUDE.md.bak first)
293
+ claudectx drift --json # JSON output
294
+ claudectx drift --path /other/proj # Scan a different project directory
295
+ ```
296
+
297
+ Detects 4 types of drift:
298
+
299
+ | Type | Example |
300
+ |---|---|
301
+ | **Dead `@ref`** | `@src/old-service.ts` — file deleted |
302
+ | **Git-deleted mention** | `legacy-auth.py` appears in prose but was removed in git |
303
+ | **Stale section** | `## Android Setup` — zero reads in 30 days |
304
+ | **Dead inline path** | `src/utils/helper.py` mentioned in text, no longer exists |
305
+
306
+ ---
307
+
308
+ ### `claudectx hooks` — Hook marketplace
309
+
310
+ Install named, pre-configured hooks beyond the basic read logger.
311
+
312
+ ```bash
313
+ claudectx hooks list # Show all available hooks
314
+ claudectx hooks add auto-compress # Install with default threshold (50k tokens)
315
+ claudectx hooks add auto-compress --config threshold=30000 # Custom token threshold
316
+ claudectx hooks add slack-digest --config webhookUrl=https://hooks.slack.com/...
317
+ claudectx hooks remove slack-digest # Remove an installed hook
318
+ claudectx hooks status # Show what's installed
319
+ ```
320
+
321
+ **Built-in hooks:**
322
+
323
+ | Hook | Trigger | Config | What it does |
324
+ |---|---|---|---|
325
+ | `auto-compress` | PostToolUse (Read) | `threshold` (default: 50000) | Runs `claudectx compress` after each session |
326
+ | `daily-budget` | PreToolUse | _(none)_ | Reports today's spend before each tool call |
327
+ | `slack-digest` | Stop | `webhookUrl` (required) | Posts session report to a Slack webhook |
328
+ | `session-warmup` | PostToolUse (Read) | _(none)_ | Re-warms the cache; reads `ANTHROPIC_API_KEY` from env |
329
+
330
+ > **Security note:** Hooks that need an API key (`compress`, `warmup`) read `ANTHROPIC_API_KEY` from your environment — no secrets are stored in `.claude/settings.local.json`.
331
+
332
+ ---
333
+
334
+ ### `claudectx convert` — Use your CLAUDE.md everywhere
335
+
336
+ You wrote great instructions for Claude. Use them with Cursor, Copilot, or Windsurf too.
337
+
338
+ ```bash
339
+ claudectx convert --to cursor # → .cursor/rules/<section>.mdc (one per ## section)
340
+ claudectx convert --to copilot # → .github/copilot-instructions.md
341
+ claudectx convert --to windsurf # → .windsurfrules
342
+ claudectx convert --to cursor --dry-run # Preview without writing
343
+ ```
344
+
345
+ Each `##` section in CLAUDE.md becomes a separate Cursor `.mdc` file with `alwaysApply: true` frontmatter. `@file` references are stripped for assistants that don't support them.
346
+
347
+ ---
348
+
349
+ ### `claudectx teams` — Multi-developer cost attribution
350
+
351
+ See where the money goes across your whole team — without sharing session content.
352
+
353
+ ```bash
354
+ # Step 1: each developer runs this on their own machine
355
+ claudectx teams export # Default: last 30 days, sonnet pricing
356
+ claudectx teams export --days 7 --model haiku # Custom window and model
357
+
358
+ # Step 2: collect the JSON files in a shared directory, then aggregate
359
+ claudectx teams aggregate --dir ./reports/
360
+ claudectx teams aggregate --dir ./reports/ --anonymize # Replace names with Dev 1, Dev 2...
361
+ claudectx teams aggregate --dir ./reports/ --json # Machine-readable JSON
362
+
363
+ # Optional: copy your export to a shared location
364
+ claudectx teams share --to /shared/reports/
365
+ ```
366
+
367
+ Output shows per-developer spend, cache hit rate, avg request size, and top shared files. Exports are lightweight JSON — no session content, no prompts, just aggregated token counts.
368
+
369
+ ---
370
+
232
371
  ## How it all fits together
233
372
 
234
373
  ```
@@ -261,7 +400,7 @@ git clone https://github.com/Horilla/claudectx.git
261
400
  cd claudectx
262
401
  npm install
263
402
  npm run build
264
- npm test # 199 tests, should all pass
403
+ npm test # 278 tests, should all pass
265
404
  npm run lint # 0 errors expected
266
405
  ```
267
406