Answer: Use {env:VARIABLE_NAME} to substitute environment variables and {file:path/to/file} to substitute the contents of a file, placing references inside JSON strings in your config files. Status: Confirmed Entry: tool/opencode/settings/config-variables Revision: 2 Digest: sha256:8cd580eb45c8dd85 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:56:38Z Last changed: 2026-11-17T14:11:50Z (home directory path prefix: — → ~/) Last verified: 2026-11-20T13:45:40Z Next check: 2026-11-21T13:45:40Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of environment variable syntax | {env:VARIABLE_NAME} | [1] | 2026-11-20 file reference syntax | {file:path/to/file} | [1] | 2026-11-20 unset env var behavior | empty string | [1] | 2026-11-20 missing file behavior | empty string | [1] | 2026-11-20 file path options | Relative to the config file directory | [1] | 2026-11-20 home directory path prefix | ~/ | [1] | 2026-11-20 Sources: [1] opencode. "Config | OpenCode". https://opencode.ai/docs/config/ Role: primary. Accessed: 2026-11-20T13:45:40Z Quote: "Use {env:VARIABLE_NAME} to substitute environment variables" (Supports: environment variable syntax) Quote: "Use {file:path/to/file} to substitute the contents of a file" (Supports: file reference syntax) Quote: "If the environment variable is not set, it will be replaced with an empty string." (Supports: unset env var behavior) Quote: "If the file does not exist, it will be replaced with an empty string." (Supports: missing file behavior) Quote: "Relative to the config file directory" (Supports: file path options) Quote: "starting with ~/ for your home directory" (Supports: home directory path prefix) Snapshot SHA-256: d03b055dad38e89a68db5764e6da7ba61ffbf573bfd2443c0350640f8718a8f5 (captured 2026-11-17T14:11:49Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-17T14:11:50Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:45:40Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:45:40Z Last attempt: 2026-11-20T13:45:40Z Notes and limitations: Extracted automatically from a single official source (section "Variables"). Related: https://latestn.com/tool/opencode/settings/configure-claude-code-console How do I configure Claude Code to use OpenCode Console? https://latestn.com/tool/opencode/settings/configure-cli-plugins How do I configure plugins for the opencode CLI in cli.json? https://latestn.com/tool/opencode/settings/configure-instructions How do I configure custom instruction files in opencode? https://latestn.com/tool/opencode/settings/command-file-locations Where do global and project opencode commands live? https://latestn.com/tool/opencode/settings/compaction-buffer-setting How do I configure the compaction buffer setting in opencode? https://latestn.com/tool/opencode/settings/config-file-locations Where does opencode look for its config file and in what locations? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-17T14:11:50Z | changed | home directory path prefix: — → ~/ | [1] 2026-11-17T14:11:50Z | changed | file path options: — → Relative to the config file directory | [1] 2026-11-17T14:11:50Z | changed | missing file behavior: — → empty string | [1] 2026-11-17T14:11:50Z | changed | unset env var behavior: — → empty string | [1] 2026-11-17T14:11:50Z | changed | file reference syntax: — → {file:path/to/file} | [1] 2026-11-17T14:11:50Z | changed | environment variable syntax: — → {env:VARIABLE_NAME} | [1] 2026-11-17T14:11:50Z | changed | Home directory path prefix: ~/ → — | [1] 2026-11-17T14:11:50Z | changed | File path options: Relative to the config file directory → — | [1] 2026-11-17T14:11:50Z | changed | Missing file behavior: empty string → — | [1] 2026-11-17T14:11:50Z | changed | Unset environment variable behavior: empty string → — | [1] 2026-11-17T14:11:50Z | changed | File reference syntax: {file:path/to/file} → — | [1] 2026-11-17T14:11:50Z | changed | Environment variable syntax: {env:VARIABLE_NAME} → — | [1] 2026-11-13T03:56:38Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/opencode/settings/config-variables/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/opencode/settings/config-variables POST: https://latestn.com/dispute/tool/opencode/settings/config-variables with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/opencode/settings/config-variables?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I set environment variables or reference files in opencode config? Revision 2, last verified 2026-11-20T13:45:40Z. https://latestn.com/tool/opencode/settings/config-variables (accessed 2026-11-21T09:50:36Z). @misc{LatestN_tool_opencode_settings_config_variables_r2, title = {How do I set environment variables or reference files in opencode config?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/opencode/settings/config-variables}}, note = {Revision 2; digest sha256:8cd580eb45c8dd85; last verified 2026-11-20T13:45:40Z; accessed 2026-11-21T09:50:36Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/opencode/settings/config-variables