

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Learn AI Coding
incomplete
2: Chat, Autocomplete, and Agents
incomplete
3: Installing OpenCode
incomplete
4: OpenCode Console
incomplete
5: The Unix Philosophy
incomplete
6: OpenCode Config
incomplete
7: CLI Config
incomplete
8: OpenCode Run
incomplete
9: GUI Clients
incomplete
10: Mobile Usage
incomplete
11: Remote Server
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The opencode command opens the full-screen TUI, which is how I use OpenCode 90% of the time. However, sometimes you don't want to chat, you just need a single response. For example, scripts and one-off prompts don't need the interactive UI.
opencode run sends a prompt to the agent and returns its response directly:
opencode run "Explain how our auth middleware works"
In this mode, the agent can still read files, run tools, and use the project's configuration, but it won't open the TUI.
Any permission requests that need an interactive approval will be rejected in this mode.
Assistant messages go to stdout, while progress and tool activity go to stderr, making shell redirection useful:
opencode run "Summarize this project" > project-summary.md
You can also use --format json if another program needs structured events instead of plain text.
Sometimes I like to have one model do an "adversarial review" of another model's work before I look at it. I just instruct my agent to use opencode run --model <model> to run a different model when it's done for a second opinion.
Use opencode run to add a SlopLang example that prints the result of 1 + 2 * 3.
opencode run --model "<provider/model>" "Read docs/spec.md and examples/hello.slop. Create a new examples/arithmetic.slop file that prints the result of 1 + 2 * 3. Change only that example. Run it, confirm it prints 7, and run uv run pytest tests/test_examples.py -q."
opencode run --continue "Describe the correction here"
Tell OpenCode to run and submit the CLI tests from the project root.
In SlopLang, the hallucinate function is the same as Python's print function, and the ✨ emoji is the statement terminator (like a semi-colon in C).