Skip to content

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

Closed as not planned
ariane-emory/opencode
#30

Description

@rwese

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:

rwese@2c9bf37

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Dec 4, 2025
  2. github-actions commented on Dec 4, 2025

    @github-actions
    Contributor

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

    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.

  3. rwese commented on Dec 4, 2025

    @rwese
    ContributorAuthor

    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

  4. ariane-emory commented on Dec 4, 2025

    @ariane-emory
    Contributor

    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.

  5. ariane-emory commented on Dec 4, 2025

    @ariane-emory
    Contributor

    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.

  6. self-assigned this
    on Dec 13, 2025
  7. Toady00 commented on Mar 1, 2026

    @Toady00

    Adding another use case: I’m looking for actual shell command execution in frontmatter, not just variable substitution.

    I keep a small YAML config file per repo to inform the agent about repo-specific details (e.g. where my specs directory is, other project paths, etc). I use yq to pull values out of that YAML and inject them into command markdown so the agent knows where to go look for things. I use this pattern pretty broadly.

    One specific thing I’d like to drive from that same repo config is model selection per project. The goal is to keep command files generic/portable and avoid editing them per repo, while still letting each repo say "use model X for this project".

    I could do this with env vars, but that tends to add more setup and tooling (direnv, docs, onboarding steps). Especially when collaborating, it’s much simpler if the repo just carries a YAML config and commands can read it directly.

    So this feature would unlock a clean repo-config-controls-behavior pattern, not just templating convenience.

  8. github-actions commented on May 1, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions