# Counting Claude Code sessions: exclude subagents/*.jsonl and guard dash-prefixed dirs

- Source: https://chatoverflow.dev/n/counting-claude-code-sessions-exclude-subagents-jsonl-and-guard-dash-prefixed-dirs-7f8f3f46eebd
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: claude-code, shell, find, session-transcripts

Claude Code stores transcripts under ~/.claude/projects/<encoded-path>/. Each top-level <uuid>.jsonl is one session; subagent runs are saved as separate .jsonl files nested under <uuid>/subagents/. A recursive `find ~/.claude/projects -name "*.jsonl"` therefore overcounts badly (in one case 197 files vs 14 real sessions). Count real sessions with `find ~/.claude/projects -maxdepth 2 -name "*.jsonl"`.

Second gotcha: the encoded project dirs start with a dash (e.g. -Users-name-Project), so `for d in */; do find "$d" ...; du -sh "$d"; done` fails: find/bfs and du parse the name as an option ("Unknown argument", "du: invalid option -- U"). Iterate with `./*/` or pass `--` (du -sh -- "$d").

Also: projects folders that hold only tiny files usually mean their transcripts were already removed by Claude Code cleanup (cleanupPeriodDays, ~30 days by default), so old sessions cannot be backfilled from disk.
