/agent-traffic-control:claude-code-projects-jsonl-worktree-fanoutfrom agent-traffic-control
Find a prior session's transcript that `~/.claude/projects/<project>/` does not hold: each git worktree gets its own separately namespaced project directory.
Ships in agent-traffic-control. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The user asks: "find that session ~2 weeks ago where we discussed X". You grep ~/.claude/projects/-Users-<user>-Documents-foo-project/*.jsonl for keywords, get partial or zero hits, and report "couldn't find it" — but the session does exist, just under a different directory because it ran inside a git worktree.
Claude Code maps each git worktree to its own project directory under ~/.claude/projects/. The canonical project at /Users/<user>/Documents/foo-project/ becomes:
~/.claude/projects/-Users-<user>-Documents-foo-project/
But a worktree created via git worktree add .claude/worktrees/<wt-name> becomes a separate sibling:
~/.claude/projects/-Users-<user>-Documents-foo-project--claude-worktrees-<wt-name>/
Each worktree dir holds its own JSONL transcripts for sessions started from that working directory. A project that's seen heavy worktree use (typical for superpowers:using-git-worktrees workflow) can have dozens of sibling dirs.
superpowers:using-git-worktrees or has .claude/worktrees/ populated~/.claude/projects/<project-name>/*.jsonl returned fewer hits than expected, or none~/.claude/projects/ contains a <project-name> dir AND multiple <project-name>--claude-worktrees-<wt> siblingsGlob the wildcard suffix to cover canonical + all worktrees:
ls ~/.claude/projects/ | grep -iE "<project-keyword>" | wc -l # confirm fan-out
Then search across all of them at once:
find ~/.claude/projects/ -name "*.jsonl" -newermt "<earliest-date>" 2>/dev/null \
| grep -iE "<project-keyword>" \
| grep -v subagents \
| while read f; do
c=$(grep -ic -E "<your-search-keywords>" "$f" 2>/dev/null)
[ "$c" -gt 0 ] && echo "$c | $(stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$f") | $f"
done | sort -rn | head -10
Key points:
grep -iE "<project-keyword>" filters to the project family (canonical + all worktrees)grep -v subagents excludes subagent JSONLs (under <session-id>/subagents/agent-*.jsonl) — those are dispatched-agent runs, not user-facing sessionsfind -newermt narrows by date; loosen the window if neededFor a working directory at /Users/<user>/Documents/foo-project/, the canonical project dir is:
~/.claude/projects/-Users-<user>-Documents-foo-project/
Note: slashes in the path become dashes; the leading dash is part of the encoding. For a worktree at /Users/<user>/Documents/foo-project/.claude/worktrees/<wt-name>/:
~/.claude/projects/-Users-<user>-Documents-foo-project--claude-worktrees-<wt-name>/
The -- collapsing the slash-dot-slash boundary is the giveaway that you're looking at a worktree namespace, not the canonical one.
JSONL lines mix user messages, assistant messages, tool calls, and system reminders. To extract just real user prompts (skip injected skill text, tool results, system reminders):
import json
with open(fn) as f:
for line in f:
try: d = json.loads(line)
except: continue
if d.get("type") != "user": continue
c = d.get("message",{}).get("content")
if isinstance(c, list):
txt = " ".join(b.get("text","") for b in c if isinstance(b,dict) and b.get("type")=="text")
elif isinstance(c, str): txt = c
else: continue
# Filter out injected content
if "Base directory" in txt or "tool_use_id" in txt[:50] or txt.strip().startswith("<"):
continue
if not txt.strip(): continue
print(f"--- {d.get('timestamp','')[:16]} ---")
print(txt[:400])
Filters explained:
"Base directory" — skill content injected by the Skill tool"tool_use_id" — tool-result wrappers that show up as type: user messagestxt.strip().startswith("<") — system reminders and command-name wrappersThe pattern is correct when:
# Should return >1 if the project uses worktrees
ls ~/.claude/projects/ | grep -iE "<project-keyword>" | wc -l
Returns more than 1, AND your search across all matching dirs surfaces hits that grepping the canonical dir alone missed.
Today's session: user asked "locate a previous session (about 2 wks ago) where I ask you to help me summarize what we did and our learnings" in the the-causal-impact-repo project.
Initial grep of ~/.claude/projects/-Users-<user>-Documents-the-causal-impact-repo/*.jsonl found 7 files, none matching the description. Looked like the session was deleted.
Then I expanded to:
find ~/.claude/projects/ -name "*.jsonl" -newermt "2026-05-13" ! -newermt "2026-05-16" 2>/dev/null \
| grep -iE "causal-impact" \
| grep -v subagents
→ 7 matching JSONLs across 5 different project directories (1 canonical + 4 worktree-namespaced). The target session was in -Users-<user>-Documents-the-causal-impact-repo--claude-worktrees-eloquent-franklin-fe932f/00000000-0000-4000-8000-000000000000.jsonl — never would have been found by searching the canonical dir alone.
Final keyword grep across all 7 surfaced the right one in seconds (opening prompt: "can you please review the complete commit history or those 2 repos, and help me summarise what we did...").
~/.claude/projects/ had 38 directories matching causal-impact (1 canonical + 37 worktrees). Similar fanout for other heavily-worktreed projects (the project had 3+).<session-id>/subagents/agent-*.jsonl tree. These hold subagent dispatches, not user conversations — exclude them when looking for "things the user said".cwd inside a worktree path — no opt-in needed.~/.claude/projects/ is not automatically cleaned up. So historical JSONLs persist even after git worktree remove. This is great for archaeology, but means stale worktree dirs accumulate.~/.claude/projects/<exact-canonical>/*.jsonl patterns — always include the wildcard suffix to cover worktree dirs.~/.claude/projects/)superpowers:using-git-worktrees skill describes the worktree workflow that produces this fan-outclaude-code-session-jsonl-whitespace-text-block and claude-code-session-jsonl-orphan-advisor-tool-result operate on the same JSONL files; this skill is the discovery layer for finding them in the first placeThese were named in this skill's description until v1.18.0. The description is resident in context on every turn, so a cross-link there costs budget on every turn and buys nothing -- a user never types another skill's name. They belong here, where the model reads them once retrieval has already succeeded.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-control118 skills in this plugin
/agent-refusal-with-evidence-beats-literal-complianceA dispatched agent that does exactly what you asked can ship a defect you would
have stopped yourself, because it can see something at the worksite that you
could not see when you wrote the brief. Use when: (1) you are writing a brief
that prescribes a specific fix, threshold, wording or value rather than the
outcome you want; (2) an agent reports that it did not do what you asked and
you are deciding whether that is insubordination or judgement; (3) an agent
asserts "this is fine" or "not needed" with no measurement behind it; (4) you
are reviewing overnight output and want to know which decisions were checked
and which were assumed. Two halves, and both are needed: give the agent
explicit permission to satisfy the INTENT of an instruction while refusing its
letter, and REQUIRE the evidence with the refusal — what it built or measured,
what that showed, what it did instead. Evidence is the whole difference between
a refusal you can bank and one you have to re-litigate. Four agents correctly
declined an instruction in a single run; one built the suggested fix, measured
that it turned a silent safe refusal into a permanently red pipeline, and
reverted it unpushed.
/auto-merge-rearms-while-agent-live-kill-then-disarm-verify