Better credentials loading
Status Fixed / completed
Maintainer reply None cached
Activity 9 comments · opened Feb 26, 2025 · closed Mar 7, 2025
I do a lot of development in docker containers, and Claude Code works great in them. The one catch is that every time I rebuild a container, I need to re-auth Claude Code, which is also quickly creating new API keys.
It would be awesome to be able to load an API key from a file or environmental variable to avoid this.
9 Comments
I have a complementary use case, the need to use more than one Claude API account on my host computer. It would be great if I could set the account / API key to use with a file in each project directory, which would override the global account setting.
Can you provide API key manually somehow, with environment variable for example?
+1
Hi, thanks for the suggestion! You can persist API keys by persisting
~/.claude.jsonconfig file (you can point to a different location for the config file by settingCLAUDE_CONFIG_DIRenv var)@levpopov would be great though if there was an option to switch between keys (e.g., with the command /switch-account). This would be useful for people using both personal and work-related accounts.
@radoslawkoziol would something like https://github.com/anthropics/claude-code/issues/261#issuecomment-2701757283 work for you?
Yeah, I think it's good enough for now
@levpopov I've tried your solution, but I think there's some problem, or I am doing something wrong: https://github.com/anthropics/claude-code/issues/519
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.