thedotmack/claude-mem / claude-mem-cursor/skills/agent-cost-report
agent-cost-report
VerifiedBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 100 B |
| CHECKSUMS.txt | markdown | 2.1 KB |
| SKILL.md | skill md | 21.3 KB |
| scripts/acr.py | script | 12.2 KB |
| scripts/acr/__init__.py | script | 105 B |
| scripts/acr/behavior.py | script | 17.5 KB |
| scripts/acr/classify.py | script | 5.5 KB |
| scripts/acr/costs.py | script | 6.3 KB |
| scripts/acr/devices.py | script | 5.4 KB |
| scripts/acr/evidence.py | script | 9.2 KB |
| scripts/acr/labels.py | script | 7.6 KB |
| scripts/acr/measure.py | script | 5.6 KB |
| scripts/acr/mistakes.py | script | 23.1 KB |
| scripts/acr/owner.py | script | 2.9 KB |
| scripts/acr/patterns.py | script | 26.0 KB |
| scripts/acr/period.py | script | 3.8 KB |
| scripts/acr/prices.py | script | 5.0 KB |
| scripts/acr/render.py | script | 52.7 KB |
| scripts/acr/rollup.py | script | 31.7 KB |
| scripts/acr/rules.json | config | 3.5 KB |
| scripts/acr/rules.py | script | 4.5 KB |
| scripts/acr/sample.py | script | 3.6 KB |
| scripts/acr/snapshot.py | script | 2.0 KB |
| scripts/acr/sync.py | script | 3.7 KB |
| scripts/acr/transcripts.py | script | 7.4 KB |
| scripts/acr/wins.py | script | 21.0 KB |
scripts/acr/snapshot.py
View on GitHub"""Read-only snapshot of the claude-mem SQLite database (plan Phase 1.3).
The live DB runs in WAL mode (src/services/sqlite/connection.ts:53-55), so a plain file copy
is wrong; the sqlite3 backup API is used instead. The live connection is opened with
`mode=ro` and closed right after the backup. Nothing here ever writes to the live DB.
"""
import os
import sqlite3
DB_FILE = "claude-mem.db"
SNAPSHOT_FILE = "snapshot.db"
def data_dir(env=None):
"""Mirrors src/shared/paths.ts:20-66: $CLAUDE_MEM_DATA_DIR if set, else ~/.claude-mem.
settings.json is never consulted."""
env = os.environ if env is None else env
d = env.get("CLAUDE_MEM_DATA_DIR")
return os.path.expanduser(d) if d else os.path.expanduser(os.path.join("~", ".claude-mem"))
def db_path(env=None):
return os.path.join(data_dir(env), DB_FILE)
def snapshot(outdir, live=None):
"""Copy the live DB into <outdir>/snapshot.db via the backup API; return the snapshot path."""
live = live or db_path()
if not os.path.exists(live):
raise FileNotFoundError(f"claude-mem database not found at {live} "
f"(set CLAUDE_MEM_DATA_DIR if it lives elsewhere)")
os.makedirs(outdir, exist_ok=True)
snap = os.path.join(outdir, SNAPSHOT_FILE)
for ext in ("", "-wal", "-shm", "-journal"): # drop a stale snapshot from an earlier run
if os.path.exists(snap + ext):
os.remove(snap + ext)
# copied from /workspace/weekly-cost-workflow/weekly_report.py:17
# src = sqlite3.connect(f"file:{LIVE}?mode=ro", uri=True); dst = sqlite3.connect(SNAP); src.backup(dst); dst.close(); src.close()
src = sqlite3.connect(f"file:{live}?mode=ro", uri=True)
try:
dst = sqlite3.connect(snap)
try:
src.backup(dst)
finally:
dst.close()
finally:
src.close()
return snap
def open_snapshot(snap):
"""Open a snapshot for querying (row_factory=Row, as weekly_report.py:18)."""
db = sqlite3.connect(snap)
db.row_factory = sqlite3.Row
return db
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| backup-setupthedotmack/claude-memSet up, check, or restore local claude-mem database snapshots. Use when the user says "set up backups", "back up my memories", "backup status", or "restore my database". | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |