> ## 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.

# How Coding Agent Governance works

> Understand how hook events from your AI coding agents flow into the Endor Labs inventory, policies, and overview.

Coding Agent Governance gives security and engineering teams visibility and control over how AI coding agents work inside your organization. Endor Labs collects events from agents, builds an inventory of your developers' AI use, and applies your policies to risky activity in real time.

Use Coding Agent Governance to answer questions such as:

* Which AI coding agents and MCP servers are running on developer machines?
* Are agents reading sensitive files, executing dangerous commands, or talking to unapproved MCP servers?
* When a policy fires, what was the developer trying to do, and which agent was responsible?

Coding Agent Governance has the following components:

* Hooks that run on developer machines and capture events.
* Coding Agent Governance policies that govern these events.
* Dashboards that show what your agents are doing.

Together, these components let you control and view the activities of AI agents across your organization.

## What Coding Agent Governance is (and isn't)

Coding Agent Governance puts guardrails around what coding agents do so it can catch accidental or unintended actions before they cause damage. It reduces the chance an agent does something it shouldn't while working through a task.

It is not a sandbox, firewall, or hardened security boundary. Policy controls lower risk and limit the damage of agent mistakes, but they do not guarantee that a risky action is impossible. Hard guarantees require isolation at the operating system, system call, or sandbox level.

Coding Agent Governance works alongside that kind of isolation. It does not replace it.

Coding Agent Governance targets accidental agent behavior. It is not designed to stop a determined developer who deliberately tries to defeat the controls.

## Lifecycle of an event

When a developer starts a session, an Endor Labs hook runs alongside the agent and emits a normalized event for every meaningful action. Each event includes the agent type, the user, the workspace context, and the tool, command, or file the agent acted on.

The event takes two paths in parallel:

* Local evaluation: The hook checks the event against a cached copy of Coding Agent Governance policies. If a policy matches, the hook can stop the action, record the event for your security team, or ask the developer to approve it. See [Enforcement behavior](#enforcement-behavior) to review where each agent can pause.
* Centralized aggregation: The hook forwards the event to Endor Labs, where it updates the inventory, the Coding Agent Governance overview, and the policy violation log.

Together, these paths enforce policies on developer machines in real time and give your security team a single place to monitor activity and plan their response. As your AI agent inventory evolves, your security team can refine policies and roll out changes.

The following diagram shows the data flow in Coding Agent Governance.


&#x20; %%motion
&#x20; callouts: on
&#x20; list: off
&#x20; speed: 0.5
&#x20; %%
&#x20; %%steps
&#x20; A, s1, B | A coding agent takes an action, and the Endor Labs hook intercepts it before the action runs.
&#x20; s2, C | The hook evaluates your policies locally on the developer machine.
&#x20; s3, D | The policy decides whether to block the action, alert, ask for permission, or allow it.
&#x20; e1, e2, e3, E, F, G \{effect: draw} | The hook sends event metadata to Endor Labs, where it appears in inventory, overview, and policy violations.
&#x20; %%
&#x20; flowchart TD
&#x20;   subgraph Dev\[Developer machine]
&#x20;       A\[Coding agent action] s1\@--> B\[Endor Labs hook]
&#x20;       B s2\@--> C\[Local policy evaluation]
&#x20;       C s3\@--> D\[Block / Alert / Ask Permission / Allow]
&#x20;   end
&#x20;   subgraph Endor\[Endor Labs]
&#x20;       E\[Inventory]
&#x20;       F\[Overview]
&#x20;       G\[Policy Violations]
&#x20;   end
&#x20;   B e1\@-->|Event metadata| E
&#x20;   B e2\@-->|Event metadata| F
&#x20;   B e3\@-->|Event metadata| G
&#x20;   click E href "/agent-governance/inventory" "Review your agent inventory"
&#x20;   click F href "/agent-governance/overview" "Coding Agent Governance overview"
&#x20;   click G href "/agent-governance/policy-violations" "Triage policy violations"
&#x20;&#x20;

## Hooks and what they govern

A hook is a small script Endor Labs deploys to your developers' machines. It runs whenever the agent starts a session, submits a user prompt, calls an MCP tool, runs a shell command, or reads, writes, or deletes a file. For each event, the hook can apply a policy locally before the agent acts.

Hooks enforce guardrails such as blocking dangerous commands or gating MCP tool use. They are instruction-based controls that the agent and host follow, not a tamper-proof runtime.

You can write policies for the following activities:

* Shell commands the agent tries to run, matched by regex.
* File reads, writes, deletes, and edits, matched by regex on the file path.
* MCP server and tool calls, matched by regex on server name and tool name.
* Shell commands reviewed by the [AI judge](#how-the-ai-judge-reviews-commands), when you turn it on.
* Package installs and manifest or lockfile edits, checked against the Endor Labs malware feed.
* New dependencies, checked against Endor Labs vulnerability data for known vulnerabilities.
* File content the agent writes or reads, scanned for secrets.

The malware, dependency risk, and secrets checks have no patterns to write. Their verdict comes from Endor Labs data. See [Secure coding checks](https://docs.endorlabs.com/agent-governance/secure-coding.md) to review how each check reaches a verdict.

When a policy matches, the hook applies the action you chose:

* **Block** stops the action and returns a deny response. If the agent hook response can carry the message, it tells the agent that a governance policy denied the action, and not to work around the block.
* **Alert** logs the event without stopping the agent.
* **Ask Permission** pauses for the developer to approve or deny, where the agent supports it. See [Enforcement behavior](#enforcement-behavior) to review the per-agent behavior.
* **AI Judged** hands a matched shell command to the [AI judge](#how-the-ai-judge-reviews-commands), which allows, asks, or blocks it.

See [Write a policy](https://docs.endorlabs.com/agent-governance/policies.md) to build allowlists and blocklists and to override built-in system policies.

## How the AI judge reviews commands

Pattern policies decide on the developer's machine. When you turn on the AI judge, the hook also asks Endor Labs to label shell commands as benign, review, or suspicious. A review label asks the developer to confirm, and a suspicious label blocks.

The judge runs only after you turn it on, with an auto mode policy whose **Judge Scope** is not **Off** or with a policy that uses the **AI Judged** action. When it runs, the hook sends the command and your deployment context to Endor Labs, which asks a large language model (LLM) for a label and a reason.

Judging changes the hook's behavior in the following ways:

* The hook has up to 10 seconds per event in a namespace with judging turned on, instead of 5 seconds. The judge gets up to 8 seconds, keeping 2 seconds to record the event. The hook skips the judge when less than 5 seconds would remain for it.
* If the judge errors, times out, or is skipped, the command falls back to its pattern policies. A match from an **AI Judged** policy has no pattern action, so the hook releases it.
* **Governance** policies keep their action whatever the judge decides.
* Endor Labs records each judgment on the event, including failed and skipped ones.

See [Auto mode and the AI judge](https://docs.endorlabs.com/agent-governance/policies.md#auto-mode-and-the-ai-judge) to turn on the judge and review how each label maps to an outcome.

## Example: A blocked malicious package install

The following session shows the lifecycle end to end. A developer asks a coding agent to install an npm package. The hook checks the install against a malware policy on the developer's machine. The block stops the install before any package code runs.

```text theme={null}
> Run this command in non-interactive mode: npm install plugin-proposal-json-strings

  I'll check what this package actually is before installing. The name looks like
  an unscoped variant of @babel/plugin-proposal-json-strings.

  Bash(npm view plugin-proposal-json-strings --json)
    The only remaining version is 0.0.1-security, described as a "security holding
    package" from npm/security-holder. The purged version history (99.10.9, 9.9.9,
    8.0.11) is a dependency-confusion pattern.

  Bash(npm install plugin-proposal-json-strings)
    Error: [ENDOR LABS SECURITY POLICY BLOCK] This action was identified as an
    install of a known-malicious or untrusted software package. malware detected in
    npm package "plugin-proposal-json-strings" (flagged by MALWARE_SOURCE_OSV).
    Endor Labs flagged this package as known-malicious. Do not install the flagged
    package. If the dependency is genuinely needed, choose a non-flagged, safe
    version or a different well-known package, or ask the user. Do not try to
    install the same package by another route (a different registry, a direct
    download, renaming, or --force) or by disabling this check — that is treated as
    an evasion.
    Tell the user this was blocked by the Endor Labs policy "Malware: block
    installs of known-malicious packages".

  The install was blocked, and I'm not going to attempt it another way. npm install
  plugin-proposal-json-strings was blocked by the Endor Labs policy "Malware: block
  installs of known-malicious packages". The package was flagged as known-malicious
  (MALWARE_SOURCE_OSV). The package you probably want is the scoped Babel one,
  @babel/plugin-proposal-json-strings.
```

The example shows four things about how enforcement behaves:

* The hook evaluated the install at the moment the agent ran it, so no package code executed. Nothing depended on the agent choosing to check the package first.
* The verdict came from the Endor Labs malware feed rather than a pattern someone authored. See [Malware check](https://docs.endorlabs.com/agent-governance/secure-coding.md#malware-check) to review the feed each verdict comes from.
* The deny response names the denied action category, the evidence, the feed source, and the policy that fired. It instructs the agent not to route around the block or disable the check. The agent stopped and reported the block instead of retrying with a different registry or `--force`.
* The event reached **Policy Violations** with the package, ecosystem, and feed source alongside the agent and user, so your security team sees the attempt even though the install never ran.

## Data sent to Endor Labs

Each hook event includes the metadata Endor Labs needs for inventory and policy evaluation:

* Agent name, version, and (where available) model
* Session and sub-session IDs
* Device (endpoint) identifier
* Session configuration, such as permission mode and sandbox state
* User identifier when the agent provides one
* Repository name (not populated for Claude Code sessions) and working directory
* MCP server name, tool name, and call counts
* Shell command line (regex-matched against your policies)
* File path and operation type (read, write, delete, edit)
* Secrets check match (rule, line, column, and fingerprint, never the secret value)
* Policy match outcome and the action applied

### Secret redaction

Endor Labs runs every command line, file path, URL, environment value, and MCP tool input or output through a regex-based redactor before it leaves the developer's machine. Environment variables and keys named like a secret (such as `TOKEN`, `SECRET`, `API_KEY`, `PASSWORD`, or `AUTHORIZATION`) become `[REDACTED]`. The redactor also matches common secret formats in place. These include URL and database-connection credentials, AWS access keys, JWTs, PEM private keys, and provider tokens such as GitHub (`ghp_*`), OpenAI, and Anthropic keys.

Redaction of event payloads uses regex pattern matching that can miss some secrets. A secret that does not match a known pattern or key name can still reach the backend. The [secrets check](https://docs.endorlabs.com/agent-governance/secure-coding.md) is separate from redaction: it detects secrets in file content on the developer's machine, and its violations include the rule and location, never the value. When an enabled secrets policy detects a secret, Endor Labs also scrubs the detected string from the stored event payload. The follow-up event recorded after a permitted file operation includes no file content.

> [!WARNING]
>
> On Cursor, the `sessionStart` hook returns the Endor Labs credential values to Cursor in plaintext under an `AGENT_HOOK_ENDOR_*` prefix, so subsequent hooks in the session inherit them. The values never leave the developer's machine, but anything that captures Cursor hook stdout (such as debug logging or screen recording) can see them.

The hook writes two Coding Agent Governance files to a developer's disk. It refreshes the local policy cache (`~/.endorctl/aigovernance/endor-policies-<namespace>.jsonl`) at session start.

The recommended Cursor and Claude Code configurations also enable the event cache at `~/.endorctl/aigovernance/localdb/cache-<namespace>.db`. The hook queues events there and sends them to Endor Labs in batches within about 30 seconds of hook activity. The hook also sends every queued event at session start and end.

## What you see in Endor Labs

After you deploy hooks and at least one policy exists, select **Agent Governance** from the left sidebar:


&#x20; \- Sub-drawer entry: Overview
&#x20; What it shows: Counts of developers using AI, distinct coding agents in use, developers with a sandbox gap, and policy violations over a chosen time range.
&#x20; \- Sub-drawer entry: Inventory
&#x20; What it shows: Five tabs with usage counts and recent activity. Workstation Inventory lists each agent your developers run, and MCP Servers lists the servers your agents called. AI Models lists the models invoked through agents, and Skills lists the skills your agents loaded. Sandboxing shows whether each developer runs agents inside a sandbox.
&#x20; \- Sub-drawer entry: Policy Violations
&#x20; What it shows: A filterable feed of every event that matched a policy, with the agent, the user, and the action Endor Labs took.
&#x20;&#x20;

Policies live with the rest of your platform policies. To open them, select **User menu** > **Policies & Rules** from the left sidebar, then select **Agent Governance**.

## Limitations of Coding Agent Governance

Coding Agent Governance currently has the following limitations.

### Platform and agent coverage

Coverage has the following boundaries:

* Hooks run on macOS, Linux, and Windows developer machines. Hooks do not run on CI runners. See [Supported agents and platforms](https://docs.endorlabs.com/agent-governance.md#supported-agents-and-platforms) to review the full matrix.
* Policy enforcement covers Cursor, Claude Code, Codex, GitHub Copilot, and Snowflake Cortex Code. At session start, Endor Labs still discovers other AI tools, such as Continue, Cody, Gemini CLI, and Amazon Q. They appear in the **Workstation Inventory** table with a **Discovered • Not governed** status, and no hook fires for them.

### Enforcement behavior

Keep the following enforcement behaviors in mind:

* Policy edits take effect at the next session start on a developer's machine, when the hook refreshes the local policy cache. Tell developers to restart the agent to pick up policy changes.
* A hook problem never blocks a developer. If the hook cannot run, or a malware or dependency risk policy cannot reach the Endor Labs API for a verdict, the action proceeds. An unreadable local policy cache does not disable enforcement, because the hook falls back to the built-in system policies. When the hook cannot run, the agent and the IDE keep working, but the event is missing from inventory and policy violations until you fix the cause.
* In Claude Code, **Ask Permission** pauses for approval at `PreToolUse`. At `SessionStart`, Claude Code cannot prompt, so an **Ask** policy ends the session and shows the reason instead. See [Deploy hooks for Claude Code](https://docs.endorlabs.com/agent-governance/claude-code.md) to review its hook events.
* In Cursor, **Ask Permission** pauses for approval on shell commands and MCP tool calls. On file reads and on Cursor's own `preToolUse` hook, Cursor accepts only allow or deny, so an **Ask** policy denies the call. At session start, Cursor also ends the session instead of pausing. See [Deploy hooks for Cursor](https://docs.endorlabs.com/agent-governance/cursor.md) to review its hook events.
* In Codex, an **Ask Permission** policy cannot pause a tool call. The call proceeds, the developer sees the **User Message**, and the model receives it as a confirmation instruction. Only **Block** denies a tool call, and at Codex's own approval prompts an **Ask** policy defers to that prompt. At `SessionStart`, Codex cannot prompt, so an **Ask** policy ends the session and shows the reason. See [Deploy hooks for Codex](https://docs.endorlabs.com/agent-governance/codex.md) to review its Ask behavior at each hook event.
* In GitHub Copilot, **Ask Permission** prompts in VS Code agent mode only. The Copilot CLI acts on deny but ignores ask, so an **Ask** policy on a CLI session proceeds and appears under **Policy Violations**, the same way **Alert** behaves. At session start, Copilot does not block, so a matched policy shows as a governance notice in the session instead. See [Deploy hooks for GitHub Copilot](https://docs.endorlabs.com/agent-governance/copilot.md) to review its Ask behavior in VS Code and in the CLI.
* In Snowflake Cortex Code, **Ask Permission** shows Cortex Code's own permission prompt at `PreToolUse`, without the reason from the policy. A **Block** policy denies the tool call and shows the reason. At `SessionStart`, Cortex Code doesn't stop the session, so a matched session policy only records the violation. See [Deploy hooks for Snowflake Cortex Code](https://docs.endorlabs.com/agent-governance/cortex-code.md#enforcement-behavior) to review how its tools map to policies.
* Policies match commands and patterns, not the end effect. An agent can occasionally reach the same result another way. That trade-off comes with pattern-based controls that can miss some cases.

### Attribution and visibility

Attribution has the following gaps:

* User attribution appears when the agent's hook payload includes a user identifier. Cursor supplies one on most events. Claude Code, Codex, and GitHub Copilot attempt to derive one from the local environment and may succeed depending on the version and configuration, but the value can still be empty. Snowflake Cortex Code reports `ENDOR_ACTOR` when set, otherwise the operating system login. The **User** column on **Policy Violations** and the user count on the **Overview** stay empty for events without an identifier.
* endorctl captures device (endpoint) attribution on every event, but Coding Agent Governance does not show it in the user interface. You cannot filter or scope inventory or policy violations by device.
* Claude Code sub-agent activity may have no user identity, and the hook does not record sub-agent MCP tool calls that a policy cleanly allows. Policies still evaluate and enforce on sub-agent activity.

### Inventory and scoring

Inventory and scoring have the following limits:

* Endor Labs computes MCP server risk scores only for servers it finds in an agent's configuration files. A server invoked without a discoverable configuration entry can appear in inventory from its tool calls without a score.
* Endor Labs discovers MCP servers that enabled Claude Code plugins contribute, from the installed-plugin registry (`~/.claude/plugins`) and from skills-directory plugins. Each server appears in inventory under the name Endor Labs derives from its runtime, the command binary or URL host. When it cannot derive one, the name falls back to `<plugin>/<server>`.
* Endor Labs attributes each plugin-contributed server to the level that installed the plugin. It does not inventory disabled plugins or marketplace plugins that are not installed locally.
* Endor Labs does not assess agent plugins as a single unit. It evaluates the MCP servers and skills a plugin contributes, not the plugin itself.
* File access matching is regex-based on path. The [secrets check](https://docs.endorlabs.com/agent-governance/secure-coding.md#secrets-check) adds content-aware secret detection, but Endor Labs does not redact or rewrite the content an agent reads.
* Skills inventory reflects skills discovered in the workspace and user-home directories at session start. Skills loaded at runtime by the agent, or installed outside those directories, might not appear. See [Skills](https://docs.endorlabs.com/agent-governance/inventory.md#skills) to review the exact paths scanned.
* Endor Labs doesn't collect Snowflake Cortex Code skills, or MCP servers and permissions declared at the Cortex Code project level. See [Known limitations](https://docs.endorlabs.com/agent-governance/cortex-code.md#known-limitations) for the other Cortex Code gaps.
* Hooks capture session configuration such as permission mode and sandbox state. Use [Session Posture](https://docs.endorlabs.com/agent-governance/policies.md#session-posture) policies to match sessions by sandbox setting. The inventory has limited client-posture context today.


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