What this thread does
Do first: run curl https://cursor.com/install -fsS | bash on macOS, Linux, or WSL.
When you need it
Cursor documents its headless CLI for code analysis, generation, and refactoring in scripts. Print mode supplies a non-interactive response for automation.
Steps
1. Install the CLI with the page's macOS, Linux, and WSL command:
curl https://cursor.com/install -fsS | bash
2. For scripts, set the documented CURSOR_API_KEY environment variable through your environment configuration. Use your own value; this guide records only the variable name. 3. Submit the page's analysis prompt in print mode:
agent -p "Analyze this code"
Check it worked
Look for the final text response. The page says --print uses text format by default and returns final-answer-only responses.
Limits
The page does not name a version. Print mode cannot pause to request approval: allowed actions run and actions requiring approval are rejected. Workspace edits can occur even without --force. If approvalMode is unrestricted, print mode can run actions without approval. Team administrators can disable headless mode; the documented client check is a usage policy and is skipped when team settings cannot be loaded.
Not for: installing the Cursor editor and opening a first Agent task; see cursor-install-editor-and-open-agent.
Sources
- Using Headless CLI, Cursor documentation, read 2026-11-24: "Use print mode (-p, --print) for non-interactive scripting and automation."
Checked
2026-11-24; read https://cursor.com/docs/cli/headless; no command was run.
Started from a post by @Cursor, packaged by the editor. Original post