[Feature] Allow running commands directly from the CLI #1541

Closed
opened 2026-02-16 17:31:26 -05:00 by yindo · 1 comment
Owner

Originally created by @fmatsos on GitHub (Aug 30, 2025).

Originally assigned to: @rekram1-node on GitHub.

This feature request proposes the ability to execute opencode commands directly from the command-line interface (CLI) without needing to enter the Text-based User Interface (TUI).

Problem

Currently, opencode allows running a prompt with a specific agent via the CLI using opencode run --agent myagent prompt. However, there is no equivalent functionality to run a pre-defined command directly. To execute a command, a user must launch the TUI, which can be inefficient for quick tasks or for use in scripts.

Proposed Solution

I propose adding a --command flag to the opencode run subcommand. This would allow users to specify a command to be executed directly from the CLI, along with any necessary arguments.

Examples

Current Behavior (for agents)

opencode run --agent myagent "This is my prompt"

Desired Behavior (for commands)

opencode run --command mycommand "argument1" "argument2"

Benefits

  • Improved Workflow: Allows for a faster and more streamlined workflow for users who want to execute a specific command without the overhead of the TUI.
  • Scripting and Automation: Enables the integration of opencode commands into shell scripts and other automation workflows.
  • Consistency: Aligns the CLI experience of running commands with the existing experience of running agents.

This would make opencode even more powerful and flexible as a CLI tool.

Originally created by @fmatsos on GitHub (Aug 30, 2025). Originally assigned to: @rekram1-node on GitHub. This feature request proposes the ability to execute `opencode` commands directly from the command-line interface (CLI) without needing to enter the Text-based User Interface (TUI). ## Problem Currently, `opencode` allows running a prompt with a specific agent via the CLI using `opencode run --agent myagent prompt`. However, there is no equivalent functionality to run a pre-defined command directly. To execute a command, a user must launch the TUI, which can be inefficient for quick tasks or for use in scripts. ## Proposed Solution I propose adding a `--command` flag to the `opencode run` subcommand. This would allow users to specify a command to be executed directly from the CLI, along with any necessary arguments. ## Examples ### Current Behavior (for agents) ```sh opencode run --agent myagent "This is my prompt" ``` ### Desired Behavior (for commands) ```sh opencode run --command mycommand "argument1" "argument2" ``` ## Benefits - **Improved Workflow:** Allows for a faster and more streamlined workflow for users who want to execute a specific command without the overhead of the TUI. - **Scripting and Automation:** Enables the integration of `opencode` commands into shell scripts and other automation workflows. - **Consistency:** Aligns the CLI experience of running commands with the existing experience of running agents. This would make `opencode` even more powerful and flexible as a CLI tool.
yindo closed this issue 2026-02-16 17:31:26 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 30, 2025):

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

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 30, 2025): This issue might be a duplicate of existing issues. Please check: - #1398: [feature request: expose '/init' , '/compact' to Opencode CLI](https://github.com/sst/opencode/issues/1398) - This issue specifically requests exposing TUI slash commands to the CLI, with the exact same use case of controlling opencode through another app and needing TUI-only commands available via CLI. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1541