.agents/skills/opencode-qa/references/cli-commands.md
The installed binary is opencode (v1.15.13). From the source repo you can also run bun run --conditions=browser ./src/index.ts <cmd> inside packages/opencode. The canonical non-interactive QA entry is opencode run --format json.
--print-logs
--log-level DEBUG|INFO|WARN|ERROR
--pure (run without external plugins)
-h, --help
-v, --version
opencode run (non-interactive QA core)Positional message. Key flags:
-m, --model <provider/model>
--agent <name>
-s, --session <ses_...>
-c, --continue
--fork
--format default|json
-f, --file <path>
--title
--attach <url>
-p, --password
-u, --username
--dir
--variant
--thinking
-i, --interactive
--dangerously-skip-permissions
--command <slash-cmd>
--format json emits NDJSON, one JSON object per line, each shaped like:
{"type":"...", "timestamp":<ms>, "sessionID":"ses_...", ...}
type is one of: text, tool_use, step_start, step_finish, reasoning, error. The process exits when the session goes idle.
Validation rules:
-i cannot combine with --command or --format json--fork needs -c or -sExamples:
opencode run "list the files in src" --format json
opencode run --command commit
opencode run -c "continue the previous task"
opencode run "explain auth" --attach http://127.0.0.1:4096 -p "$OPENCODE_SERVER_PASSWORD"
opencode db (database tools)opencode db path
Prints the active DB file path.
opencode db "<SQL>" --format json
Runs a query and prints JSON rows. Use --format tsv (default) for TSV output.
opencode db
Opens an interactive sqlite3 shell.
opencode db migrate
Migrates legacy JSON storage into SQLite.
Bundled scripts for session investigation:
scripts/db-session-by-id.shscripts/db-session-by-name.shscripts/db-session-by-text.shscripts/export-roundtrip.shFull detail in references/db-investigation.md.
opencode sessionopencode session list --format json
Lists sessions as JSON.
opencode session delete <ses_id>
Deletes one session.
opencode export [sessionID]Prints "Exporting session: ..." to STDERR and a clean JSON document {info:{...}, messages:[...]} to STDOUT. Always redirect STDERR before piping to jq.
Example:
opencode export ses_3a4e... 2>/dev/null | jq '.info.id'
Bundled wrapper:
scripts/export-roundtrip.sh <ses_id>
opencode serveStarts a headless HTTP server.
Flags:
--port (0 = pick 4096 then a free port)
--hostname (default 127.0.0.1)
--mdns
--mdns-domain
--cors
On start it prints:
opencode server listening on http://<host>:<port>
Set OPENCODE_SERVER_PASSWORD to require auth. See references/server-api.md.
Bundled smoke test:
scripts/server-smoke.sh
opencode debugUseful subcommands:
opencode debug paths # data/config/cache/state dirs
opencode debug info # version, OS, terminal, plugins
Others: config, lsp, ripgrep, file, skill, snapshot, agent, v2, wait.
opencode models [provider] --verbose
opencode stats
opencode providers list # alias: auth
opencode mcp list
opencode generate # prints the OpenAPI JSON spec
The installed opencode (v1.15.13) matches the dev source in packages/opencode. When citing internals, cite dev source paths but always verify a flag against opencode <cmd> --help on the installed binary, since the dev branch can drift ahead.
For DB internals see references/db-investigation.md; for the HTTP server see references/server-api.md.