A team wants Cursor Tab kept away from certain files and every Tab edit audited; which controls reach Tab, and which Agent-side settings do not?
answer
- Tab is not Agent
- two hooks of its own
- ignore file covers Tab too
- fail-open unless told otherwise
- rules and personal keys skip it
basics
~20 sTab is governed by .cursorignore and by two Tab-only hooks, beforeTabFileRead (allow or deny a read) and afterTabFileEdit (audit an edit); rules, Agent hooks such as beforeReadFile, personal API keys and the model picker do not reach Tab.
solid answer
~40 sTreat Tab as its own surface. Files listed in `.cursorignore` are blocked from Agent, Tab and Inline Edit alike. For finer control, `hooks.json` has two **Tab hooks**: `beforeTabFileRead` receives the file path and contents and returns `allow` or `deny` (matcher value `TabRead`), and `afterTabFileEdit` receives the edit ranges and old and new lines for auditing or formatting (`TabWrite`). Hook failures are fail-open by default, so a security hook should set `failClosed: true`. What does **not** reach Tab: rules (the docs say rules do not impact Tab), the Agent hooks such as `beforeReadFile` and `afterFileEdit`, personal API keys (Tab keeps using Cursor's built-in models) and the chat's model picker. Team analytics then count accepted Tab suggestions and Tab-written lines.
code
json · 19 lines{
"version": 1,
"hooks": {
"beforeTabFileRead": [
{
"command": ".cursor/hooks/tab-read-guard.sh",
"matcher": "TabRead",
"timeout": 5,
"failClosed": true
}
],
"afterTabFileEdit": [
{
"command": ".cursor/hooks/tab-edit-audit.sh",
"matcher": "TabWrite"
}
]
}
}go deeper
Recall that Tab is a separate surface from Agent and that .cursorignore and the Tab status indicator both apply to it.
Explain the two Tab hooks, their inputs and outputs, the TabRead and TabWrite matcher values, and where hooks.json lives at project and user level.
Design a Tab control set that fails closed where it must, and explain why rules, Agent hooks, personal keys and Run Modes leave Tab uncovered.
Decide whether Tab's value justifies its governance cost on a sensitive codebase, versus disabling it for certain file types or folders, and how to evidence the choice with analytics.
## Why Tab needs its own controls Cursor has several AI surfaces, and most of its governance features were designed around **Agent**: rules, Run Modes, Agent hooks, the model picker. **Tab**, the autocomplete, is different. It reads files and writes edits continuously as you type, without a chat, and the documentation lists separate, Tab-specific mechanisms for it. A team that configures only Agent-side controls and assumes Tab follows them has a gap. ## Controls that do reach Tab - **`.cursorignore`.** Cursor blocks files listed in it from code accessible by Agent, **Tab** and Inline Edit, and from @-mention references. Its syntax and default list belong to the material on Cursor's ignore files; the point here is only that Tab is inside its scope. The docs add that complete protection is not guaranteed. - **`beforeTabFileRead` hook.** Called before Tab reads a file. Input is `file_path` and `content`; output is `permission`: `allow` or `deny`. It fires only for Tab, not Agent, and has no `attachments` field because Tab uses none. Typical use: redaction or access control for autonomous Tab operations. - **`afterTabFileEdit` hook.** Called after Tab edits a file. Input includes the file path and the edits with `range`, `old_line` and `new_line`, so it can feed a formatter or an audit log of Tab-written code. - **The Tab status indicator and Cursor Settings > Tab.** Snooze, disable globally, or disable for specific file extensions. - **Team analytics.** The Tab Completions chart counts accepted Tab suggestions, and the AI Code Tracking API reports fields such as `tabLinesAdded` and `tabLinesDeleted`. ## Wiring the hooks Hooks are defined in a `hooks.json` file with `"version": 1` and a `hooks` object mapping each hook name to an array of definitions. A definition has a `command` and optional fields such as `matcher`, `timeout` and `failClosed`. The matcher values for Tab are fixed: `TabRead` for `beforeTabFileRead` and `TabWrite` for `afterTabFileEdit`. Failure behaviour decides whether a hook is a control or a suggestion: 1. Exit code `2` blocks the action, the same as returning `deny`. 2. For permission hooks such as `beforeTabFileRead`, invalid JSON or a response that does not match the schema blocks the action. 3. Crashes, timeouts and other non-zero exit codes **fail open** by default; set `failClosed: true` to block on those too. Hooks load from four sources, highest priority first: **Enterprise** (MDM-managed, system-wide), **Team** (cloud-distributed, Enterprise only), **Project** (`<project>/.cursor/hooks.json`, run in trusted workspaces and checked into version control) and **User** (`~/.cursor/hooks.json`). All matching hooks run, and any `deny` wins over `allow`. ## Settings that do not reach Tab | Setting | Why it misses Tab | |---|---| | Project and user rules | The rules docs state that rules do not impact Cursor Tab | | `beforeReadFile`, `afterFileEdit` | Agent hooks; they apply to Cmd+K and Agent Chat, not to Tab | | Personal API keys | Custom keys work only with chat models; Tab keeps using Cursor's built-in models | | The model picker and Auto | The picker sits in the chat and agent panel and chooses models for those requests; Tab runs on Cursor's built-in models | | Run Modes | They govern Agent's shell, MCP and Fetch calls; Tab runs none | Tab is also an editor feature: the Tab hooks do not run in cloud agents, because Tab completions do not run there. ## Mistakes that leave Tab uncovered - **Copying an Agent hook and assuming it covers Tab.** A `beforeReadFile` script that denies a path does nothing for Tab until the same logic is registered under `beforeTabFileRead`. - **Relying on a rule such as "never read the fixtures folder".** Rules are instructions to Agent; Tab never sees them. - **Leaving a security hook fail-open.** A guard that times out under load silently lets reads through unless `failClosed` is `true`. - **Putting the hook only in a user-level file.** `~/.cursor/hooks.json` protects one machine; a project file in version control, or a team or enterprise hook, reaches everyone. - **Measuring nothing.** Without the Tab analytics, a team cannot tell whether the controls changed how much code Tab writes. ## A sensible setup 1. List clearly sensitive paths in `.cursorignore` so every surface, Tab included, is blocked from them. 2. Add a project-level `beforeTabFileRead` hook with `failClosed: true` for any rule more nuanced than a path list, such as redacting content. 3. Add `afterTabFileEdit` to log or format Tab-written lines, and read the team's Tab analytics instead of guessing how much code Tab writes. 4. Keep Agent-side controls in place, but never count them as covering Tab. Why an organisation wants these controls at all is a security-design question for the material on agent safety; what Cursor itself offers is the list above.
- The team already has a beforeReadFile hook that denies reads under a secrets path. Is Tab covered?No. beforeReadFile is an Agent hook; Agent hooks apply to Cmd+K and Agent Chat. Tab triggers beforeTabFileRead instead, so the team needs a second definition under that name, or a .cursorignore entry, which Cursor applies to Agent, Tab and Inline Edit alike.
- A developer adds their own provider key under Cursor Settings > Models to keep code on their provider account. Does Tab use it?No. Cursor's help on API keys says custom keys only work with chat models and Tab completion continues using Cursor's built-in models. A team relying on a provider key for data handling must account for Tab separately, for example by disabling it for sensitive file types or guarding reads with a Tab hook.
- A beforeReadFile hook also stops Tab from reading a file
- Rules in .cursor/rules restrict what Tab may suggest
- Adding your own API key moves Tab onto your provider account
- A crashing permission hook blocks the action by default
- .cursorignore only affects Agent, not Tab