.cursorignore helps restrict Cursor’s direct AI access to files, but it does not protect secrets through every tool. Terminal commands and MCP tools can still access ignored content. Use ignore files as one control alongside the permissions of the processes and accounts doing the work. 12
Understand what each file controls
Cursor respects .gitignore and supports additional exclusions in .cursorignore. Its documentation explicitly separates those file-access controls from terminal and MCP access. 1
Git has another limitation: adding a path to .gitignore does not stop tracking a file that is already tracked. 3 Check existing repository contents as well as the patterns you are about to add. A tidy ignore file is not evidence that a credential was never committed.
Check the route the agent uses
Review Cursor’s run mode, approvals and available sandbox controls. These determine how shell and MCP calls are handled; an instruction in a prompt is not a substitute for checking those settings. Platform and version support matter. 2
For an integration task, provide a development account with only the required access. Keep examples in documentation as placeholders, so the agent can understand the expected variable names without needing production values.
A harmless check is to create private-example.txt containing DUMMY_VALUE, exclude that filename and ask for a direct file read. Observe which tool is attempted and what it reports. This checks that route only; it does not establish that every terminal or MCP operation is blocked.
If a credential was already exposed
Adding an ignore rule cannot invalidate an exposed key. Revoke or rotate the credential with its provider, then address any copies or repository history that need attention. GitHub recommends dealing with the credential itself first when cleaning a repository exposure. 4