Cursor CLI Non-Interactive Mode (Scripts & CI)
2 min read
Interactive mode: the AI asks you questions, you press Y/N, and confirm step by step — like pair programming with someone. Non-interactive mode: give it one instruction, it runs to completion, no one needs to sit there pressing keys. Perfect for scripts or CI pipelines — let the AI work overtime while you do something else.
Basic Usage
Add --no-interactive (or the shorthand -n):
cursor agent "Add a .editorconfig to the project" --no-interactive- The AI executes directly without pausing for input
- Best for: predictable, repeatable tasks (adding comments, fixing lint, reformatting to standards, etc.)
Using in a Script
#!/bin/bash
cd /path/to/project
cursor agent "Run the linter and fix issues per CONTRIBUTING.md" --no-interactive- Works for automated code cleanup, simple refactors, adding comments
- Remember: the CI environment needs Cursor account authorization (run
cursor auth loginfirst, or use a token) — otherwise the AI can't do anything
Specifying a Model (Optional)
Want to use a specific model for the run:
cursor agent "Rewrite this comment" --model claude-3-5-sonnet --no-interactiveCheck the official docs for available model names — don't make up model IDs.
Run in the Cloud (-c)
Heavy task and don't want to tie up your terminal? Use -c to hand it off to the cloud:
cursor agent "Analyze the entire repo and generate an architecture document" -c-chands the conversation off to a cloud Agent to continue- You can close your terminal — you can reconnect to the conversation later. Think of it as "background execution," but it's the AI working in the background for you.
Summary
- Non-interactive: add
--no-interactiveor-n, no one needs to press keys - Scripts/CI: same command — just make sure the environment can log in to Cursor
- Specify a model:
--model model-name - Long-running tasks: use
-cto hand off to the cloud, works even if you shut down
Next: 05-tips — Tips and FAQ to avoid common pitfalls