Feature request: show recent sessions by worktree/branch

Resolved 💬 2 comments Opened Mar 19, 2026 by mikewiacek Closed Apr 16, 2026

Problem

When using Claude Code across multiple git worktrees, there's no way to see which worktree/branch you most recently worked on for a given task. The session data is all there in ~/.claude/projects/ but there's no viewer for it.

The directory names under ~/.claude/projects/ encode filesystem paths by replacing / with -, but this encoding is ambiguous (hyphens in directory names vs path separators are indistinguishable). Meanwhile, the session JSONL files already store the actual cwd — it's just not surfaced anywhere.

Use case

I frequently work across 10-20 git worktrees simultaneously. I'll start a session in one worktree, switch to another for a different task, and quickly lose track of where I was working on what. A command like claude sessions or claude recent that shows:

0m ago   /home/mike/depot/src/stairwell  [branch: mike/massdns]
8m ago   /home/mike/worktrees/secret_temporal_death/src/stairwell  [worktree: secret_temporal_death, branch: mike/secret_temporal_death]
1h ago   /home/mike/worktrees/sstable_service/src/stairwell  [worktree: sstable_service, branch: mike/fix-prevmr-delete-bug]
17h ago  /home/mike/worktrees/prod_mr_plumbing/src/stairwell  [worktree: prod_mr_plumbing, branch: mike/prod_mr_plumbing]

...would be extremely useful for heavy worktree users.

Suggested implementation

  1. Read the cwd field from session JSONL files (first few lines contain a {"type":"progress","cwd":"..."} entry)
  2. Group sessions by worktree/repo root
  3. Show the git branch for each (via git rev-parse --abbrev-ref HEAD)
  4. Sort by most recent session activity
  5. Mark paths that no longer exist on disk

I wrote a quick Go tool that does this as a workaround: it scans ~/.claude/projects/*/, reads the cwd from JSONL files, falls back to greedy path matching against disk for older sessions without JSONL, and groups by worktree. Works well enough to demonstrate the value.

Why this matters

The data already exists — Claude Code tracks sessions per-directory. It just needs a way to list them across directories with git context. For anyone using worktrees (which Claude Code itself creates via /worktree), this is table stakes for staying oriented.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗