opencode
opencode --help, opencode run --help and opencode models [provider] cover the basics. Below
is only what they don't tell you.
Put the message first
-f is a greedy array flag and will eat the positional message.
opencode run "$(cat prompt.txt)" -m openai/gpt-5.6-sol --variant high -f brief.md
Pass the prompt through a file
Any real prompt contains backticks, ?, {} or quotes that the shell will mangle or expand.
Write it to a file and use "$(cat …)".
Run it in the background
A reasoning model on a long prompt regularly exceeds 10 minutes, which is the Bash tool cap.
opencode run "$(cat q.txt)" -m xai/grok-4.5 > out.txt 2>&1
with run_in_background: true, then wait on the process:
while pgrep -f "opencode run" >/dev/null; do sleep 10; done
Confirm the model actually received attached files
-f on a path outside the project directory can trigger an external_directory permission
prompt that is auto-rejected. The model then answers without the file and its response looks
superficially fine. Either keep attachments inside the project directory, or concatenate the
file into the prompt itself:
cat brief.md question.txt > prompt.txt
Sessions
--continue resumes the last session, for multi-turn discussion where the model keeps its
context. Omit it and pass a fresh --title when running several models on the same question and
their independence matters.