> For the complete documentation index, see [llms.txt](https://herd-security.gitbook.io/herd-security-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/cursor.md). Agents can also search and read this documentation through its [MCP server](https://herd-security.gitbook.io/herd-security-docs/~gitbook/mcp).

# Agent Oversight for Cursor

Extend agent oversight to Cursor with a hook script delivered through device management, how it behaves when Herd cannot be reached, and what is not covered.

{% hint style="warning" %}
**Plan feature.** Agent oversight is locked, with an **I'm interested** button, until it is on your organization's plan.
{% endhint %}

## What it does

Agent oversight for Cursor checks three kinds of action before Cursor runs them, and checks each prompt before it is sent (see [Prompts](#prompts)):

* shell commands
* MCP tool calls
* file reads

Herd applies your existing rules to them. A shell command is judged as a shell command, a file read as a read, and an MCP call by its `mcp__<server>__<tool>` name. Every rule starts in **Recording**, which records a match and blocks nothing. A rule blocks a Cursor action only after an admin switches it to **Enforcing**.

Cursor runs hooks as commands on the device, so Herd ships a small script for it. The script sends each action to Herd with your hook token and prints Herd's answer back to Cursor. It removes the file content and attachments from a read before it sends anything.

Herd never answers "allow" to Cursor. If no rule objects, the script prints nothing and Cursor carries on with its own approval prompt.

## What you need

* **Node 18 or later** on each device. The script needs it and has no other dependencies.
* **`HERD_HOOK_TOKEN`** visible to the Cursor process. See [Agent oversight hook token](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/hook-token.md). A copy of Cursor launched from the macOS desktop may not read a variable set in a shell profile, so confirm on one device that the variable reaches Cursor.
* A way to put files on devices at fixed paths, such as your device management tool.

## Set it up

1. Go to **AI Insights → Setup**. In the **Cursor** card, download the hook bundle. It holds the script and a `hooks.json` for each operating system.
2. Place the files with your device management, at the location Cursor reads for the device's operating system:

   | Operating system | Location of `hooks.json`                         |
   | ---------------- | ------------------------------------------------ |
   | macOS            | `/Library/Application Support/Cursor/hooks.json` |
   | Linux            | `/etc/cursor/hooks.json`                         |
   | Windows          | `C:\ProgramData\Cursor\hooks.json`               |

   These are the enterprise locations from Cursor's documentation. Cursor gives this file the highest priority and leaves distribution to your organization. Put the script where the `hooks.json` for that system says it is.
3. Decide how `HERD_HOOK_TOKEN` reaches each device.
4. Start with one group and one person. Run a shell command in Cursor and check that it shows in Herd.

Cursor's Enterprise plans can also deliver hooks from Cursor's cloud to a team. Cursor's documentation says these take about 30 minutes to sync and do not support the fail-closed setting. Herd's script has its own fail-closed option, described below.

{% hint style="info" %}
Cursor's documentation does not say that a person cannot remove or edit the device file. Treat the device file as a strong control, not a guarantee.
{% endhint %}

## When Herd cannot check an action

By default the hook fails open: if something goes wrong, Cursor lets the action run. **Fail closed** is the existing option on the Setup page. For Cursor it changes only the cases marked below, and only while the script is running.

| Situation                                                                                                                                                                                                                                                                                                                      | Fail closed off (default)                                                                                                                            | Fail closed on                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| Herd cannot be reached, or answers with an error status such as a 503 or a refused token. Herd answers a 503 itself when it has none of your rules in hand: it could not tell which organization is calling, your rules did not load and it has no earlier copy, or the deadline passed or something failed before they loaded | The script prints nothing and Cursor lets the action run.                                                                                            | The script blocks shell commands and MCP calls.               |
| `HERD_HOOK_TOKEN` is missing                                                                                                                                                                                                                                                                                                   | The action is unchecked and Herd sees nothing.                                                                                                       | The action is blocked. The message says the token is missing. |
| Herd answers with your rules in hand but cannot check the action (a rule could not run, an engine error, or a missed deadline after the rules loaded)                                                                                                                                                                          | A shell command is blocked only while an **Enforcing** rule could apply to it; otherwise it runs and Herd records it as unchecked. An MCP call runs. | The same as the left column.                                  |
| Herd cannot read the action in full                                                                                                                                                                                                                                                                                            | Blocked only while an **Enforcing** rule could apply to it.                                                                                          | The same as the left column.                                  |
| `node` or the script is missing on the device                                                                                                                                                                                                                                                                                  | Cursor lets every action run, and nothing in Herd shows that device.                                                                                 | The same as the left column.                                  |

## What is not covered

* **Cursor Tab** (inline completions).
* **Cursor cloud agents.**
* **Prompts longer than the check reads.** See [Prompts](#prompts).
* A person who removes the device file, or a device without Node, is not covered.

## Prompts

Herd checks a Cursor prompt before it is sent, with the same four prompt rules as [Claude Code prompt checking](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/prompt-checking.md): credentials, card numbers, IBANs and private keys. The generated `hooks.json` registers the prompt hook along with the three action hooks.

* **One mode per rule.** The mode you set for a rule applies in Claude Code, in the Claude organization backstop and in Cursor. Every rule starts in **Recording**.
* **A blocked prompt shows fixed wording.** The person sees the rule's own message if your organization [wrote one](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/built-in-rules.md#write-your-own-rule), and Herd's from the rule catalog otherwise. It never repeats the prompt.
* **A prompt always fails open.** If Herd is unreachable, slow or answers with an error, the prompt is sent, whatever **Fail closed** says. The setting covers only shell commands and MCP calls.
* **The script sends only the prompt and its ids.** Not attachments, file content, the transcript path or the model.
* **A rule whose action is to add context** is recorded as a match that would have blocked, because Cursor's reply has no place for context.
* **An identical prompt sent again is checked and recorded again.** Cursor gives no identifier for a prompt, so nothing removes the repeat.
* **Long prompts.** Of a prompt over 65,536 characters, Herd reads the first 32,768. A prompt over 1 MiB is not read.

{% hint style="warning" %}
**If you already deployed the Cursor files, prompt checking does nothing until you regenerate the bundle on the Setup page and deploy the new `hooks.json` and script.**
{% endhint %}

## People and sessions

Cursor reports the email of the signed-in user, but anyone who holds your hook token could send any email. Herd stores the email with the session and does not treat it as proof of whose session it was. Unless you connect a Cursor Admin API key (see below), a Cursor session in your organization is recorded **without a person**, and Herd cannot name or message that person. Cursor sessions are left out of the Compliance matching, the rollout counts and the session coverage series.

### Tie each session to a person with a Cursor Admin API key

{% hint style="info" %}
**Beta.** Herd has not yet confirmed this match on a live Cursor team. After you connect the key, check that a few sessions show the right person before you rely on it. The Cursor Admin API needs a Cursor Enterprise team.
{% endhint %}

1. In Cursor, a team administrator creates an Admin API key on the **API Keys** page of the Cursor dashboard.
2. In Herd, go to **AI Insights → Setup** and open the **Cursor** card. Under the hook files, find **Cursor: who ran each session**. The card is shown to people with the **Manage AI governance** permission.
3. Paste the key into **Cursor Admin API key** and click **Connect**.

Once an hour, Herd reads your Cursor team's members and usage events with the key. Herd reads nothing else from Cursor. For each Cursor session, Herd looks up the team member Cursor recorded for that conversation and ties the session to that person. From then on, that person's Cursor sessions count toward coaching and their risk score.

* **A person appears an hour or more after the session starts**, because Herd checks hourly.
* **A session stays without a person** when Cursor reports no usage for it, when Cursor's records name more than one member for the conversation, or when the member has been removed from the team.
* **Herd never replaces a person.** A session that already has a person keeps that person.
* **Herd uses Cursor's record over the email the hook sent.** When the two differ, the session goes to the member Cursor recorded.

To stop, click **Disconnect** on the card. Herd stops checking straight away and removes the key. Sessions already tied to a person keep that person, and new sessions are recorded without one.

Cursor never reports how a session was started, so **Who ran it** always reads **Not reported yet** for a Cursor session. See [Who ran it](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/coverage-and-bypass.md#who-ran-it).

Identical commands within one Cursor generation count once, because Cursor gives no identifier for each call. If you switch a rule from **Recording** to **Enforcing**, a repeat of the same command can keep its first answer for up to about two minutes.

## The computer's serial number

On macOS the script also sends the computer's serial number with each call. Herd uses it for one count: which managed computers that have Cursor sent a hook call for a shell command, an MCP call or a file read in the last 14 days, on the **Desktop AI apps** card. A prompt check does not count. A serial number the script cannot read is left out, and the answer is the same. See [What Herd puts on a managed computer](https://herd-security.gitbook.io/herd-security-docs/ai/ai-coach/what-herd-puts-on-a-managed-computer.md#the-computers-serial-number) and [Which computers report](https://herd-security.gitbook.io/herd-security-docs/setup-and-integrations/settings/jamf-and-kandji.md#which-computers-report).

## Keep personal accounts out

Optional, and off until you turn it on. In **Setup**, type your Cursor team ids (from your Cursor dashboard) under **Restrict sign-in to Cursor team ids**. Herd adds a macOS configuration profile and a Linux `policy.json` that set `AllowedTeamId`, Cursor's device policy. Cursor signs out and refuses a login to a team that is not listed.

* On Windows, set the `AllowedTeamId` policy from Cursor's ADMX files with the same comma-separated ids. Cursor's documentation gives no registry value.
* On Linux the policy file is in the person's home directory, so the person can edit it.
* Try it on one managed computer before you roll it out.

See [Personal accounts](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/coverage-and-bypass.md#personal-accounts).

## Related

* [Agent oversight hook token](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/hook-token.md)
* [Check Claude Code Prompts Before They Are Sent](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/prompt-checking.md), which covers Cursor prompts too
* [Agent oversight coverage and bypass](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/coverage-and-bypass.md)
* [Deliver the agent oversight settings with device management](https://herd-security.gitbook.io/herd-security-docs/ai/agent-oversight/device-management.md)
