Run a one-off prompt without the interface
headless & scripting
// what it does
-p (or --prompt) runs a single prompt, prints the answer to stdout, and exits — no TUI. This is the building block for scripting and CI. Combine it with -m to choose a model and > to capture the result to a file.
// shell
$ gemini -p "summarize README.md"$ gemini -p "explain this error" > answer.txt// gotcha
Headless mode still respects your approval settings, so a prompt that wants to edit files or run shell commands will stall waiting for confirmation that never comes. Add --yolo or --approval-mode for unattended runs that need tool use.