claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Claude Code repeatedly executes the same bash command dozens or hundreds of times

Open Wisyle opened this issue 2 months ago • 5 comments

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 repeatedly executes the same bash command dozens or hundreds of times, causing command spam in the terminal. This happens across all projects and all Claude models, regardless of project configuration.

What Should Happen?

Each command should execute once. If a command succeeds, it should not be retried. If it fails, there should be a limited number of retries with clear error messages.

Error Messages/Logs

The same command is executed repeatedly (30-50+ times) in rapid succession, creating output
  like this:

    Bash(git add settings.py && git commit -m "Fix CORS for booster PATCH requests
    Bash(git add settings.py && git commit -m "Fix CORS for booster PATCH requests
    Bash(git add settings.py && git commit -m "Fix CORS for booster PATCH requests
  ● Bash(git add settings.py && git commit -m "Fix CORS for booster PATCH requests
  ● Bash(git add settings.py && git commit -m "Fix CORS for booster PATCH requests
  ● Bash(git add settings.py && git commit -m "Fix CORS for booster PATCH requests
  [... repeats 40+ more times ...]

Steps to Reproduce

Unknown - it happens intermittently during normal Claude Code usage, particularly when Claude is executing git commands or other bash operations.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Last version

Claude Code Version

Claude Code v2.0.27

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

Environment

  • OS: Linux (WSL2 on Windows)
  • Claude Code Version: Claude Code v2.0.27
  • Affected Models: All Claude models (Sonnet, Opus, etc.)
  • Frequency: Happens regularly across different projects

What I've Checked

  • ✅ No hooks configured: Checked ~/.claude/hooks/ and project .claude/hooks/ - neither directory exists
  • ✅ No automated commands in CLAUDE.md: Checked both global ~/.claude/CLAUDE.md and project-specific CLAUDE.md files - they only contain documentation and guidelines, no automated command execution
  • ✅ No settings.json hooks: Checked ~/.config/claude-code/settings.json - no hooks configured
  • ✅ Happens across all projects: Not specific to one codebase or configuration

Impact

  • Severely disrupts workflow
  • Makes terminal output unreadable
  • May cause unintended side effects (e.g., attempting to commit the same changes multiple times)
  • Forces me to interrupt Claude Code or restart the session

Steps to Reproduce

Unknown - it happens intermittently during normal Claude Code usage, particularly when Claude is executing git commands or other bash operations.

Additional Context

The repeated commands appear in the terminal UI as tool calls, suggesting this is happening at the tool execution layer rather than at the bash/git level. The commands themselves may be succeeding on the first try, but Claude Code continues to execute them anyway.

Wisyle avatar Oct 25 '25 18:10 Wisyle

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/10205
  2. https://github.com/anthropics/claude-code/issues/7030
  3. https://github.com/anthropics/claude-code/issues/6730

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Oct 25 '25 18:10 github-actions[bot]

It's not a duplicate other issues mentioned are unrelated

Wisyle avatar Oct 25 '25 18:10 Wisyle

Seeing this as well, macOS 2.0.27

sit avatar Oct 27 '25 06:10 sit

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 08 '25 10:12 github-actions[bot]

Image Image

Yes, now Claude Code repeats the command in the terminal many times or repeatedly inserts a space, so that the text immediately goes up out of sight.

YustasDev avatar Dec 22 '25 15:12 YustasDev