Claude gets stuck in infinite loop repeating the same failing command

Resolved 💬 5 comments Opened Jan 21, 2026 by jhinrichsen Closed Feb 28, 2026

Task/Prompt

I asked Claude to run a command on a remote server via SSH:

"we could start a runner on [remote-server] no?"

(Note: [remote-server] is a placeholder for the actual hostname)

Expected Behavior

When a command fails, Claude should:

  1. Recognize the error
  2. Analyze the cause
  3. Modify the command to fix the issue (or ask the user for guidance)

Actual Behavior

Claude ran the exact same failing command 7+ times in a row without modifying it, until I manually interrupted:

● Bash(ssh [remote-server] "make run-runner" 2>&1)                                                                           
  ⎿  Error: Exit code 2                                                                                         
     make: *** No rule to make target 'run-runner'.  Stop.                                                      
                                                                                                                
● Bash(ssh [remote-server] "make run-runner" 2>&1)                                                                           
  ⎿  Error: Exit code 2                                                                                         
     make: *** No rule to make target 'run-runner'.  Stop.
     
● Bash(ssh [remote-server] "make run-runner" 2>&1)                                                                           
  ⎿  Error: Exit code 2                                                                                         
     make: *** No rule to make target 'run-runner'.  Stop.

[... repeated 4+ more times with identical command and output until manually stopped ...]

Core Issue

This is not specific to make - the bug is that Claude fails to recognize that a command is returning an error and repeats it indefinitely without any modification. It appears Claude gets stuck in a loop where it keeps issuing the same tool call regardless of the error output.

Environment

  • Claude Code CLI: 2.1.12
  • Model: claude-opus-4-5-20251101
  • Platform: Linux

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗