You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add ability to load secrets from external command or environment variables in the config file #231
I have all my dotfiles in a github repository. I want the opencode configuration to be part of my dotfiles. I am using github mcp which requires the github personal access token so I cant commit the file.
i believe opencode will load .env files - does that help? typically we try to avoid too much env loading as people always have complex wasy they want to load the env
can you ensure the env is loaded before opencode starts? if not we can figure something out
Actually, I ended up doing it differently which works perfectly for my use case. I added a bash script that uses pass to dynamically load the github token, then use the base script as local tool.
@thdxr i did not try the .env route. I had the variable loaded in my shell via .zshrc and it did not work. The script solution works fine for my usecase, so feel free to close this issue if you dont want to investigate further into environment variables.
I'm also having the same issue with .zshrc -- I have my .env sourced, with all values printable in my terminal, but they arent being loaded in opencode:
I agree this feature will be pretty helpful, because in this way I can e.g. use 1Password cli to retrieve secrets, and never store the secrets locally.
right now i am using an approach where i put all my keys inside .secrets directory and use file references {file:./.secrets/xxx.key} to inject them. this way i can commit my opencode config to my private remote repo
Beyond just secrets management, as an example, external tools may be needed to recompute authentication credentials for MCPs. Supporting something like calling $(gcloud auth print-access-token) for every connection establishment towards an MCP would be great. The bearer token expires hourly (though seemingly slightly adjustable).
Activity
thdxr commentedon Jun 20, 2025
i believe opencode will load
.envfiles - does that help? typically we try to avoid too much env loading as people always have complex wasy they want to load the envcan you ensure the env is loaded before opencode starts? if not we can figure something out
adikari commentedon Jun 20, 2025
Actually, I ended up doing it differently which works perfectly for my use case. I added a bash script that uses pass to dynamically load the github token, then use the base script as local tool.
Example for others who run into similar issue
@thdxr i did not try the .env route. I had the variable loaded in my shell via .zshrc and it did not work. The script solution works fine for my usecase, so feel free to close this issue if you dont want to investigate further into environment variables.
aspiers commentedon Jun 28, 2025
See also #318 and #342.
caleb-reyes-op commentedon Dec 15, 2025
I'm also having the same issue with .zshrc -- I have my .env sourced, with all values printable in my terminal, but they arent being loaded in opencode:
expected:
opencode debug config:
the API key is printable in my shell.
Merge branch 'shuvcode-dev' into integration
betaboon commentedon Jan 14, 2026
https://github.com/olimorris/codecompanion.nvim uses a syntax like this
{cmd:pass some-token}which is quite nice.evannotfound commentedon Jan 17, 2026
I agree this feature will be pretty helpful, because in this way I can e.g. use 1Password cli to retrieve secrets, and never store the secrets locally.
right now i am using an approach where i put all my keys inside
.secretsdirectory and use file references{file:./.secrets/xxx.key}to inject them. this way i can commit my opencode config to my private remote repoliby commentedon Jan 19, 2026
Heads-up: the packaged CLI currently does NOT auto-load project
.envfiles. It only reads existing environment variables.Dev build sets
autoloadDotenv: false, and earlier builds used--env-file="".So
{env:VAR}resolves only if the env var is already set before opencode starts. The docs line about project.envlooks outdated.nikaro commentedon Jan 20, 2026
Did not found this issue before, so i closed mine.
Here is the associated PR: #8917
@thdxr do you mind taking a look at it?
github-actions commentedon Mar 26, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.
nikaro commentedon Mar 26, 2026
For those looking to a coding agent that supports this:
.env)malikwirin commentedon Apr 9, 2026
How does crush support this? This would resolve charmbracelet/crush#2334
feat: improve owpenbot WhatsApp onboarding (anomalyco#231)
ivucica commentedon Jul 30, 2026
This should be reopened and expanded:
Beyond just secrets management, as an example, external tools may be needed to recompute authentication credentials for MCPs. Supporting something like calling
$(gcloud auth print-access-token)for every connection establishment towards an MCP would be great. The bearer token expires hourly (though seemingly slightly adjustable).feat(es-app): size distribution and neutral notes on coalesced tool r…
fix(es-app): wrap coalesced size distribution at narrow widths (anoma…
fix(es-app): keep size distribution bins whole when wrapping (anomaly…