Skip to content
mentoor

Topic 3 of 4 · 4 min read

Enforcing organisation policy on coding agents

Goal: Review a managed policy for coding agents and find the gap that lets a user bypass an approval or connect an unapproved server.

Managed policy is the part of agent configuration that engineers cannot change, so use it only for the few rules that must hold everywhere, and check every rule for the loophole that routes around it.

Check yourself · 1 of 3

Why put a rule in managed settings rather than the committed project file?

Choose one answer

Why it matters

A shared project file is a team default. An engineer can override most of it locally. That is fine for a theme and not fine for "never skip approvals" or "only connect to approved tool servers". For rules the organisation must be able to prove, you need the top tier of the settings stack. In Claude Code that is managed settings, delivered from the admin console, by MDM, or as a file in a system directory such as /etc/claude-code/ on Linux. Server-managed delivery reaches machines without device management, and device-level delivery is harder for a user to tamper with.

What a policy usually covers

  • Permission modes: turn off the mode that skips approval prompts (disableBypassPermissionsMode).
  • Permission rules: require that only managed rules count (allowManagedPermissionRulesOnly), or merge your deny rules with the user's allow rules.
  • MCP servers: an allow list and a deny list of servers (allowedMcpServers, deniedMcpServers).
  • Hooks and plugins: limit hooks to managed ones (allowManagedHooksOnly) and limit which marketplaces may be added (strictKnownMarketplaces).
  • Telemetry and sign-in: force usage data to your own collector, and require company sign-in.

How to review a policy

For each rule ask: "What is the other route to the same outcome?" Then look for that route.

  1. List the outcome you want (no unapproved servers, no skipped approvals).
  2. List every way a user could reach it: a project file, a local file, a plugin that ships a server, a command-line flag.
  3. Check that the policy closes each one. Locking one door leaves the others.
  4. Check the failure mode: if the policy cannot be fetched, does the agent start without it? Server-managed settings have a setting to fail closed.

Before and after

Weak policy: disableBypassPermissionsMode is set, but a user can still add an MCP server in their project file, and the server's tools run with the allow rules the user wrote locally.

Fixed: add an MCP allow list, restrict the marketplaces, and require managed permission rules, so a local file cannot add a server or an allow rule that the policy did not approve.

What goes wrong

  • A deny rule for one command, while the same effect is available through a different command.
  • A policy delivered only to laptops, so cloud sessions run without it. Check which delivery reaches which environment.
  • Settings are fetched at start, but a failed fetch lets sessions run unmanaged, and nobody notices.

Examples

Finding the gap in a policy

Policy clauses:

  1. Bypass mode is disabled.
  2. Telemetry goes to the company collector.
  3. Allowed MCP servers: the issue tracker and the docs server.

Gap: nothing limits plugin marketplaces. An engineer adds a public marketplace, installs a plugin that ships its own server, and the server's tools reach the agent. Fix: restrict marketplaces to the team catalogue and make the server allow list apply to plugin-provided servers.

Choosing delivery

A company has managed laptops and also runs agent sessions in cloud environments. Device-level files cover the laptops but do not reach the cloud sessions, so the admin also configures server-managed settings and sets the option that stops sessions from starting without a fresh policy.

Key points

  • Managed settings sit above user, project and local files, so they are the place for rules that must hold on every machine.
  • A policy can turn off approval-skipping modes, restrict MCP servers, limit hooks and marketplaces, and require company sign-in.
  • Review each rule by asking for the other route to the same outcome, then check that the policy closes it.
  • Different delivery methods reach different places, so confirm that cloud and local sessions both receive the policy.
  • Decide what happens when the policy cannot be fetched: failing open leaves machines unmanaged without anyone noticing.

Common mistakes

  • Locking one route, such as approvals, and leaving plugins, servers or hooks open.
  • Putting team preferences in managed settings, so engineers cannot adjust harmless things and start working around the agent.
  • Assuming the policy reached every environment without testing a cloud session and a fresh machine.
  • Letting a failed policy fetch fall back to no policy without an alert.

Check yourself · 2 of 3

A policy disables the mode that skips approval prompts. It sets no MCP server rules. What risk remains?

Choose one answer

Check yourself · 3 of 3

Policy fetching fails on a laptop and the agent starts anyway with no remote policy. What should an admin consider?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic