Summary
Run without --all/--project, rtk discover (and the project-scoped rtk gain) auto-detects the current project and filters Claude Code history to it. For any project whose directory path contains spaces, brackets, or non-ASCII characters, this matches 0 sessions despite the history being present — making the default no-arg invocation silently useless.
Environment
rtk 0.42.0
- OS: Linux (WSL2), Claude Code history at
~/.claude/projects/
Reproduction
Working directory:
/home/user/projects/[QZX-7K42] - Análise Genérica de Exemplo
Claude Code stores its sessions under the encoded dir name:
-home-user-projects--QZX-7K42----An-lise-Gen-rica-de-Exemplo
From within that directory:
$ rtk discover
Scanned: 0 sessions # wrong — sessions exist
$ rtk discover --all
Scanned: 40 sessions # data is there
Isolating the matcher — it's a plain substring match against the encoded dir name, and the auto-derived filter doesn't reproduce that encoding:
# encoded dir name -> matches:
$ rtk discover --project="-home-user-projects--QZX-7K42----An-lise-Gen-rica-de-Exemplo"
Scanned: 40 sessions
# naive slash->dash, specials kept (≈ what auto-detect produces) -> 0:
$ rtk discover --project="-home-user-projects-[QZX-7K42] - An"
Scanned: 0 sessions
# literal cwd path -> 0 (slashes never appear in dir names):
$ rtk discover --project="/home/user/projects"
Scanned: 0 sessions
Root cause
Claude Code derives the dir name by replacing each non-[A-Za-z0-9] character with a single - (1:1, per character — note projects/[ -> projects-- is a double dash, and adjacent accents collapse to one dash each):
cwd: /home/user/projects/[QZX-7K42] - Análise Genérica de Exemplo
encoded: -home-user-projects--QZX-7K42----An-lise-Gen-rica-de-Exemplo
RTK appears to use the literal cwd (slashes never appear in encoded names) or a partial encoding that leaves brackets/spaces/accents intact, so the derived filter is never a substring of the real dir name -> 0 matches. Only affects paths with spaces, brackets, or non-ASCII chars; plain ASCII paths self-match, which is why it's gone unnoticed.
Suggested fix
Derive the project filter by reproducing Claude Code's exact per-character encoding of the absolute cwd before matching:
encoded = regex_replace(absolute_cwd, /[^A-Za-z0-9]/, "-")
then match that against entries in ~/.claude/projects/.
Workarounds
rtk discover --all
rtk discover --project="<substring of encoded dir name>" (use the --project= form — a value starting with - is parsed as a flag by clap)
Summary
Run without
--all/--project,rtk discover(and the project-scopedrtk gain) auto-detects the current project and filters Claude Code history to it. For any project whose directory path contains spaces, brackets, or non-ASCII characters, this matches 0 sessions despite the history being present — making the default no-arg invocation silently useless.Environment
rtk 0.42.0~/.claude/projects/Reproduction
Working directory:
Claude Code stores its sessions under the encoded dir name:
From within that directory:
Isolating the matcher — it's a plain substring match against the encoded dir name, and the auto-derived filter doesn't reproduce that encoding:
Root cause
Claude Code derives the dir name by replacing each non-
[A-Za-z0-9]character with a single-(1:1, per character — noteprojects/[->projects--is a double dash, and adjacent accents collapse to one dash each):RTK appears to use the literal cwd (slashes never appear in encoded names) or a partial encoding that leaves brackets/spaces/accents intact, so the derived filter is never a substring of the real dir name -> 0 matches. Only affects paths with spaces, brackets, or non-ASCII chars; plain ASCII paths self-match, which is why it's gone unnoticed.
Suggested fix
Derive the project filter by reproducing Claude Code's exact per-character encoding of the absolute cwd before matching:
then match that against entries in
~/.claude/projects/.Workarounds
rtk discover --allrtk discover --project="<substring of encoded dir name>"(use the--project=form — a value starting with-is parsed as a flag by clap)