[BUG]
Resolved 💬 3 comments Opened Oct 18, 2025 by wbmccarty Closed Oct 22, 2025
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code CLI enters an infinite loop during normal chat interactions, consuming excessive CPU (70-80%) and becoming completely unresponsive to user input. The terminal displays rapidly flashing content that cannot be read or interrupted.
- CLI becomes completely unresponsive
- Input flashes too rapidly to read
- Unable to enter any commands or text
- CPU usage spikes to 70-80% per stuck process
- Only solution is to kill the process with
kill -9 <PID>
What Should Happen?
Chat sessions should remain responsive and handle user input normally.
Error Messages/Logs
Debug logs reveal the `UserPromptSubmit` hook is executing in an infinite loop:
- **Loop iterations**: 4,046 executions in rapid succession (~100ms intervals)
- **Lock file errors**: 457 instances of "Lock file is already being held"
- **File write spam**: Repeatedly writing to `/Users/wbmccarty/.claude.json`
[DEBUG] Executing hooks for UserPromptSubmit
[DEBUG] Getting matching hook commands for UserPromptSubmit with query: undefined
[DEBUG] Found 0 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "no match query" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute
[DEBUG] FileHistory: Making snapshot for message <uuid>
[DEBUG] FileHistory: Added snapshot for <uuid>, tracking 0 files
[ERROR] Failed to save config with lock: Error: Lock file is already being held
[DEBUG] Writing to temp file: /Users/wbmccarty/.claude.json.tmp.<PID>.<timestamp>
[DEBUG] Preserving file permissions: 100600
[DEBUG] Temp file written successfully, size: 83641 bytes
[DEBUG] Applied original permissions to temp file
[DEBUG] Renaming /Users/wbmccarty/.claude.json.tmp.<PID>.<timestamp> to /Users/wbmccarty/.claude.json
[DEBUG] File /Users/wbmccarty/.claude.json written atomically
[DEBUG] Hooks: getAsyncHookResponseAttachments called
[DEBUG] Hooks: checkForNewResponses called
[DEBUG] Hooks: Found 0 total hooks in registry
[DEBUG] Hooks: checkForNewResponses returning 0 responses
[DEBUG] Executing hooks for UserPromptSubmit
... [repeats indefinitely]
Full debug logs available if needed (4.4 MB log file for one stuck session).
Steps to Reproduce
- Open multiple Claude Code CLI sessions
- Engage in normal chat conversation (no special commands or tool usage)
- After some time, one or more sessions will spontaneously enter an infinite loop
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.0.14
Claude Code Version
2.0.14 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Installation: npm-global
Root Cause Hypothesis
The UserPromptSubmit hook appears to be re-triggering itself, possibly due to:
- Race condition in file locking mechanism
- Hook system monitoring its own file changes
- Event propagation bug causing hooks to recursively fire
Frequency
This has occurred multiple times over several days, affecting different chat sessions unpredictably.
Workaround
Kill the stuck process(es):
ps aux | grep claude # Find stuck process PIDs with high CPU
kill -9 <PID>
Additional Notes
- No custom hooks are configured (debug logs show "Found 0 hook matchers in settings")
- Happens during normal chat, not related to any specific command or tool use
- Can affect multiple Claude Code sessions simultaneously
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗