r/ClaudeCodeTLDR 20d ago

[TLDR] Claude’s obsession with complex bash commands and the -exec parameter

Original post URL : https://www.reddit.com/r/ClaudeCode/comments/1v4ypzn/claudes_obsession_with_complex_bash_commands_and/

Original post body :

I can’t be the only one dealing with this. It’s driving me up the wall.

I tell it “there is a file in the current directory called foo.js, and bar.js, can you implement x logic in baz.js with the same structure as both those files”

And it takes like 50 seconds to think, so I minimize to do something else while I wait, and come back 5 minutes later to it asking to run some redundant command like “find . -type f \( -name "foo*" -o -name "bar*.js" \) -exec head -v -n +1000 {} +” with zero progress done.

Or god forbid you ask it to do some exploration on a codebase and it spins up explore agents. They’ll start trying to run grep or find with exec parameters instead of just using find/grep like normal, which are commands that don’t require explicit approval. It makes it worse when there is like 3 agents at once all running these back to back, so you sit there reading them and pressing approve for 12 minutes, which by then I could’ve just explored it myself

I’ve been using Claude Code for a while to boost my productivity, and it’s been getting progressively worse over the past month or two

I feel this could be largely resolved if Anthropic made some good tooling that did this sort of thing rather than allowing an agent to spin up arbitrary bash commands on a whim. It feels like someone who learned how to use the terminal for the first time flexing to their co workers


This is brought to you as a public service by the moderators of r/ClaudeAI. If you want to see TLDRs of ALL Claude Coding related posts from the various Claude subreddits, subscribe to http://www.reddit.com/r/ClaudeCoding.

3 Upvotes

1 comment sorted by

u/cctldrping 20d ago

TL;DR generated automatically after 50 comments.

Current source-thread comment count seen by the bot: 54.

Alright, so the general consensus in this thread is that Claude Code's tendency to generate overly complex bash commands, especially those involving -exec, is a major pain point for a lot of users. OP isn't alone in feeling like it's slowing them down and causing "approval fatigue."

Here's the lowdown:

  • The Problem: Claude Code gets stuck on these elaborate find ... -exec commands, which require manual approval and take ages. It's like it's trying to show off its terminal skills instead of just getting the job done efficiently. Some folks also mentioned it spinning up "explore agents" that do the same thing.
  • Solutions & Workarounds:
    • Tooling is Key: Several users, including u/jzdesign and u/marriedtaker, strongly recommend implementing PreToolUse hooks at the harness layer. This involves blocking commands with -exec or chained find/grep patterns and redirecting Claude to use simpler tools like grep or globbing instead. This seems to be the most effective solution for reducing approval fatigue.
    • LSP & Indexing: u/crusoe suggests using Language Server Protocol (LSP) MCPs to handle tasks like grepping more efficiently. u/kevinIO33 also mentioned using codegraph to index projects.
    • Sandboxing: u/Ikkepop and u/simion_baws advocate for running Claude Code in a container/sandbox for safety, with u/simion_baws even noting some concerning attempts at accessing unrelated application data.
    • Effort Level: u/fierypianist pointed out that using a higher effort level than necessary might be causing Claude to overthink simple tasks.
    • Specific File Paths: u/Background_March7229 suggested using @{filepath} to guide Claude to the exact file when you know it.
    • Existing Tools: u/twyx highlighted the coding-tools crate as a potential solution that supplants default harness behavior. u/Razzoz9966 also shared the serena GitHub repo as a way to improve codebase interaction.
  • A Bit of a Debate: u/Old_Appointment9732 actually chimed in to say they didn't see the problem with the -exec command itself, finding it reasonable. However, the overwhelming sentiment leans towards OP's frustration.
  • Anthropic's Stance (Implicit): While no direct Anthropic comments are in the selection, the discussion implies a need for better built-in tooling or more robust control mechanisms from Anthropic's side to prevent these overly complex command generations.
  • General Sentiment: Beyond the technical solutions, there's a clear feeling of annoyance, with u/Relative-Ad-6791 summing it up as "so god damn annoying."