[FEATURE]: allow shell commands in the frontmatter #3310

Open
opened 2026-02-16 17:39:37 -05:00 by yindo · 4 comments
Owner

Originally created by @rwese on GitHub (Dec 4, 2025).

Originally assigned to: @rekram1-node on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Why - to be able to customize commands, agents configuration to set different models by cost or using local models for testing.

shellcmd.md

---
description: !`echo "${PWD}"`
model: !`echo "${OPENCODE_MODEL_PREMIUM:-anthropic/claude-haiku-4-5}"`
---  
Command prompt...

can be used like this:

OPENCODE_MODEL_CHEAP=anthropic/claude-haiku-4-5
OPENCODE_MODEL_DEFAULT=anthropic/claude-sonnet-4-5
OPENCODE_MODEL_PREMIUM=anthropic/claude-opus-4-5
bun run dev

I implemented this here:

https://github.com/rwese/opencode/commit/2c9bf3710567903932bc095d81d136fbb31c6b8f

Originally created by @rwese on GitHub (Dec 4, 2025). Originally assigned to: @rekram1-node on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request Why - to be able to customize commands, agents configuration to set different models by cost or using local models for testing. `shellcmd.md` ```markdown --- description: !`echo "${PWD}"` model: !`echo "${OPENCODE_MODEL_PREMIUM:-anthropic/claude-haiku-4-5}"` --- Command prompt... ``` can be used like this: ```bash OPENCODE_MODEL_CHEAP=anthropic/claude-haiku-4-5 OPENCODE_MODEL_DEFAULT=anthropic/claude-sonnet-4-5 OPENCODE_MODEL_PREMIUM=anthropic/claude-opus-4-5 bun run dev ``` I implemented this here: https://github.com/rwese/opencode/commit/2c9bf3710567903932bc095d81d136fbb31c6b8f
yindo added the discussion label 2026-02-16 17:39:37 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 4, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #5054: [{env:MY_VAR} support in agent yaml] - Requests environment variable substitution support in agent YAML files
  • #718: [Custom environment variables when running commands] - Requests ability to set custom environment variables for command execution
  • #3439: [custom model aliases] - Similar concept of dynamic model selection without editing files, proposes using aliases
  • #3950: [Configurable command timeout in config.json] - Related feature of environment-based configuration through config files
  • #2432: [Define opencode cache folder as an Environment variable] - Example of using environment variables for configuration

The core feature request appears to be dynamic configuration through shell command evaluation in frontmatter, which would enable:

  • Setting different models based on environment variables
  • Cost-based model selection
  • Local vs. remote model switching for testing

Feel free to ignore if your specific case differs from these existing feature requests.

@github-actions[bot] commented on GitHub (Dec 4, 2025): This issue might be a duplicate of existing issues. Please check: - #5054: [{env:MY_VAR} support in agent yaml] - Requests environment variable substitution support in agent YAML files - #718: [Custom environment variables when running commands] - Requests ability to set custom environment variables for command execution - #3439: [custom model aliases] - Similar concept of dynamic model selection without editing files, proposes using aliases - #3950: [Configurable command timeout in config.json] - Related feature of environment-based configuration through config files - #2432: [Define opencode cache folder as an Environment variable] - Example of using environment variables for configuration The core feature request appears to be **dynamic configuration through shell command evaluation in frontmatter**, which would enable: - Setting different models based on environment variables - Cost-based model selection - Local vs. remote model switching for testing Feel free to ignore if your specific case differs from these existing feature requests.
Author
Owner

@rwese commented on GitHub (Dec 4, 2025):

I could adapt it to be as #5054 my thought was to stick with the way the yaml files are currently using shell-commands.

#3439 would be too abstract for my liking

@rwese commented on GitHub (Dec 4, 2025): I could adapt it to be as #5054 my thought was to stick with the way the yaml files are currently using shell-commands. #3439 would be too abstract for my liking
Author
Owner

@ariane-emory commented on GitHub (Dec 4, 2025):

A potentially more efficient alternative might be to employ the same {env:SOME_VAR} / {file:some_file} syntax that is already supported in the opencode.json file.

Accessing an environment variable is such a trivial task, very many programs (including opencode itself in the JSON context used for the config) can just read environment variables directly without needing to start up a whole new shell in order to do it.

The code that opencode uses to do this in the configuration file can be found in packages/opencode/src/config/config.ts somewhere near line ~725 or so.

@ariane-emory commented on GitHub (Dec 4, 2025): A potentially more efficient alternative might be to employ the same `{env:SOME_VAR}` / `{file:some_file}` syntax that is already supported in the `opencode.json` file. Accessing an environment variable is such a trivial task, very many programs (including opencode itself in the JSON context used for the config) can just read environment variables directly without needing to start up a _whole new shell_ in order to do it. The code that opencode uses to do this in the configuration file can be found in `packages/opencode/src/config/config.ts` somewhere near line ~725 or so.
Author
Owner

@ariane-emory commented on GitHub (Dec 4, 2025):

Actually, we probably only want the f(env:SOME_VAR} syntax for MD frontmatter, the {file:some_file} syntax doesn't seem like it would be terribly useful in the context of frontmatter.

@ariane-emory commented on GitHub (Dec 4, 2025): Actually, we probably only want the `f(env:SOME_VAR}` syntax for MD frontmatter, the `{file:some_file}` syntax doesn't seem like it would be terribly useful in the context of frontmatter.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3310