Skip to content

[ralph-wiggum] Stop hook affects all sessions in project, not just the ralph-loop session #64

@Aistotle

Description

@Aistotle

TL;DR

If you start a ralph-loop in one Claude Code panel and then open a second session in the same project, the second session gets hijacked. The Stop hook doesn't know which session it belongs to, so it injects the ralph-loop prompt into every session — even ones doing completely unrelated work.

This makes it impossible to run ralph-loop while doing anything else in the same project, and can cause Claude to silently start working on the wrong task.


Steps to Reproduce

  1. Open VS Code with the Claude Code extension in a project with ralph-wiggum installed
  2. In Chat Panel A, start a ralph-loop:
   /ralph-wiggum:ralph-loop "Build feature X..." --completion-promise "DONE" --max-iterations 30
  1. While that's running, open a new Claude Code chat in the same project (e.g., "New Chat" or a second panel)
  2. In Chat Panel B, have a normal conversation unrelated to the ralph-loop task
  3. When Claude completes a response in Chat Panel B, the Stop hook fires and injects the ralph-loop prompt from Chat Panel A

Expected Behavior

The Stop hook should only affect the session where /ralph-loop was initiated. Other sessions/chats in the same project should operate normally.


Actual Behavior

What happens Result
Stop hook intercepts exit attempts in Chat Panel B Wrong session
Injects ralph-loop prompt from Chat Panel A Wrong task
Creates infinite loop: respond → hook → re-inject → respond Session unusable
If user doesn't notice, Claude works on wrong task Wasted effort

Impact

  • Workflow blocked — Cannot use multiple Claude Code sessions while ralph-loop is active
  • Task hijacking — Unrelated work gets derailed by wrong task instructions
  • Silent failure mode — If user isn't watching closely, Claude starts working on the wrong task
  • Resource waste — Context window fills with repeated hook injections

Suggested Fix

The Stop hook should track which session initiated the ralph-loop and only intercept exit attempts from that specific session.

Possible approaches:

  • Store a session/chat identifier when ralph-loop starts
  • Only fire the hook if current session matches stored identifier
  • Use session-local state rather than project-level state

Environment

Component Details
Interface Claude Code for VS Code extension
Plugin ralph-wiggum (via /plugin install ralph-wiggum@claude-code-plugins)
OS macOS

Note: I haven't tested whether this also affects the terminal CLI version of Claude Code, or other IDEs. It may be VS Code-specific or it may affect all Claude Code environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions