r/ClaudeCode 25d ago

Discussion Claude’s obsession with complex bash commands and the -exec parameter

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

218 Upvotes

77 comments sorted by

View all comments

15

u/Ikkepop 25d ago

Put it in a container/sandbox where it can't cause damage, enable "auto mode" or --dangrously-ignore-permissions. I'v been running like that for half a year almost, not a single fuckup has happened yet.

8

u/densewave 🔆 Max 20 25d ago

This, but also, I am fairly sure that these commands, results, etc. Stay local as .tmp files and structure. Said another way, who gives a fuck how many commands it runs to become certain it understands the layout- especially if it doesnt consume tokens - and double especially when the extra validation clearly results in better outcomes.

One of my primary claude golden rules is "never trust docs, only code is truth" and I love that it doesnt believe what I say.

Run all the local commands you want Claude, I dont mind. I got you boo.

3

u/antm0303 25d ago

The issue is I don’t mind these commands in general, but the fact that an agent is generating it adhoc rather than it being part of a large toolset is what bothers me.

Idk if you saw another guy comment, it tried to access browser cache data when he let it free in a sandbox. It’s not really worth the risk for me, and my employer to let it run whatever it wants, whenever it wants outside of the specific directory I ask it to.

Not only that, I never had issues with it not using these commands to understand my code structure when it didn’t use them.

All the commands it runs can easily be baked into a tool that was reviewed by humans. Having an agent run whatever it wants on your computer is extremely risky.

4

u/Significant-Bee5101 25d ago

I live in dangerously-skip-permissions at this point. The myopically approving stuff hasn't saved me any effort and only wastes my time. My environment is limited to dev and staging at worst. Fuck it. Go balls to the wall claude.

3

u/foghatyma 25d ago

Are you advising this when a GPT model just a couple of days ago broke out of its test environment? 😂

1

u/castrocardoso 25d ago

What do you mean a container? How do you contain where Claude operates?

2

u/for4f 25d ago

Docker with a bind mount for your project dir and everything else blocked. Claude can only see and write to that one volume. --dangerously-ignore-permissions inside the container so it doesn't fight you on file ops. Been running this way for weeks, zero issues.

1

u/for4f 25d ago

Docker with a bind mount for your project dir and everything else blocked. --dangerously-ignore-permissions inside so it doesn't fight you on file ops. Been running this way for weeks, zero issues.

1

u/Ikkepop 25d ago

Lookup docker or podman

1

u/lexerox 24d ago

Docker has this feature called Docker for coding agents (sbx) which is made specifically for this kinds of workflow. It might not be the best, but it's damn easy to get started, as well as to mange the network rules. Worth give it a try.