Skip to main content
OpenCode supports various command-line flags to customize its behavior. All flags can be used in both interactive and non-interactive modes unless otherwise noted.

Global flags

These flags are available for all OpenCode commands.
flag
default:"false"
Display help information about OpenCode and its usage.Short form: -h
flag
default:"false"
Print the current version of OpenCode and exit.Short form: -v
flag
default:"false"
Enable debug mode with verbose logging output. Useful for troubleshooting issues or understanding OpenCode’s internal operations.Short form: -dWhen enabled:
  • Log level is set to debug
  • Detailed information about operations is displayed
  • Helpful for debugging configuration or integration issues
string
default:"current directory"
Set the current working directory for OpenCode. The application will change to this directory before starting and use it as the root for all file operations.Short form: -cUse cases:
  • Work with a specific project directory
  • Run OpenCode from anywhere while targeting a specific location
  • Useful in scripts where the working directory may vary

Non-interactive mode flags

These flags control OpenCode’s behavior in non-interactive mode.
string
default:""
Run a single prompt in non-interactive mode. When this flag is provided, OpenCode:
  • Processes the prompt immediately
  • Prints the AI response to stdout
  • Exits after completion
  • Auto-approves all permissions for the session
  • Does not launch the TUI
Short form: -pThis mode is ideal for:
  • Scripting and automation
  • Quick queries without launching the full interface
  • CI/CD pipelines
  • Testing prompts
Multi-line prompts can be provided using shell quoting:
string
default:"text"
Specify the output format for non-interactive mode. Only applies when used with --prompt.Short form: -fSupported formats:The JSON format is useful for:
  • Parsing responses programmatically
  • Integration with other tools
  • Structured data processing
  • API-like usage
flag
default:"false"
Hide the spinner animation in non-interactive mode. Only applies when used with --prompt.Short form: -qBy default, OpenCode displays a spinner while processing your prompt. Use this flag to suppress the spinner when:
  • Running from scripts
  • Piping output to other commands
  • Using in automated workflows
  • Logging output to files
  • The spinner interferes with other terminal output
Combine with --output-format json for clean, parseable output:

Flag combinations

Flags can be combined to achieve different behaviors:

Flag precedence

When multiple configuration sources are present, OpenCode follows this precedence order:
  1. Command-line flags (highest priority)
  2. Environment variables
  3. Local config file (.opencode.json in working directory)
  4. Global config file (~/.opencode.json or ~/.config/opencode/.opencode.json)
  5. Default values (lowest priority)
For example, if debug is set in both the config file and via the -d flag, the flag takes precedence.

Boolean flags

Boolean flags like --debug, --quiet, and --help can be specified in multiple ways:

Common patterns

Development workflow

Scripting

CI/CD integration

Quick queries

Tips

Use short forms for faster typing: -d instead of --debug, -p instead of --prompt, etc.
Combine with shell features: Use command substitution, pipes, and redirection:
The --output-format and --quiet flags only apply in non-interactive mode (when using --prompt). They are ignored in interactive mode.