diff options
| author | Adam Malczewski <[email protected]> | 2026-06-04 22:26:51 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-04 22:26:51 +0900 |
| commit | 0af8b1de733a199dbf5dcf779cc45f495048b1c3 (patch) | |
| tree | 267d9b46db7bbeb747d0d1cc9d330079aa62fa09 /notes | |
| parent | fd855ffb335e72a94b6f992ede5a859237460a8b (diff) | |
| download | dispatch-0af8b1de733a199dbf5dcf779cc45f495048b1c3.tar.gz dispatch-0af8b1de733a199dbf5dcf779cc45f495048b1c3.zip | |
chore: track agent-CLI note + ignore prompts/
Diffstat (limited to 'notes')
| -rw-r--r-- | notes/opencode-agents.md | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/notes/opencode-agents.md b/notes/opencode-agents.md new file mode 100644 index 0000000..5a8e489 --- /dev/null +++ b/notes/opencode-agents.md @@ -0,0 +1,64 @@ +# Spawning OpenCode Agents via CLI + +## Non-interactive (headless) run + +`opencode run` streams output to stdout and exits — no TUI opens. + +```bash +opencode run "your prompt here" +``` + +## Key flags + +| Flag | Short | Purpose | +|------|-------|---------| +| `--dir` | | Working directory for the agent | +| `-m provider/model` | `--model` | Which model to use | +| `-f path/to/file` | `--file` | Attach a file to the message | +| `--agent` | | Which agent profile to use | +| `--format json` | | Raw JSON events instead of formatted text | +| `--dangerously-skip-permissions` | | Auto-approve all permissions (dangerous!) | + +## Examples + +### Run with a specific model and CWD + +```bash +opencode run --dir /path/to/project -m opencode-go/qwen3.7-max "your prompt" +``` + +### Attach a file as context + +```bash +opencode run --dir /path/to/project -m opencode-go/qwen3.7-max -f prompt.md "follow the instructions in the attached file" +``` + +### Pipe file content as the prompt itself + +```bash +opencode run --dir /path/to/project -m opencode-go/qwen3.7-max "$(cat prompt.md)" +``` + +### Use a specific agent profile + +```bash +opencode run --dir /path/to/project --agent my-agent -f prompt.md "do it" +``` + +### JSON output for scripting + +```bash +opencode run --dir /path/to/project -m opencode-go/qwen3.7-max -f prompt.md "do it" --format json +``` + +## API key configuration + +- **Env var:** `ANTHROPIC_API_KEY=sk-... opencode run ...` (provider-specific) +- **Persisted:** `opencode auth login --provider anthropic` +- **Project `.env`:** opencode reads `.env` on startup + +## Listing available agents + +```bash +opencode agent list +``` |
