← Back to context

Comment by js2

1 day ago

> export IS_SANDBOX=1 && claude --dangerously-skip-permissions

FYI, this can be shortened to:

  IS_SANDBOX=1 claude --dangerously-skip-permissions

You don't need the export in this case, nor does it need to be two separate commands joined by &&. (It's semantically different in that the variable is set only for the single `claude` invocation, not any commands which follow. That's often what you want though.)

> I asked Claude to rename all the files and I could go do something else while it churned away, reading the files and figuring out the correct names.

It's got infinite patience for performing tedious tasks manually and will gladly eat up all your tokens. When I see it doing something like this manually, I stop it and tell it to write a program to do the thing I want. e.g. I needed to change the shape of about 100 JSON files the other day and it wanted to go through them one-by-one. I stopped it after the third file, told it to write a script to import the old shape and write out the new shape, and 30 seconds later it was done. I also had it write me a script to... rename my stupidly named bank statements. :-)

This. I had a 10000 line css file, and told it to do a find and replace on some colours. It was hilariously bad at this and started chewing tokens. Asking it to write a script to swap it out and then execute that script for me and it was done instantly. Knowing the right questions to ask an AI is everything.

  • I actually have noticed it do this by itself a couple of times, it's where I got the idea to do the same

> It's got infinite patience for performing tedious tasks manually and will gladly eat up all your tokens. When I see it doing something like this manually, I stop it and tell it to write a program to do the thing I want.

This is so funny. Thank you for sharing :)

Does it even work with the &&? Iirc, I've never had luck putting env vars before the && and always had to do it the way you describe

  • It works because they exported it. VAR=foo bar only sets it for the env passed to that exec or subshell, export VAR=foo && bar adds it to the current env then executes bar.

    export VAR=foo && bar is dangerous because it stays set.

    • Ah, that's what I had done wrong, thank you! And agree I wouldn't want to just one-off export it and have it be set, better to not export it for one-liner one-offs for sure

make it work more generally via `env`

    env IS_SANDBOX=1 claude --dangerously-skip-permissions

not all shells support FOO=bar prefixes, in particular fish does not, but the above works everywhere

  • This might have been the case for fish shell; but not anymore, it works in current version. I myself have used the popular syntax without specifying `env` in my aliases.