# CLI Reference > Complete command-line reference for OpenCode. All commands run from a terminal. ``` opencode [command] [flags] ``` ## Default behavior Running `opencode` with no command starts the TUI in the current directory. This is the same as `opencode tui`. ## Global flags | Flag | Purpose | |---|---| | `--help`, `-h` | Display help | | `--version`, `-v` | Print version | | `--print-logs` | Print logs to stderr | | `--log-level ` | `DEBUG` \| `INFO` \| `WARN` \| `ERROR` | | `--pure` | Run without loading external plugins | --- ## `opencode` / `opencode tui` Start the terminal UI. ```bash opencode [project] [flags] ``` | Flag | Purpose | |---|---| | `--continue`, `-c` | Continue the last session | | `--session `, `-s` | Continue a specific session | | `--fork` | Fork the session when continuing | | `--prompt ` | Pre-fill prompt | | `--model `, `-m` | Set model (`provider/model-id`) | | `--agent ` | Start with a specific agent | | `--port`, `--hostname` | Bind the underlying server | | `--mdns`, `--mdns-domain` | mDNS discovery | | `--cors ` | Additional browser origins for CORS | --- ## `opencode run` Run OpenCode non-interactively with a prompt. ```bash opencode run "summarize the last 5 commits" opencode run --format json "list every TODO with file and line" opencode run --agent plan --model anthropic/claude-haiku-4-5 "audit src/ for missing input validation" ``` | Flag | Purpose | |---|---| | `--continue`, `-c` | Continue the last session | | `--session `, `-s` | Continue a specific session | | `--fork` | Fork the session when continuing | | `--share` | Share the session | | `--model `, `-m` | Model in `provider/model-id` form | | `--agent ` | Agent to use | | `--file `, `-f` | Attach file(s) to the message | | `--format ` | Output format | | `--title ` | Title for the session | | `--attach ` | Attach to a running OpenCode server | | `--password`, `-p` · `--username`, `-u` | Basic auth for the attached server | | `--dir ` | Directory to run in | | `--port` | Port for the local server backing this run | | `--variant ` | Model variant | | `--thinking` | Show thinking blocks | | `--command ` | Run a saved command | | `--dangerously-skip-permissions` | Auto-approve everything that isn't explicitly denied. **CI only.** | --- ## `opencode auth` Manage provider credentials. ```bash opencode auth login [--provider ] [--method