> print mode & automation
Print mode (-p / --print) turns the agent into a non-interactive command: it prints a final answer and exits, making it scriptable. It is inferred automatically when stdout is not a TTY or stdin is piped, so pipelines usually get it for free. Pair it with --output-format for JSON, --force to apply changes unattended, and CURSOR_API_KEY for CI.
// print mode & automation
6 commands$ cursor-agent -p "list all TODO comments in this repo"$ git diff | cursor-agent -p "summarize these changes"$ cursor-agent -p "review auth.ts for security issues" --output-format json$ cursor-agent -p "add tests for utils.ts" --output-format stream-json$ cursor-agent -p "update CHANGELOG.md for the latest release" --force$ curl https://cursor.com/install -fsS | bash// faq
How do I use the Cursor CLI non-interactively in a script?
Run cursor-agent -p "your prompt" — it prints the final response and exits with no TUI. Print mode also switches on automatically when you pipe into the CLI or redirect its output, so git diff | cursor-agent -p "summarize" works without the flag. Add --output-format json to parse the result programmatically.
What output formats does the CLI support?
text (default) prints only the final answer. json emits one JSON object with the full result plus session_id, request_id, and timing. stream-json emits newline-delimited events, one line per assistant message and a terminal result event; add --stream-partial-output for character-level deltas. All of them require --print.
Why does the agent not apply changes in print mode?
Print mode is non-interactive, so there is no one to approve write or shell actions. Add --force (aliases -f, --yolo) to allow commands that are not explicitly denied, or scope a permissions.allow list. permissions.deny entries still block even with --force.
How do I parse the JSON output safely?
On success --output-format json writes a single object; read its result field for the text and session_id to resume the thread. On failure the process exits non-zero and writes an error to stderr with no JSON emitted, so always check the exit code before piping stdout into jq.
How do I run the CLI in GitHub Actions?
Install with the curl script, add "$HOME/.local/bin" to $GITHUB_PATH, and run cursor-agent -p "..." --force. Store your key as a repository secret and expose it with env: CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}. Browser login cannot work in CI, so a missing key fails with "Not authenticated."