Skip to main content
The command endorctl ai-audit processes AI coding agent hook events for Coding Agent Governance. You do not run it interactively. A hook configuration installed on a developer machine invokes it once per hook event. The agent passes the event as JSON on standard input, and the command writes the agent-specific response, such as an allow or deny decision, to standard output. See Deploy hooks for Cursor, Claude Code, Codex, and GitHub Copilot to install the hook configurations that run this command.

Usage

Each supported agent has a subcommand that understands that agent’s hook payload format.
A typical hook configuration entry runs the command with explicit connection flags.

Authentication

endorctl ai-audit authenticates with an API key and secret issued for the AI Audit User role. See Prerequisites for Coding Agent Governance to create the key. Unlike other endorctl commands, ai-audit ignores ENDOR_TOKEN when API key credentials are present, so hooks keep working in shells that already exported a token. Older versions of endorctl failed on the mixed credentials, so don’t export ENDOR_TOKEN in the hook environment. See endorctl exit codes for the related authentication failure.

Behavior

The command has the following runtime behavior:
  • Local policy evaluation: The command evaluates each event against the policy snapshot in ~/.endorctl/aigovernance/endor-policies.jsonl. The snapshot refreshes from your namespace at session start, so pattern-based enforcement needs no network round-trip per event. Malware policies are the exception, querying the malware feed per matching install. See Local policy cache.
  • Fails open: If the command cannot run, or cannot reach the Endor Labs API for a malware verdict, it allows the action rather than blocking the agent. An unparseable policy snapshot falls back to the built-in system policies.
  • Bounded latency: Each invocation limits itself to 5 seconds, then fails open, so a backend outage cannot stall the agent.

Environment variables

For an audit-only rollout, set ENDOR_AI_AUDIT_NO_BLOCKING=true in the environment of the hook, as shown in the deploy configuration for each agent. It downgrades every Block action to Alert at evaluation time, so policies record violations without denying actions. The following pages cover the feature this command serves: