Test Claude Resume SID
Overview
This skill tests whether Claude Code's --resume <sid> flag preserves the original session ID or creates a new one (fork behavior). This is critical for agent-management systems that need to track sessions by SID across multiple processes.
When to Use
- •Verifying that
cc --resume <sid>maintains session identity - •Debugging agent-management server assumptions about SID:PID mappings
- •Confirming session behavior before implementing agent orchestration
- •Testing if multiple resumed processes share the same SID
Quick Start
Run the automated test script:
bash
python ~/.claude/skills/test-claude-resume-sid/scripts/test_resume_sid.py
Options:
- •
--suffix <name>: Custom suffix for tmux session (default: random) - •
--keep: Keep tmux session alive after test for manual inspection
What the Test Does
- •Creates a detached tmux session
- •Runs
cc "test prompt"in pane 0 - •Extracts the session ID (SID) from the output
- •Splits into 3 panes (horizontal + vertical split)
- •Runs
cc --resume <sid>in panes 1 and 2 - •Extracts SIDs from all 3 panes
- •Reports whether all SIDs match
Expected Results
PASS: All 3 panes show the SAME session ID
- •
--resumepreserves the original SID - •Multiple processes can share one session identity
- •Agent-management servers can rely on
requested_sid == observed_sid
FAIL: Panes show DIFFERENT session IDs
- •
--resumecreated new SIDs (forked) - •Each process has its own session identity
- •Agent-management servers must track
resume_from_sidvsobserved_sid
Manual Test Steps
To run the test manually:
bash
# 1. Create tmux session
tmux new-session -d -s sid-test -x 180 -y 50
# 2. Run initial cc
tmux send-keys -t sid-test:0.0 'cc "Hi, my secret is abc123"' Enter
# 3. Wait ~5 seconds, then capture SID
tmux capture-pane -t sid-test:0.0 -p | grep -oE '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
# 4. Split panes
tmux split-window -h -t sid-test:0.0
tmux split-window -v -t sid-test:0.1
# 5. Resume in new panes (replace <SID> with actual SID)
tmux send-keys -t sid-test:0.1 'cc --resume <SID>' Enter
tmux send-keys -t sid-test:0.2 'cc --resume <SID>' Enter
# 6. Wait ~5 seconds, then capture all panes
tmux capture-pane -t sid-test:0.0 -p | grep -i "agent id"
tmux capture-pane -t sid-test:0.1 -p | grep -i "agent id"
tmux capture-pane -t sid-test:0.2 -p | grep -i "agent id"
# 7. Attach to inspect
tmux attach -t sid-test
Verifying via Logs
To confirm SID:PID mapping in centralized logs:
bash
# Find all PIDs for a given SID
grep "<SID>" ~/centralized-logs/claude/sse_lines.jsonl | \
python -c "
import sys, json, re
pids = set()
for line in sys.stdin:
obj = json.loads(line.strip())
meta = obj.get('metadata', '{}')
if isinstance(meta, str):
m = re.search(r'\"pid\":(\d+)', meta)
if m: pids.add(int(m.group(1)))
for p in sorted(pids): print(p)
"
If resume preserves SID, expect 3+ unique PIDs for the same SID.
Resources
scripts/
- •
test_resume_sid.py- Automated test script that creates tmux session, runs cc commands, extracts SIDs, and reports results