thedotmack/claude-mem / plugin/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.
scripts/tests/test_snapshot.py
View on GitHubimport os
import shutil
import sqlite3
import tempfile
import unittest
from unittest.mock import patch
import _paths # noqa: F401
from acr import snapshot
class DbPath(unittest.TestCase):
def test_env_override(self):
self.assertEqual(snapshot.db_path({"CLAUDE_MEM_DATA_DIR": "/data/mem"}), os.path.join("/data/mem", "claude-mem.db"))
def test_default_is_home_claude_mem(self):
expected = os.path.join(os.path.expanduser("~"), ".claude-mem", "claude-mem.db")
self.assertEqual(snapshot.db_path({}), expected)
self.assertEqual(snapshot.db_path({"CLAUDE_MEM_DATA_DIR": ""}), expected)
class Backup(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.mkdtemp(prefix="acr-snap-")
self.live = os.path.join(self.tmp, "live", "claude-mem.db")
os.makedirs(os.path.dirname(self.live))
db = sqlite3.connect(self.live)
db.execute("PRAGMA journal_mode=WAL")
db.execute("CREATE TABLE sdk_sessions (content_session_id TEXT, project TEXT, started_at_epoch INTEGER)")
db.executemany("INSERT INTO sdk_sessions VALUES (?,?,?)", [("s1", "p", 1), ("s2", "q", 2)])
db.commit()
db.close()
self.writer = sqlite3.connect(self.live)
self.writer.execute("PRAGMA wal_autocheckpoint=0")
self.writer.execute("INSERT INTO sdk_sessions VALUES (?,?,?)", ("s3", "r", 3))
self.writer.commit()
def tearDown(self):
self.writer.close()
shutil.rmtree(self.tmp, ignore_errors=True)
def test_snapshot_is_a_faithful_copy_and_live_is_untouched(self):
before = os.stat(self.live)
out = os.path.join(self.tmp, "out")
snap = snapshot.snapshot(out, live=self.live)
self.assertEqual(snap, os.path.join(out, "snapshot.db"))
after = os.stat(self.live)
self.assertEqual((before.st_mtime_ns, before.st_size), (after.st_mtime_ns, after.st_size))
db = snapshot.open_snapshot(snap)
rows = db.execute("SELECT content_session_id, project FROM sdk_sessions ORDER BY 1").fetchall()
db.close()
self.assertEqual([tuple(r) for r in rows], [("s1", "p"), ("s2", "q"), ("s3", "r")])
# a second run replaces the stale snapshot
snap2 = snapshot.snapshot(out, live=self.live)
self.assertEqual(snap, snap2)
def test_env_resolution_used_when_live_not_given(self):
with patch.dict(os.environ, CLAUDE_MEM_DATA_DIR=os.path.dirname(self.live)):
snap = snapshot.snapshot(os.path.join(self.tmp, "out2"))
self.assertTrue(os.path.exists(snap))
def test_missing_db_is_a_clear_error(self):
with self.assertRaises(FileNotFoundError):
snapshot.snapshot(os.path.join(self.tmp, "out3"), live=os.path.join(self.tmp, "nope.db"))
if __name__ == "__main__":
unittest.main()
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 |