> ## Documentation Index
> Fetch the complete documentation index at: https://docs.endorlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Coding Agent Governance with MDM

> Generate Cursor hooks, Claude Code settings, Codex requirements, GitHub Copilot policy hooks, or a macOS configuration profile for managed developer machines.

Coding Agent Governance configurations connect Cursor, Claude Code, Codex, and GitHub Copilot events to Endor Labs. Use this page to generate hook configuration for individual machines or for fleets managed through mobile device management (MDM).

You can create Cursor `hooks.json`, Claude Code `settings.json`, Codex `requirements.toml`, a GitHub Copilot policy hook file, or a macOS configuration profile for Claude Code or Codex. The generated hooks install and update endorctl when a coding agent session starts.

The generator and the mdm-scripts repository don't cover Snowflake Cortex Code yet. See [Deploy hooks for Snowflake Cortex Code](https://docs.endorlabs.com/agent-governance/cortex-code.md#install-on-a-managed-fleet) to deliver its hooks file by hand.

## Before you begin

Complete the following tasks before you generate a configuration:

* Complete the [Coding Agent Governance prerequisites](https://docs.endorlabs.com/agent-governance/prerequisites.md).
* Create an API key with the **AI Audit User** role.
* Identify the namespace that owns your Coding Agent Governance policies.
* For manual generation, install `git` on the admin machine. The scripts run with system tools only. Creating a macOS configuration profile also requires macOS and `plutil`.

## Generate a configuration in your browser

The browser generator assembles the configuration locally. Your API key, secret, namespace, and environment variable values are never sent to Endor Labs or GitHub.

If the browser generator isn't available or can't fetch its source files, [generate the configuration manually](#generate-a-configuration-manually).

## Generate a configuration manually

The [Endor Labs MDM scripts repository](https://github.com/endorlabs/mdm-scripts/tree/main/agent-governance) is the authoritative source for the generator scripts. Clone the repository on an admin machine.

```bash theme={null}
git clone https://github.com/endorlabs/mdm-scripts
cd mdm-scripts/agent-governance
```

Set your credentials as environment variables. The generator reads these exact variable names, and prompts for any missing credential when you run it interactively.

```bash theme={null}
export ENDOR_API_CREDENTIALS_KEY="<api-key>"
export ENDOR_API_CREDENTIALS_SECRET="<api-secret>"
export ENDOR_NAMESPACE="<namespace>"
```

Generate the configuration that matches your coding agent and deployment method.

> [!WARNING]
>
> The output contains your API key and secret. Treat the output and its MDM policy as secrets. Restrict access and rotate the API key if someone exposes the configuration.

> [tab] Cursor
>
> Generate `hooks.json` for macOS or Linux. Cursor has no managed environment block, so every hook command includes the credentials and `--env` settings inline.
>
> ```bash theme={null}
> scripts/render.sh --agent cursor \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o cursor-hooks.json
> ```
>
> For Windows, add `--target-os windows`. The generated hook uses an encoded PowerShell command that can run from Git Bash, PowerShell, or Command Prompt.
>
> ```bash theme={null}
> scripts/render.sh --agent cursor --target-os windows \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o cursor-hooks.json
> ```

> [tab] Claude Code
>
> Generate `settings.json` for a user installation, Linux managed settings, or Windows deployment.
>
> ```bash theme={null}
> scripts/render.sh --agent claude \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o claude-settings.json
> ```
>
> For Windows, add `--target-os windows`.
>
> ```bash theme={null}
> scripts/render.sh --agent claude --target-os windows \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o claude-settings.json
> ```

> [tab] Claude Code macOS profile
>
> Pipe the Claude Code settings through `render-plist.sh` to create a `.mobileconfig` file. Replace the identifier and organization with values for your organization.
>
> ```bash theme={null}
> scripts/render.sh --agent claude \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o - \
> | scripts/render-plist.sh \
>   --identifier com.example.ai-governance.claudecode \
>   --organization "Example Organization" \
>   --name "Claude Code - Endor AI Governance" \
>   -o com.anthropic.claudecode.mobileconfig
> ```

> [tab] Codex
>
> Generate `requirements.toml` with managed hooks for macOS or Linux. Codex trusts hooks from a managed requirements source, so they run without per-user approval. Codex has no managed environment block, so every hook command includes the credentials and `--env` settings inline.
>
> ```bash theme={null}
> scripts/render.sh --agent codex \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o codex-requirements.toml
> ```
>
> For Windows, add `--target-os windows`.
>
> ```bash theme={null}
> scripts/render.sh --agent codex --target-os windows \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o codex-requirements.toml
> ```

> [tab] Codex macOS profile
>
> Pipe the Codex requirements through `render-plist.sh --style mcx` to create a `.mobileconfig` file that delivers the TOML as a managed preference. Replace the identifier and organization with values for your organization.
>
> ```bash theme={null}
> scripts/render.sh --agent codex \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o - \
> | scripts/render-plist.sh --style mcx \
>   --identifier com.example.ai-governance.codex \
>   --organization "Example Organization" \
>   --name "Codex - Endor AI Governance" \
>   -o com.openai.codex.mobileconfig
> ```

> [tab] GitHub Copilot
>
> Generate the policy hook file for macOS or Linux. Copilot has no managed environment block, so every hook command includes the credentials and `--env` settings inline.
>
> ```bash theme={null}
> scripts/render.sh --agent copilot \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o copilot-hooks.json
> ```
>
> For Windows, add `--target-os windows`. The Windows session hook gets a 30-minute timeout because the bootstrap downloads endorctl during session start.
>
> ```bash theme={null}
> scripts/render.sh --agent copilot --target-os windows \
>   --api-key "$ENDOR_API_CREDENTIALS_KEY" \
>   --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
>   --namespace "$ENDOR_NAMESPACE" \
>   -o copilot-hooks.json
> ```

### Configure optional behavior

The generator enables the local response cache by default. Add `--env ENDOR_AI_AUDIT_NO_BLOCKING=true` to evaluate and record actions without blocking them.

```bash theme={null}
scripts/render.sh --agent cursor \
  --api-key "$ENDOR_API_CREDENTIALS_KEY" \
  --api-secret "$ENDOR_API_CREDENTIALS_SECRET" \
  --namespace "$ENDOR_NAMESPACE" \
  --env ENDOR_AI_AUDIT_NO_BLOCKING=true \
  -o cursor-hooks.json
```

Add `--skip-endorctl-update` if you provision endorctl separately and don't want the hook to check for updates when a session starts.

## Deploy the generated configuration

Deliver the generated file through your MDM or configuration management tool.

### Deploy Cursor hooks

Deliver `cursor-hooks.json` to the location that matches your deployment:

* For a local trial, copy `cursor-hooks.json` to `~/.cursor/hooks.json`.
* On managed macOS machines, deliver it to `/Library/Application Support/Cursor/hooks.json`.
* On managed Linux machines, deliver it to `/etc/cursor/hooks.json`.
* On Windows, push `cursor-hooks.json` to `C:\ProgramData\Cursor\hooks.json` with your MDM tool.

See [Deploy hooks for Cursor](https://docs.endorlabs.com/agent-governance/cursor.md) to verify the installation and review the registered hook events.

### Deploy Claude Code settings

Deliver the generated Claude Code configuration to the location that matches your deployment:

* For a local trial, copy `claude-settings.json` to `~/.claude/settings.json`.
* On managed Linux machines, deliver it to `/etc/claude-code/managed-settings.json`.
* On Windows, push `claude-settings.json` to `C:\Program Files\ClaudeCode\managed-settings.json` with your MDM tool.
* On managed macOS machines, upload `com.anthropic.claudecode.mobileconfig` as a custom profile.

See [Deploy hooks for Claude Code](https://docs.endorlabs.com/agent-governance/claude-code.md) to verify the installation and review the registered hook events.

#### Check a Claude Code macOS profile

Run these checks on a Mac, because `plutil` ships only with macOS. The commands assume the default payload type, `com.anthropic.claudecode`. If you set a custom payload type, replace that value in the profile file name and the managed-preference path. The browser generator names the profile `<payload-type>.mobileconfig`, and macOS installs it as `/Library/Managed Preferences/<payload-type>.plist`.

1. Confirm that the profile is a valid property list, has no Windows (CRLF) line endings, and has a `SessionStart` hook that parses as shell.

   ```bash theme={null}
   plutil -lint com.anthropic.claudecode.mobileconfig
   grep -c $'\r' com.anthropic.claudecode.mobileconfig      # must print 0
   plutil -extract 'PayloadContent.0.hooks.SessionStart.0.hooks.0.command' raw -o - \
     com.anthropic.claudecode.mobileconfig | sh -n           # must print nothing
   ```

   A Windows checkout, an editor, or a paste into a web form can add CRLF line endings, and `plutil -lint` still accepts the file. The generated hook strips carriage returns when it runs, so CRLF line endings alone don't break it. A nonzero count still means that something changed the file after generation, so generate it again.

2. Upload the generated file itself to your MDM. Don't open it in an editor or paste its contents.

3. If your MDM lets you download the uploaded profile, run the step 1 checks on the downloaded copy.

4. On a test Mac that has the profile installed, confirm that the managed preference contains the complete hook. The check extracts the exact command that Claude Code runs and must print nothing.

   ```bash theme={null}
   plutil -extract 'hooks.SessionStart.0.hooks.0.command' raw -o - \
     '/Library/Managed Preferences/com.anthropic.claudecode.plist' | sh -n
   ```

5. On the same test Mac, confirm that the managed preference still contains the Endor Labs credentials. macOS combines every profile with the same payload type into this one file and keeps only one `env` block.

   ```bash theme={null}
   plutil -p '/Library/Managed Preferences/com.anthropic.claudecode.plist'
   sudo profiles show -type configuration | grep -B4 -A2 anthropic
   ```

   Check the output against these conditions:

   * The `plutil` output must list `AGENT_HOOK_ENDOR_API`, `AGENT_HOOK_ENDOR_NAMESPACE`, `AGENT_HOOK_ENDOR_API_CREDENTIALS_KEY`, and `AGENT_HOOK_ENDOR_API_CREDENTIALS_SECRET` under `env`.
   * The `profiles` output lists every installed profile with this payload type. More than one profile means that another product, for example a developer analytics tool, also configures Claude Code.

   If the `AGENT_HOOK_ENDOR_*` keys are missing, another profile replaced the `env` block. The Endor Labs hooks then run without credentials and send nothing, with no error. Combine both payloads into one profile, and repeat this step after every push of either profile.

6. Start a Claude Code session on the test Mac. If endorctl isn't installed yet, the `SessionStart` hook installs it to `~/.endorctl/endorctl` in the background and skips its own audit.

7. In that session, run `/status`. The **Setting sources** line must include `plist`. For example, `Enterprise managed settings (plist)`.

   Another managed source, such as `(remote)`, can take priority. Claude Code then skips the profile, and the Endor Labs hooks don't run. The profile appears on the **Skipped sources** line instead.

   To fix this, deliver the Endor Labs settings through the source that wins. On Claude Code v2.1.242 or later, you can instead set `managedSourcesBehavior` to `"merge"` in that source. Claude Code then applies both sources, and the line ends in `, merged`.

   Merge also applies hooks and `permissions.allow` rules from every lower source. Use it only if an administrator controls each one.

8. If the hook installed endorctl in step 6, start a second session after `~/.endorctl/endorctl` exists.

9. Confirm that the session activity reaches Endor Labs. See [Verify hooks are firing](https://docs.endorlabs.com/agent-governance/claude-code.md#verify-hooks-are-firing) to check for recent activity in the inventory.

10. Assign the profile to the rest of your fleet.

### Deploy Codex requirements

Deliver the generated Codex configuration to the location that matches your deployment:

* On managed macOS and Linux machines, deliver `codex-requirements.toml` to `/etc/codex/requirements.toml`.
* On managed macOS machines, you can instead upload `com.openai.codex.mobileconfig` as a custom profile.
* On Windows, push `codex-requirements.toml` to `%ProgramData%\OpenAI\Codex\requirements.toml` with your MDM tool.

See [Deploy hooks for Codex](https://docs.endorlabs.com/agent-governance/codex.md) to verify the installation and review the registered hook events.

### Deploy Copilot policy hooks

Deliver `copilot-hooks.json` to Copilot's policy directory. Copilot treats that directory as administrator policy. Hooks there ignore `disableAllHooks` and run regardless of folder trust. Only the Copilot CLI reads the policy level.

Deliver the file to the location that matches your deployment:

* For a local trial, copy `copilot-hooks.json` to `~/.copilot/hooks/endor.json`. Both the Copilot CLI and VS Code agent mode read that directory, but a developer can edit it.
* On managed macOS and Linux machines, deliver it to `/etc/github-copilot/policy.d/endor.json`, owned by root with mode `0644`.
* On Windows, push it to `C:\ProgramData\GitHub\Copilot\policy.d\endor.json` with your MDM tool.

See [Deploy hooks for GitHub Copilot](https://docs.endorlabs.com/agent-governance/copilot.md) to verify the installation and review the registered hook events.

## Update a deployment

The session hook installs endorctl on first use and checks for a newer version on later session starts. It verifies every downloaded binary with SHA-256.

On macOS and Linux, the hook never waits for the download. It hands the install or update to a background job and audits with the binary already on disk. If endorctl isn't installed yet, the hook skips the audit. On Windows, the hook downloads endorctl during session start.

The version check runs at most once a day. Set `ENDORCTL_UPDATE_TTL_MINUTES` in the configuration's environment variables to change that interval.

Regenerate and redeploy the configuration when you change credentials, environment variables, or delivery settings. Server-side Coding Agent Governance policy changes don't require a new configuration.

Older Claude Code settings and profiles for macOS and Linux don't strip CRLF line endings from the session hook. If a macOS profile with that hook picks up CRLF line endings, its session hook breaks. A file needs updating if its `SessionStart` command doesn't start with `eval "$(printf`. Regenerate and redeploy those files.

## Keep a fleet current with the scheduled runner

The [mdm-scripts repository](https://github.com/endorlabs/mdm-scripts/tree/main/agent-governance) also provides `scripts/runner.sh`, which replaces one-shot generation with a self-updating deployment on macOS and Linux. Paste it into your MDM as a recurring script body, such as a Jamf script, a Kandji Custom Script, or a JumpCloud Command. Edit the settings block at the top to pick the agent (`cursor`, `claude`, `codex`, or `copilot`) and pin a reviewed revision.

On each run it fetches the repository at that revision, renders the configuration on the endpoint, and replaces the installed file in one step, only when the result changed. Credential and flag changes then roll out on the next scheduled run without a redeploy. To pick up repository changes, update the pinned revision in the script.

The runner has these requirements and limits:

* The MDM must set `ENDOR_API_CREDENTIALS_KEY`, `ENDOR_API_CREDENTIALS_SECRET`, and `ENDOR_NAMESPACE` in the script's environment. Use an API key with the **AI Audit User** role.
* Endpoints need only `curl` and `tar`, which come with macOS and Linux.
* For `copilot`, the runner writes `/etc/github-copilot/policy.d/endor.json` and creates the directory if needed.
* Windows does not use the runner. Pre-generate the configuration and push it with Intune or your MDM tool.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.