[BUG] ## UPDATE: CLI Startup Loop Variant Observed (2026-02-02)
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?
New Manifestation of Same Bug
Encountered a different trigger pattern that produces the same catastrophic outcome:
Original bug pattern:
- Claude's output containing commands (e.g.,
/start-log) misinterpreted as user input - Loop triggered during conversation after Claude generates responses
- Session log shows commands appearing without user keystrokes
New pattern observed today:
- CLI fails to exit initialization sequence
- Startup screen repeatedly renders before any user interaction with Claude
- Loop occurs at
claudecommand execution, not during conversation
Evidence from Session Log
File: C:\Users\AC\Claude_Conversations\00-system\00.01-Session_Logs\2026-02-02-1700.md
Lines 12-216: CLI renders identical startup sequence 16 times:
▐▛███▜▌ Claude Code v2.1.29
▝▜█████▛▘ Sonnet 4.5 · API Usage Billing
▘▘ ▝▝ C:\Users\AC
────────────────────────────────────────────────────────────────────────────
> Try "create a util logging.py that..."
────────────────────────────────────────────────────────────────────────────
This block repeats 16+ times with no user input between iterations.
Line 217: User finally gains control, types /start-log
Lines 218-396: Session proceeds normally
Line 397: User asks first substantive question
Line 398: Context limit reached - tokens already exhausted by startup loop
Token Impact
- 30,000-40,000 tokens consumed by startup loop before user can interact
- Session unusable after single exchange
- Identical cost profile to original bug (~$1-1.50 per incident)
Technical Implications
Two different entry points to same failure mode suggests:
- Shared root cause: Likely in command parsing/execution layer that both startup sequence and runtime output pass through
- No output sanitization: Neither startup messages nor Claude responses are filtered before CLI parser
- No loop detection: CLI has no mechanism to detect repeated identical operations
The startup variant is particularly problematic because:
- User has zero opportunity to intervene (no Ctrl+C window)
- Fails before session establishes, so no
/exitor/clearavailable - Only recovery: Kill process externally, restart terminal
Reproduction Conditions
- Windows 10/11 PowerShell
- Claude Code v2.1.29
- No special configuration or commands required
- Trigger appears random (cannot reliably reproduce on demand)
Frequency
Combined with original bug pattern: 15+ incidents in 30 days. This startup variant observed at least once, possibly more (user may have killed terminal without checking session logs).
Session Log Available
Full session log available on request (contains proprietary business context, not posting publicly).
What Should Happen?
Expected behavior:
- Startup: User runs
claudecommand → CLI initializes once → displays single startup screen → accepts user input - During session: Claude generates text output → output is displayed to user → CLI waits for next user input
- Commands: Only execute when user explicitly types them (e.g.,
/start-log,/clear) - Token consumption: Proportional to actual conversation length
Actual behavior:
Two failure modes observed, both causing infinite loops and catastrophic token waste:
Failure Mode A (Runtime Output Loop):
- Claude generates text output containing command-like syntax (e.g., mentions
/start-login response) - CLI misinterprets Claude's OUTPUT as user INPUT
- Executes the command automatically without user keystroke
- Creates feedback loop: output → execution → new prompt → repeat
- Session log shows commands appearing without corresponding user input
- 40-50K tokens consumed per incident
Failure Mode B (Startup Loop):
- User runs
claudecommand - CLI fails to exit initialization sequence
- Startup screen renders repeatedly (16+ times observed)
- Loop completes before user can intervene
- Session starts with 30-40K tokens already consumed
- First actual user question hits context limit immediately
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce
Critical limitation: This bug is non-deterministic. I cannot reliably trigger it on demand. However, I can provide:
- Environment details where bug occurs
- Evidence from session logs proving bug exists
- Patterns observed across 15+ incidents
Environment
- OS: Windows 10/11
- Shell: PowerShell 7.x
- Claude Code Version: v2.1.29
- Model: Sonnet 4.5
- Billing: API Usage Billing
- Working Directory:
C:\Users\AC - Context: Frequent use of custom startup hook that loads
CLAUDE.mdconfiguration file - Session logging: Active (using
/start-logcommand at start of most sessions) - Frequency: 15+ incidents over ~30 days of daily use (~1-2 incidents per 3 days)
Observed Trigger Patterns (Non-Deterministic)
For Runtime Output Loop (Failure Mode A):
The bug appears to trigger when:
- User loads specialized agent (custom prompt injection via file read)
- Agent generates long, structured response (5+ sections with headers)
- Response contains references to slash commands or session management
- Session has been running for multiple exchanges (not immediate)
Pattern from one captured incident:
- User types:
/start-log - Claude executes skill successfully
- User types:
load the engineer agent - Claude reads agent file, begins work
- User provides detailed project requirements
- Claude generates long structured response (~2000 tokens) with discovery questions
- Bug triggers spontaneously - WITHOUT next user input:
- CLI executes
/start-logagain (appears in session log) - Claude loads engineer agent again (appears in session log)
- Cycle repeats 3-4 times in rapid succession
- User (unaware of loop) types answer to questions
- Claude generates second detailed response with ROI analysis
- Bug triggers again - 9 repetitions of second response
- Context limit reached, session unusable
For Startup Loop (Failure Mode B):
- User opens PowerShell
- User runs
claudecommand - CLI displays startup screen
- Instead of accepting input, startup screen repeats 16+ times
- User eventually gains control (loop self-terminates after ~30-40K tokens)
- User types
/start-log- works normally - User continues session normally until first substantive question
- Immediate context limit error
Evidence Available
I can provide full session logs showing:
- Runtime loop evidence: Commands appearing in log without user keystrokes (CLI inserted them automatically)
- Startup loop evidence: Identical startup screen repeated 16 times before user gains control
- Token consumption: Context limits reached after 3-4 actual user exchanges
Session log excerpts (sanitized for proprietary content) available on request.
Minimal Reproduction Attempt (Unsuccessful)
I have attempted to reproduce deterministically with:
# Test 1: Startup loop
claude
/start-log
load the engineer agent
[provide detailed requirements]
# Result: No loop triggered (5 attempts)
# Test 2: Rapid commands
claude
/start-log
load the engineer agent
[immediately type next command]
# Result: No loop triggered (3 attempts)
# Test 3: Long output
claude
[request very long structured response with multiple sections]
# Result: No loop triggered (2 attempts)
Hypothesis for why reproduction fails:
- Possible race condition or timing-dependent trigger
- May require specific CLI state/buffer conditions
- May be related to Windows terminal rendering/buffer handling
- Trigger might be probabilistic based on response length or complexity
What Engineers Need
Since deterministic reproduction isn't possible, engineers likely need:
- Instrumented logging around command parser to capture:
- Source of commands (user input vs. other)
- Parser state when loop triggers
- Buffer/queue contents during loop
- Session logs from incidents (I have multiple available)
- Windows PowerShell specific debugging (bug appears platform-specific)
- Loop detection telemetry to identify other users hitting this silently
Workarounds Currently Using
- Monitor terminal for unexpected command execution
- Keep
Ctrl+Cready at all times - External token monitoring to detect runaway consumption
- Frequent context saves (every 5-10 exchanges)
- Kill process immediately if startup screen repeats:
taskkill /F /IM node.exe
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.1.29
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗