Suggestion: set a CLAUDECODE environment variable inside of the claude code bash environment

Resolved 💬 3 comments Opened Mar 16, 2025 by asmeurer Closed Mar 18, 2025

It would be useful to have a way for commands to be able to detect if they are being run inside of the claude code environment. In particular, I want to add some things to my bash profile that run differently inside of claude than in my main terminal, but I could see other uses as well.

Right now, there doesn't seem to be an obvious way to do this. The best thing I can see is to check if TTY is set to not\na\ntty, which is a string that I don't think anything else uses.

But it would be simpler if claude just set a special environment variable like CLAUDECODE=1 inside of the bash environment it runs. From what I can call looking at !env in claude, nothing like this currently exists.

View original on GitHub ↗

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