- Go 93%
- Nix 6%
- Makefile <1%
- Shell <1%
claude-session-merge #
Merges Claude Code session indexes from all your project directories into one combined index.
This lets the /insights command show usage stats across every project, not just the current one.
How it works #
Claude Code stores session data per project under ~/.claude/projects/.
Each project directory has a session_index.json tracking conversations in that project.
This tool reads all of them, deduplicates entries, and writes a merged index to a single target directory.
Usage #
# Merge everything (reads ~/.claude/projects/*, writes merged index)
claude-session-merge
# Preview what would happen
claude-session-merge --dry-run
# Use a different Claude config directory
claude-session-merge --config-dir /path/to/.claude
# Change the target directory name
claude-session-merge --target my-combined-sessions
# Use a custom config file
claude-session-merge --config /path/to/session-merge.yaml
# Convert a path to its Claude project directory name
claude-session-merge path-to-name ~/Development/my-project
# Output: -home-user-Development-my-project
Configuration #
Flags and environment variables #
The tool checks these in order (first match wins):
| Setting | Flag | Env var | Default |
|---|---|---|---|
| Config dir | --config-dir |
CLAUDE_CONFIG_DIR |
~/.claude |
| Config file | --config |
$CONFIG_DIR/session-merge.yaml |
|
| Target suffix | --target |
CLAUDE_SESSION_MERGE_TARGET |
all-projects |
Config file #
Place a session-merge.yaml in your Claude config directory (default: ~/.claude/session-merge.yaml).
All fields are optional.
# Target suffix for the merged index directory.
# CLI --target and CLAUDE_SESSION_MERGE_TARGET override this.
target: "all-projects"
# Root directories to scan for project subdirectories.
# Default (when empty/unset): $CONFIG_DIR/projects/
# Tilde (~/) is expanded to $HOME.
root_dirs:
- "~/.claude/projects"
# Only include directories matching these glob patterns.
# Matched against the directory basename (not full path).
# Mutually exclusive with blocklist.
allowlist:
- "-home-user-important-*"
# Skip directories matching these glob patterns.
# Matched against the directory basename (not full path).
# Mutually exclusive with allowlist.
blocklist:
- "-home-user-scratch-*"
- "-home-user-tmp-*"
Key behaviors:
allowlistandblocklistare mutually exclusive. Setting both produces an error.- Patterns use Go's
filepath.Matchglob syntax (e.g.,*,?,[abc]). - When
root_dirsis set, it replaces the default$CONFIG_DIR/projects/. Include the default explicitly if you still want it scanned. - The merged index is always written to
$CONFIG_DIR/projects/<target>, regardless of which roots are scanned. - Unknown YAML keys cause an error (strict parsing).
Finding project directory names #
Use the path-to-name subcommand to convert a filesystem path into the directory name Claude Code uses:
claude-session-merge path-to-name ~/Development/my-project
# -home-user-Development-my-project
claude-session-merge path-to-name ~/Development
# -home-user-Development
# Use in config as: "-home-user-Development-*"
The conversion replaces /, ., and ~ with -.
Flags #
| Flag | Description |
|---|---|
--config |
Config file path |
--config-dir |
Claude config directory |
--debug, -d |
Enable debug logging |
--dry-run |
Preview merge without writing |
--target |
Target directory name suffix |
Subcommands #
| Command | Description |
|---|---|
generate |
Regenerate marketplace.json |
path-to-name |
Convert a filesystem path to its Claude project directory name |
validate |
Check marketplace.json for required fields |
Claude Code marketplace #
This repo is a Claude Code marketplace.
It ships a session-merge plugin and a merge-sessions skill.
To install, add the marketplace and then install the plugin:
/plugin marketplace add https://git.sr.ht/~jcmuller/claude-session-merge
/plugin install session-merge@claude-session-merge
Installation #
# With nix
nix run sourcehut:~jcmuller/claude-session-merge
# From source
go install git.sr.ht/~jcmuller/claude-session-merge@latest