You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+41-6Lines changed: 41 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,7 +235,7 @@ OpenCode supports a variety of AI models from different providers:
235
235
236
236
- Gemini 2.5
237
237
- Gemini 2.5 Flash
238
-
238
+
239
239
## Usage
240
240
241
241
```bash
@@ -249,13 +249,46 @@ opencode -d
249
249
opencode -c /path/to/project
250
250
```
251
251
252
+
## Non-interactive Prompt Mode
253
+
254
+
You can run OpenCode in non-interactive mode by passing a prompt directly as a command-line argument. This is useful for scripting, automation, or when you want a quick answer without launching the full TUI.
255
+
256
+
```bash
257
+
# Run a single prompt and print the AI's response to the terminal
258
+
opencode -p "Explain the use of context in Go"
259
+
260
+
# Get response in JSON format
261
+
opencode -p "Explain the use of context in Go" -f json
262
+
263
+
# Run without showing the spinner (useful for scripts)
264
+
opencode -p "Explain the use of context in Go" -q
265
+
```
266
+
267
+
In this mode, OpenCode will process your prompt, print the result to standard output, and then exit. All permissions are auto-approved for the session.
268
+
269
+
By default, a spinner animation is displayed while the model is processing your query. You can disable this spinner with the `-q` or `--quiet` flag, which is particularly useful when running OpenCode from scripts or automated workflows.
270
+
271
+
### Output Formats
272
+
273
+
OpenCode supports the following output formats in non-interactive mode:
0 commit comments