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
How to make OpenCode load environment variables from a file when executing commands in skills #9334
I’m trying to execute some shell commands inside an OpenCode skill, but these commands depend on several environment variables (for example API keys, custom paths, or runtime configs).
At the moment, it seems that OpenCode does not automatically load environment variables from a specified file (such as .env) when running commands defined in a skill.
What I want to achieve
I’d like OpenCode to be able to load environment variables from a designated env file before executing skill commands, so that:
Skills can run in a reproducible environment
Secrets and configs don’t need to be hard-coded in skill definitions
The behavior is closer to tools like dotenv, direnv, or envsubst
Expected behavior (examples)
Some possible approaches that would work:
Allow specifying an env file in the skill configuration, e.g.
envFile: .env
Or automatically load .env from the project root when executing skills
Or provide a hook / setting to inject environment variables before command execution
Question
What is the recommended way to make OpenCode load environment variables automatically when executing commands inside a skill?
If this is not currently supported, is there a plan or recommended workaround?
These issues discuss related requests for environment variable support in OpenCode, including passing environment variables to skills/agents and loading from .env files. Feel free to ignore if your specific use case differs.
Activity
github-actions commentedon Jan 19, 2026
This issue might be a duplicate of existing issues. Please check:
These issues discuss related requests for environment variable support in OpenCode, including passing environment variables to skills/agents and loading from .env files. Feel free to ignore if your specific use case differs.
github-actions commentedon Mar 27, 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.