session-digger
CLAUDE.md34 starsChanged 4 months agoISCView on GitHub
Session Digger mines Claude Code session JSONL files for insights. It helps users recall past work, trace decisions, learn from mistakes, and understand file histories by analyzing ~/.claude/projects/ conversation data. Flow: Commands dispatch to agents. Agents use skills for domain knowledge and call scripts (via Bash tool) for data extraction. Scripts are thin bash wrappers around the scripts/echolib/ package. Python 3.9 is the floor because annotations use builtin generics (list[str], dict[str, int]), which Python 3.8 evaluates eagerly and rejects. Keep…
In this repository13 other files it gives its agents.
- session-diggerSkill
- deep-analysisSkill
- env-doctorSkill
- env-masterSkill
- env-radarSkill
- experience-synthesisSkill
- git-miningSkill
- jsonl-coreSkill
- memory-managementSkill
- native-diagSkill
- skill-insightSkill
- skill-searchSkill
- wechat-diggerSkill
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 50
All in scripts/, require only Python 3.9+ (stdlib only) and bash.
- Distinctive: line 101
Never collapse layers: Layer 0 is exact, Layer 1 is a cheap cache, Layer 2 is pure aggregation, Layer 3 is the only layer that makes …
- Very specific: line 106
Index first: Run /index once per environment, then use sd-recall.py search which auto-uses FTS.
- Very specific: line 108
Script-based parsing: Use the provided scripts instead of ad-hoc grep/jq pipelines.
- Very specific: line 113
--decisionsmode: When user asks "why did we..." or "decisions about X", add --decisions to recall.
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Session Digger — Plugin Development Guide
Purpose
Session Digger mines Claude Code session JSONL files for insights. It helps users recall past work, trace decisions, learn from mistakes, and understand file histories by analyzing ~/.claude/projects/ conversation data.
Architecture
commands/ → User-facing slash commands (entry points)
agents/ → Task-specific agents dispatched by commands via the Task tool
skills/ → Reusable knowledge (parsing rules, git patterns, synthesis taxonomy)
scripts/ → Python/bash tools that do the actual JSONL parsing and extractionFlow: Commands dispatch to agents. Agents use skills for domain knowledge and call scripts (via Bash tool) for data extraction. Scripts are thin bash wrappers around the scripts/echolib/ package.
Commands
/recall— Search and analyze past sessions (auto-uses FTS index after/index)/recap— Summarize recent sessions/timeline— Chronological project history (sessions + git)/lessons— Extract lessons learned/dashboard— Global memory overview and staleness alerts/audit— Memory staleness audit (heuristic or deep)/extract— Extract knowledge from conversation sessions/prune— Interactive memory cleanup/analyze— Analyze sessions for patterns (retry loops, errors, corrections)/apply— Interactive rule approval and persistence (y/n/e/a/q review)/topics— Topic segmentation and boundary detection/index— Build/update SQLite FTS search index/import— Import external conversations (WeChat, JSON, CSV, transcript)/save-summary— Save analysis result as cached summary for future recall/trend— Longitudinal trend analysis (week/month-over-month, by-theme, regressions)/optimize— Cross-session skill gap analysis → SKILL.md improvement proposals
Agents
recall— Unified search: session finding, decision archaeology, mistake huntingfile-historian— Trace a file's history across sessions and gitanalyze— Deep analysis of specific sessionsschema-scout— Detect JSONL schema changesmemory-auditor— Deep content-aware memory verification
Skills
jsonl-core— Canonical JSONL parsing infrastructure and record type referencegit-mining— Git log/blame/diff patterns for correlating commits with sessionsexperience-synthesis— Taxonomy for categorizing insights (decisions, mistakes, patterns)memory-management— Memory format, staleness scoring, and routing knowledge
Scripts
All in scripts/, require only Python 3.9+ (stdlib only) and bash. Git scripts additionally require git.
Python 3.9 is the floor because annotations use builtin generics (list[str],
dict[str, int]), which Python 3.8 evaluates eagerly and rejects. Keep the
floor honest: dataclass(slots=True) is 3.10-only and silently took a
registered command offline on 3.9 machines.
Core library:
echolib/— Core Python parsing package (no pip dependencies)
Unified engine (v0.7):
sd-recall.py— Unified single-process recall engine. Replaces bash pipeline (list-sessions + extract-messages + extract-tools). Uses SQLite FTS index when available, falls back to file scan. Supportssearch,sessions,statssubcommands.index-builder.py— Build/update SQLite FTS5 index. v1.1: now stores rich stats (tool_usage_json, tool_errors_json, flags_json, duration_seconds, project_name, tags, outcome) for trend/skill-gap analysis. Subcommands:build(incremental),search(FTS query),detail(session metadata),stats(index overview).dialog-adapter.py— Import external conversation formats (WeChat export, generic JSON/CSV, plaintext transcripts) into session-digger's JSONL schema. Auto-detects format.topic-segmenter.py— Topic boundary detection via time-gap + content-similarity heuristics. Outputs labeled segments with keywords.
Trend & skill-gap analysis (v0.8):
trend-engine.py— Longitudinal analysis over the SQLite index. Three modes:period-over-period(week/month comparison with deltas),by-theme(aggregate by project/tag/agent),regressions(detect tools getting worse). Reads ONLY the index, never raw transcripts.skill-gap-finder.py— Mine the index for recurring pain points (tool errors, retry loops, long conversations, project outliers) and draft reviewable SKILL.md proposals. Matches patterns to installed skills via keyword overlap. Never auto-edits skill files.format-detector.py— Signature-matching format detection for unknown agent transcripts. Scores known formats (Claude Code, Grok, Kimi Code, Cline, Aider, generic markdown) and surfaces unknown formats with sample keys for extension.
Per-command scripts:
analyze-session.sh— Pattern analysis: retry loops, errors, user corrections. Invoked by/analyze.apply-rules.sh— Format, review, and persist candidate rules. Invoked by/apply.post-compaction-hook.sh— Claude Code PreToolUse hook: detect compaction and remind about context recovery tools.
Group chat profiles (v0.7.1):
chat-profiles.py— Incremental participant profile extraction for group chats. Uses append-only merge rules inspired by baoyu-wechat-summary: quotes/events append unbounded, tags/interests merge with frequency sorting, speaking style only refines at 100-message thresholds. Outputs one JSON per participant.
Replaced by sd-recall.py subcommands:
- The old shell scripts (
list-sessions.sh,extract-messages.sh,extract-tools.sh,session-stats.sh,parse-jsonl.sh, etc.) have been removed in v0.6.0. - Their functionality lives in
sd-recall.pysubcommands:sessions,search,stats,session-stats,messages,tools,files,schema. save-summary.shandextract-knowledge.shhave also been replaced:sd-recall.py save-summaryandsd-recall.py extract-knowledge.recall-lite.sh— End-to-end no-API recall. Invoked by/recall --liteand runnable directly from a shell.
Architecture (four-layer model)
Inspired by agent-transcript-analyzer. Each layer has a distinct cost and trust level:
Layer 0: PARSE echolib/ Raw transcript → stats (exact, ground truth)
Layer 1: INDEX index-builder.py Stats → SQLite cache (rebuildable, fast to query)
Layer 2: TREND trend-engine.py Index → aggregation (pure arithmetic, re-runnable)
Layer 3: DECISION skill-gap-finder.py Patterns → proposals (judgment call, human-approved)Never collapse layers: Layer 0 is exact, Layer 1 is a cheap cache, Layer 2 is pure aggregation, Layer 3 is the only layer that makes judgment calls.
Key Conventions
- Index first: Run
/indexonce per environment, then usesd-recall.py searchwhich auto-uses FTS. sd-recall.pyas primary engine: New commands should usesd-recall.py search/sessions/statsinstead of the bash pipeline. Faster (single process), same output.- Script-based parsing: Use the provided scripts instead of ad-hoc grep/jq pipelines.
echolib/handles schema variations and noise filtering. - Grep tool is not bash: In agent/skill docs,
Grep pattern=...calls refer to the Claude Code Grep tool, not the bashgrepcommand. ${CLAUDE_PLUGIN_ROOT}: Resolves to this plugin's root directory at runtime. When undefined (global skill installation, not plugin mode), resolve the root viascripts/resolve_root.sh(SD_ROOT="$(scripts/resolve_root.sh)"), which encodes the full fallback chain.- Cache side effect:
build-index.sh/build_fallback_index()writes.session-digger-index.jsoninside~/.claude/projects/<dir>/. This is excluded from the plugin repo via.gitignore. - SQLite index:
~/.session-digger/index.db— auto-maintained byindex-builder.py. Mtime-based incremental updates: only changed files are re-parsed. --decisionsmode: When user asks "why did we..." or "decisions about X", add--decisionsto recall. Returns 60-80% fewer tokens by only surfacing decision-point messages.- Lite mode: Slash commands cost a model turn by definition — that's the contract. When users hit billing/tier errors or want raw evidence, route them to lite mode: either
/recall --lite(one cheap turn, raw script output, no synthesis) orscripts/recall-lite.shfrom a shell (zero API calls). Do not pretend a slash command can be made API-free. - Empty TSV fields: When parsing tab-separated rows from
list-sessions.shin bash, do not useIFS=$'\t' readdirectly — bash collapses consecutive tabs because tab is whitespace IFS, which corrupts rows where SUMMARY (or any other field) is empty. Translate tabs to a non-whitespace delimiter first (tr '\t' $'\x1f', thenIFS=$'\x1f' read). Seerecall-lite.shfor the pattern.
Speed Tier (v0.7)
1. /index (first time, ~5-30s one-time)
└─> sd-recall search → <50ms (FTS index hit)
└─> decisions mode → 60-80% token reduction
2. /topics → topic-segmenter.py (single pass, O(n) per session)
3. /import → dialog-adapter.py writes JSONL to _imported/
└─> /index picks it up automaticallyIncremental fingerprint
_file_fingerprint() uses mtime + size + head-hash (4KB MD5) for change detection.
This catches content changes that preserve mtime (git checkout, file copy with
preserved timestamp), which the old mtime-only check missed.
Privacy markers
dialog-adapter.py stamps imported sessions with a privacy field:
"plaintext_chat"for WeChat/transcript imports (plaintext conversation data)"imported"for generic JSON/CSV
Downstream analysis should respect this flag and avoid echoing raw content
back to users or LLMs without explicit consent. This mirrors wechat-local-vault's
contains_plaintext_wechat_data: true marker pattern.
References
CHANGELOG.md— 版本历史(v0.3 → 当前)。不要把它搬回 SKILL.md:历史条目曾占 SKILL.md 79% 的篇幅,而 SKILL.md 每次被激活都整体进入上下文。改了什么、为什么改看这里, 当前用法看 SKILL.md。references/report-template.md— Structure for single-session, batch, trend, and skill-gap reports.references/format-signatures.md— Agent format signature catalogue + checklist for adding new ones.
Prerequisites
- Python 3.9+ (stdlib only, no pip packages)
- bash
- git (optional, needed only for git-mining features and git-based agents)
- curl (optional, needed only for URL validation in /audit --deep)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

