claude-code - ✅(Solved) Fix Bug: Whitespace normalization mismatch in Ralph Wiggum stop hook causes completion promise comparison to fail [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52405Fetched 2026-04-24 06:08:03
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1

In plugins/ralph-wiggum/hooks/stop-hook.sh (lines 119, 123), the completion promise text extracted from output is whitespace-normalized via s/\s+/ /g, but the stored COMPLETION_PROMISE value is not normalized. This causes the comparison to fail when the user's promise contains multiple consecutive spaces.

Root Cause

In plugins/ralph-wiggum/hooks/stop-hook.sh (lines 119, 123), the completion promise text extracted from output is whitespace-normalized via s/\s+/ /g, but the stored COMPLETION_PROMISE value is not normalized. This causes the comparison to fail when the user's promise contains multiple consecutive spaces.

Fix Action

Fixed

PR fix notes

PR #52415: fix: normalize whitespace in completion promise before comparison

Description (problem / solution / changelog)

Summary

  • Normalize whitespace in the stored COMPLETION_PROMISE before comparing it to the extracted promise text
  • The extracted text was already normalized via perl (s/\s+/ /g), but the stored value was not, causing comparison failures when the promise contained multiple consecutive spaces

Test plan

  • Set a completion promise with multiple spaces: --completion-promise "TASK DONE"
  • Verify the promise is detected when output contains <promise>TASK DONE</promise> (single space)
  • Verify normal single-space promises still work

Fixes #52405

🤖 Generated with Claude Code

Changed files

  • plugins/ralph-wiggum/hooks/stop-hook.sh (modified, +4/-1)
RAW_BUFFERClick to expand / collapse

Description

In plugins/ralph-wiggum/hooks/stop-hook.sh (lines 119, 123), the completion promise text extracted from output is whitespace-normalized via s/\s+/ /g, but the stored COMPLETION_PROMISE value is not normalized. This causes the comparison to fail when the user's promise contains multiple consecutive spaces.

Steps to Reproduce

  1. Set a completion promise with multiple spaces: --completion-promise 'TASK DONE'
  2. The promise is stored as-is: "TASK DONE" (4 spaces)
  3. When extracted from output, whitespace is normalized to single spaces: "TASK DONE"
  4. The comparison fails: "TASK DONE" != "TASK DONE"

Expected Behavior

The completion promise should be detected regardless of whitespace differences between the stored promise and the output text.

Suggested Fix

Normalize whitespace on the stored COMPLETION_PROMISE as well before comparison, or normalize both sides at comparison time.

extent analysis

TL;DR

Normalize the stored COMPLETION_PROMISE value to ensure consistent whitespace for comparison.

Guidance

  • Identify where the COMPLETION_PROMISE is stored and modify the storage logic to normalize whitespace using a similar approach as in the stop-hook.sh (e.g., s/\s+/ /g).
  • Alternatively, normalize both the stored COMPLETION_PROMISE and the extracted promise text at comparison time to ensure consistency.
  • Verify the fix by setting a completion promise with multiple spaces and checking if the comparison succeeds.
  • Consider adding tests to cover different whitespace scenarios to prevent regressions.

Example

# Example of normalizing whitespace in the stored COMPLETION_PROMISE
COMPLETION_PROMISE=$(echo "$COMPLETION_PROMISE" | sed 's/\s\+/ /g')

Notes

This fix assumes that the normalization approach used in stop-hook.sh is suitable for the stored COMPLETION_PROMISE as well. If different normalization rules apply, adjustments may be necessary.

Recommendation

Apply workaround: Normalize the stored COMPLETION_PROMISE value or both sides at comparison time to ensure consistent whitespace, as this directly addresses the identified issue without requiring version upgrades or significant code changes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING