How to Let Cursor Run Commands Automatically (and Keep It Safe)
Enable auto-run for the Cursor agent and set an allow and deny list so it executes tests without risky commands.
By default Cursor's agent asks before running any terminal command. For tight loops like writing code then running tests, that confirmation step gets tedious. Cursor can run commands automatically, but turning that on without guardrails is risky. This guide enables auto-run while blocking destructive commands so the agent can iterate without you babysitting every step.
- Cursor with agent mode
- A project with a test or lint command the agent should run
- A few minutes to define allow and deny lists
Find the auto-run setting
Open Cursor Settings and go to the Agent or Terminal section. Look for the option that controls whether terminal commands run automatically. Enabling it lets the agent execute commands without a per-command prompt.
Build an allow list
Add only the commands you are comfortable running unattended. Test runners, linters, type checkers, and read-only git commands are good candidates. Anything that writes to the network or deletes files should not be here.
npm test
npm run typecheck
npm run lint
git status
git diffBuild a deny list
The deny list is your safety net. Block commands that delete data, change remote state, or run arbitrary downloads. A denied command always pauses for explicit approval even when auto-run is on.
rm
rmdir
git push
git reset --hard
curl
wget
sudoTest the loop
Ask the agent to fix a failing test and run the suite. It should edit code and run npm test on its own, but pause if it ever reaches for something on the deny list. Watch the first few runs closely before trusting it.
Result: the agent runs your tests and linters on its own to close a fix-and-verify loop, while destructive commands still require your explicit approval.
Watch related tutorials
12:36
18:52
14:05
22:40
7:18
33:42