Conversation
SessionStart hook that tracks active Claude Code sessions. When 3+ sessions are active (modified in last 2 hours), outputs a reminder to include explicit context in responses — repo name, branch, what we're working on. Designed for users who juggle multiple windows/repos simultaneously. Auto-cleans session marker files older than 24 hours. Inspired by gstack's ELI16 mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review: Add session multiplexing detectionNice feature idea for multi-window workflows. A few observations: Bug: Duplicate
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47845b9d28
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "SessionStart": [ | ||
| { | ||
| "matcher": "startup|resume|clear|compact", |
There was a problem hiding this comment.
Remove ended sessions from multiplexing count
This tracking logic only runs on SessionStart and never clears a session marker when a session ends, so closed windows are still counted as "active" for up to 2 hours (or 24 hours until cleanup). In practice, if a user opens 3 sessions, closes 2, and then starts another within 2 hours, the hook still reports 3+ active sessions and injects unnecessary guidance. Adding a SessionEnd hook to delete the corresponding marker would make the count reflect truly active sessions.
Useful? React with 👍 / 👎.
- Remove dead code OS detection (both branches were identical) find -mmin works the same on macOS and Linux - Add basename guard against path traversal in SESSION_ID - Add comment explaining the 3-session threshold choice Co-Authored-By: Claude <noreply@anthropic.com>
PR Review: Add session multiplexing detectionNice idea — context grounding in multi-session workflows is a real pain point. The implementation is clean and consistent with the existing Potential Bug:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| # Threshold: 3+ sessions is where context-juggling becomes error-prone. | ||
| # Below 3, a user can reasonably track what each window is doing. | ||
| if [ "$ACTIVE_COUNT" -ge 3 ]; then | ||
| echo "Multi-session mode: $ACTIVE_COUNT active Claude Code sessions detected. The user is juggling multiple windows — always include explicit context (repo name, branch, what we're working on) when reporting status or completing work." |
There was a problem hiding this comment.
Hook outputs plain text instead of required JSON format
High Severity
The echo on line 33 outputs a plain text string, but Claude Code's SessionStart hooks expect JSON output containing a hookSpecificOutput with an additionalContext field to inject context into the conversation. Plain text stdout from a SessionStart hook is not treated as conversation context — it triggers a "hook output does not start with {" warning and may produce a "startup hook error" in the UI. The message never reaches Claude, which defeats the entire purpose of the hook. The output needs to be structured as JSON, e.g. {"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"..."}}.
There was a problem hiding this comment.
WONTFIX — incorrect. For SessionStart hooks, stdout is injected directly as context. The Claude Code docs example literally uses echo 'Reminder: ...' plain text. JSON hookSpecificOutput/additionalContext is only required for decision-returning hooks like PreToolUse. The plain echo here is the correct pattern.


Summary
Changes
plugins/core/hooks/session-multiplexing.sh— new hook script~/.claude/sessions/{SESSION_ID}on every session start/resume/clear/compactplugins/core/hooks/hooks.json— added SessionStart hook entryTest plan
~/.claude/sessions/🤖 Generated with Claude Code