Skip to main content
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 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.
  • 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. The generator never sends your API key, secret, namespace, or environment variable values 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

The Endor Labs MDM scripts repository is the authoritative source for the generator scripts. Clone the repository on an admin machine.
Set your credentials as environment variables. The generator reads these exact variable names, and prompts for any missing credential when you run it interactively.
To use an API URL other than https://api.endorlabs.com, add --api-url <api-url> to the scripts/render.sh command. Generate the configuration that matches your coding agent and deployment method.
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.
Generate hooks.json for macOS or Linux. Cursor has no managed environment block, so every hook command includes the credentials and --env settings inline.
For Windows, add --target-os windows. The generated hook uses an encoded PowerShell command that can run from Git Bash, PowerShell, or Command Prompt.

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.
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.
Deploy cursor-hooks.json exactly as generated. The generator writes every / in the macOS and Linux file as \/, which the Cursor IDE and the Cursor CLI both read as /. A JSON formatter such as jq rewrites \/ back to /, and the Cursor CLI then loads no hooks from that file. See Deploy hooks for Cursor to verify the installation and review the hook events that Coding Agent Governance processes.

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 to verify the installation and review the hook events that Coding Agent Governance processes.

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.
    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.
  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.
    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 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 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 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 downloads endorctl from the API URL in the configuration and 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. Older Claude Code settings and profiles also have no ConfigChange hook. Regenerate and redeploy them so the hook runs when a Claude Code configuration file changes. Older Cursor hooks.json files for macOS and Linux contain https:// in their commands, and the Cursor CLI loads no hooks from them. A current file contains https:\/\/ instead. Regenerate and redeploy the older files. Older configurations download endorctl from https://api.endorlabs.com, whatever API URL they hold. If your tenant uses another API URL, regenerate and redeploy them.

Keep a fleet current with the scheduled runner

The mdm-scripts repository 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.