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
giton the admin machine. The scripts run with system tools only. Creating a macOS configuration profile also requires macOS andplutil.
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.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.
- Cursor
- Claude Code
- Claude Code macOS profile
- Codex
- Codex macOS profile
- GitHub Copilot
Generate For Windows, add
hooks.json for macOS or Linux. Cursor has no managed environment block, so every hook command includes the credentials and --env settings inline.--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.
--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
Delivercursor-hooks.json to the location that matches your deployment:
- For a local trial, copy
cursor-hooks.jsonto~/.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.jsontoC:\ProgramData\Cursor\hooks.jsonwith your MDM tool.
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.jsonto~/.claude/settings.json. - On managed Linux machines, deliver it to
/etc/claude-code/managed-settings.json. - On Windows, push
claude-settings.jsontoC:\Program Files\ClaudeCode\managed-settings.jsonwith your MDM tool. - On managed macOS machines, upload
com.anthropic.claudecode.mobileconfigas a custom profile.
Check a Claude Code macOS profile
Run these checks on a Mac, becauseplutil 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.
-
Confirm that the profile is a valid property list, has no Windows (CRLF) line endings, and has a
SessionStarthook that parses as shell.A Windows checkout, an editor, or a paste into a web form can add CRLF line endings, andplutil -lintstill 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. - Upload the generated file itself to your MDM. Don’t open it in an editor or paste its contents.
- If your MDM lets you download the uploaded profile, run the step 1 checks on the downloaded copy.
-
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.
-
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
envblock.Check the output against these conditions:- The
plutiloutput must listAGENT_HOOK_ENDOR_API,AGENT_HOOK_ENDOR_NAMESPACE,AGENT_HOOK_ENDOR_API_CREDENTIALS_KEY, andAGENT_HOOK_ENDOR_API_CREDENTIALS_SECRETunderenv. - The
profilesoutput 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.
AGENT_HOOK_ENDOR_*keys are missing, another profile replaced theenvblock. 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. - The
-
Start a Claude Code session on the test Mac. If endorctl isn’t installed yet, the
SessionStarthook installs it to~/.endorctl/endorctlin the background and skips its own audit. -
In that session, run
/status. The Setting sources line must includeplist. 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 setmanagedSourcesBehaviorto"merge"in that source. Claude Code then applies both sources, and the line ends in, merged. Merge also applies hooks andpermissions.allowrules from every lower source. Use it only if an administrator controls each one. -
If the hook installed endorctl in step 6, start a second session after
~/.endorctl/endorctlexists. - Confirm that the session activity reaches Endor Labs. See Verify hooks are firing to check for recent activity in the inventory.
- 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.tomlto/etc/codex/requirements.toml. - On managed macOS machines, you can instead upload
com.openai.codex.mobileconfigas a custom profile. - On Windows, push
codex-requirements.tomlto%ProgramData%\OpenAI\Codex\requirements.tomlwith your MDM tool.
Deploy Copilot policy hooks
Delivercopilot-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.jsonto~/.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 mode0644. - On Windows, push it to
C:\ProgramData\GitHub\Copilot\policy.d\endor.jsonwith your MDM tool.
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. SetENDORCTL_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 providesscripts/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, andENDOR_NAMESPACEin the script’s environment. Use an API key with the AI Audit User role. - Endpoints need only
curlandtar, which come with macOS and Linux. - For
copilot, the runner writes/etc/github-copilot/policy.d/endor.jsonand creates the directory if needed. - Windows does not use the runner. Pre-generate the configuration and push it with Intune or your MDM tool.