In this categoryCursor ยท 26
- How to Install Cursor and Import VS Code Settings (6 Minutes)Start
- Cursor Setup Guide: From Install to Your First AI Edit
- How to Set Up Project Rules in the .cursor/rules Folder
- How to Set Up Codebase Indexing in Cursor
- How to Enforce Project Conventions with Cursor Rules
- How to Write a Team Rule That Applies Only to Certain Files
- How to Migrate a Legacy .cursorrules File to the New Rules Folder
- How to Use Cursor Rules to Guide AI Edits
- How to Set Project Rules in Cursor
- How to Add a .cursorrules File to Steer Cursor
- How to Customize Cursor Keyboard Shortcuts
- How to Edit Multiple Files at Once with Cursor Composer
- How to Use Cursor Tab Completion Effectively
- How to Edit Code Inline with Cmd+K in Cursor
- How to Add Context to Cursor Chat with @ Mentions
- How to Choose and Switch AI Models in Cursor
- How to Add Library Docs as Context with @Docs in Cursor
- How to Generate and Maintain Tests with Cursor Composer
- How to Undo a Composer Change with Checkpoints in Cursor
- How to Use Cursor Agent Mode to Build a Feature End to End
- How to Connect an MCP Server to Cursor
- How to Refactor Across Your Whole Codebase in Cursor
- How to Query Your Database from Cursor with a Postgres MCP Server
- How to Let Cursor Run Commands Automatically (and Keep It Safe)
- How to Build a Full Feature Across Frontend and Backend with Composer
- How to Debug an MCP Server That Will Not Connect in Cursor
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
30:24
16:30
33:42
41:18
28:05
3:12New guides in your inbox
Fresh step-by-step how-to guides as we publish them. One email a week, no more.