Resume Claude Code sessions automatically, with per-pane isolation for Superset, iTerm, and tmux.
Add this to your hooks object:
"SessionEnd": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "jq -r '\"mkdir -p \" + .cwd + \"/.claude_sessions && echo \\\"claude --dangerously-skip-permissions --resume \" + .session_id + \"\\\" > \" + .cwd + \"/.claude_sessions/${SUPERSET_PANE_ID:-${ITERM_SESSION_ID:-${TMUX_PANE:-default}}}\"' | sh"
}
]
}
]c() {
local key="${SUPERSET_PANE_ID:-${ITERM_SESSION_ID:-${TMUX_PANE:-default}}}"
local session_file=".claude_sessions/$key"
if [ -f "$session_file" ]; then
local cmd
cmd=$(cat "$session_file")
rm -f "$session_file"
rmdir .claude_sessions 2>/dev/null
eval "$cmd"
else
claude "$@"
fi
}echo '.claude_sessions/' >> ~/.gitignore_global- Exit Claude Code -> the hook saves the session ID to
.claude_sessions/<pane-id> - Run
cfrom the same pane -> resumes right where you left off - Run
cagain (or with arguments) -> starts a fresh session (file was consumed) - Multiple panes in the same directory = no conflicts
| Terminal | Environment Variable |
|---|---|
| Superset | SUPERSET_PANE_ID |
| iTerm | ITERM_SESSION_ID |
| tmux | TMUX_PANE |
| Other | default |
- jq must be installed
- Claude Code with hooks support