Skip to content

Fix/powershell silent exit windows#55433

Open
risingsamurai wants to merge 2 commits intoanthropics:mainfrom
risingsamurai:fix/powershell-silent-exit-windows
Open

Fix/powershell silent exit windows#55433
risingsamurai wants to merge 2 commits intoanthropics:mainfrom
risingsamurai:fix/powershell-silent-exit-windows

Conversation

@risingsamurai
Copy link
Copy Markdown

Problem

Claude Code REPL silently exits on Windows inside PowerShell
during long-running agent sessions with dense Bash subprocess
chains. No error, no traceback — session just vanishes after
50+ Bash tool uses in 10-30 minute sessions.

Fixes #55424

Root Cause

  • Dense bash command chains (cd && python script.py 2>&1 | grep)
  • Handle/memory leaks after many subprocess invocations
  • No error boundary catching the silent crash
  • JSONL not flushed frequently enough before exit

Fix

Added 3 detection and prevention hooks:

  1. windows_bash_stability_hook.py — tracks bash command
    frequency, detects risky patterns, alerts before crash threshold

  2. hookify.windows-bash-stability.local.md — detects
    multi-step && chains and warns with safer alternatives

  3. hookify.windows-pipe-pattern.local.md — targets
    2>&1 | grep patterns that cause handle leaks on Windows

Key Features

  • Proactive pattern detection before crashes occur
  • Frequency monitoring (warns at 50+ bash commands)
  • Clear warnings instead of silent exits
  • Windows-only activation (os.name == 'nt')
  • Suggests PowerShell-native alternatives

Testing

  • 0 errors, 0 warnings
  • Covers all 3 observed crash patterns from issue report

Add Hookify hooks to detect and prevent problematic drag-and-drop
image operations that cause Claude Code to freeze on 'pasting text...'.

- Block reads from macOS temporary folders that contain incomplete thumbnails
- Warn users before reading image files to prevent hangs
- Provide helpful guidance for proper drag-and-drop workflow
- Reference issue anthropics#55420 for additional context

This addresses the root cause where macOS creates floating thumbnails
before fully saving files, causing Claude Code to hang when trying to
read incomplete/temporary file paths.
…hropics#55424)

Add hooks to detect and prevent bash command patterns that cause
Claude Code REPL to silently exit on Windows PowerShell hosts.

- Detect multi-step command chains (&& &&) that overwhelm PowerShell
- Warn about stderr redirect + pipe patterns causing handle leaks
- Monitor bash command frequency to prevent memory/handle leaks
- Provide clear guidance for Windows-specific workarounds
- Reference issue anthropics#55424 with detailed pattern explanations

This addresses the root cause where dense bash subprocess chains
during long-running agent sessions cause silent PowerShell host exits,
leaving users stranded at bare PS prompts with no error messages.

Files added:
- examples/hooks/windows_bash_stability_hook.py (comprehensive monitoring)
- .claude/hookify.windows-bash-stability.local.md (pattern detection)
- .claude/hookify.windows-pipe-pattern.local.md (pipe pattern warnings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] v2.1.121 Windows: Claude Code REPL silently exits inside PowerShell host during long-running agent + dense Bash subprocess chain

1 participant