CursorAdvanced

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.

9 minAdvanced

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.

Cursor Settings - Agent
Terminal command execution
------------------------------
[x] Auto-run allowed commands
Allow list: npm test, npm run lint, git status
Deny list: rm, git push, curl, sudo
Auto-run with allow and deny lists is the safe middle ground.

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.

Allow list examples
npm test
npm run typecheck
npm run lint
git status
git diff

Build 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.

Deny list examples
rm
rmdir
git push
git reset --hard
curl
wget
sudo
Deny wins over allow
Keep the deny list broad. If a command could be destructive and is not on the allow list, the agent should stop and ask. Treat the deny list as the real boundary.

Test 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.

Cursor Agent terminal
agent runs allowed command automatically
$npm test
Tests: 1 failed, 23 passed
agent edits the failing module, then re-runs
$npm test
Tests: 24 passed
$

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

Tags
#cursor#agent#auto-run#safety