Independent analysis by NHI Mgmt GroupSource article: Dam Secure, “Does Claude Code read AGENTS.md? Why your security rules might not be loading” (November 25, 2026)

TL;DR: AGENTS.md only governs Claude Code when no CLAUDE.md or CLAUDE.local.md is present, according to Dam Secure, so security rules can disappear silently when a local file wins. Instruction loading is context, not enforcement, which makes review and explicit inheritance more important than assuming one shared file covers every session.


At a glance

What this is: NHI Mgmt Group's analysis, drawing on Dam Secure's blog post: Claude Code reads AGENTS.md only conditionally, and local CLAUDE.md files can silently override shared security instructions.

Why it matters: Identity and security teams need deterministic instruction inheritance because coding agents can omit the very rules meant to constrain data access, logging and privileged operations.


Context

AGENTS.md is a project-level instruction file, but it is only reliable when the agent actually loads it. In Claude Code, precedence rules mean a nearby CLAUDE.md or CLAUDE.local.md can suppress the shared file without a warning, which turns instruction governance into a file-discovery problem rather than a simple policy-writing exercise. AI coding agents security guide

That matters because many teams now treat instruction files as the place where security guardrails, data-handling rules and repository-specific access constraints live. If the wrong file wins, the agent may still produce valid code while ignoring controls such as scoped database access or limits on logging sensitive input.

The starting position is typical for teams that assume one shared instruction file will behave consistently across tools, but the failure mode is more subtle: precedence, not intent, decides what the agent sees.


Key questions

Q: How should teams govern shared instructions for coding agents?

A: Teams should govern shared instructions through one documented inheritance model that defines which repository files, local overrides and session prompts are authoritative. That model should specify who can edit each layer, how conflicts are resolved, and how changes are reviewed before agents inherit them. Without that control, coding agents may follow inconsistent instructions across repos and workspaces.

Q: Why do local agent files create governance risk for repository rules?

A: Local agent files create governance risk because they can override central repository rules at the workspace level and vary by developer machine. That makes instruction scope harder to audit, weakens change control, and can let an agent follow stale or unauthorised guidance. Security teams should treat them as governed configuration, with review, versioning and explicit precedence rules.

Q: How does instruction precedence work in Claude Code?

A: Instruction precedence in Claude Code is the order in which layered instruction files are read and applied, so a more specific local file can override broader repository guidance. In practice, CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md represent different scopes that need clear ownership, review and conflict handling so the agent follows the intended rule set.

Q: What should security teams do when agent output ignores written rules?

A: When agent output ignores written rules, teams should treat it as a control failure and inspect the prompt stack, file precedence, tool instructions and model context for conflicts or missing constraints. They should then tighten the governing instruction set, add validation checks, and define a human approval step for high-risk actions or code changes before the agent can proceed.


Technical breakdown

Instruction-file precedence in Claude Code

Claude Code resolves project instructions by checking for CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md before it relies on AGENTS.md. That means the control plane is not a single file, but a precedence chain that changes based on the working directory and any parent folders. A local override can therefore replace shared policy with developer-specific context, even when the team believes the shared file is still active. Read What Is Claude Code? Features, Plans, Surfaces and History.

Practical implication: Treat instruction loading as a governed precedence model, not a single source of truth.

Why security guidance disappears without a warning

The risk is not that the agent cannot read instructions at all. The risk is that the agent reads a different instruction set than the one the security team expected, and the session still succeeds syntactically. In practice, that can leave access-control rules, logging limits or data-handling constraints out of scope for the generated change, even though the code compiles and tests pass.

Practical implication: Assume successful output does not prove the correct instructions were loaded.

Managed inheritance is safer than ad hoc overrides

A resilient pattern is to centralise mandatory rules in a managed CLAUDE.md and import AGENTS.md where teams need shared instructions across tools. That gives security teams one place to keep non-negotiable guidance while still allowing project-specific context to layer underneath. The important design choice is not where the file lives, but how you guarantee it is loaded across all agent sessions. See the AI IDE and Coding Agent Security Guide.

Practical implication: Use managed instruction sources for rules that must survive local overrides.


Threat narrative

Attacker objective: The practical objective is to get the agent to operate outside the team's intended security instructions while still producing accepted code changes.

  1. Entry occurs when a developer opens a Claude Code session in a repository that contains a local CLAUDE.md or CLAUDE.local.md.
  2. Credentialed context shifts when that file suppresses the shared AGENTS.md instructions that would otherwise constrain the agent's behaviour.
  3. Impact follows when the agent generates code that omits required access-control or data-handling rules, creating a silent governance failure rather than an obvious exploit.
  • Anthropic GTG-1002 AI espionage campaign: A state-sponsored group ran Claude Code agents to attack about 30 organisations, harvesting and reusing credentials at machine speed.
  • Nx s1ngularity attack 2025: Attackers stole Nx's npm token via a GitHub Actions flaw and shipped malware that stole 2,349 secrets and abused developers' AI CLIs.

Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Instruction precedence is now an access-control problem: the system that decides which file Claude Code reads is effectively part of the security boundary. If a local file can override shared guidance without warning, the organisation does not have a policy-writing problem. It has a policy-delivery problem. Security teams should treat instruction loading like any other control path that can fail open when precedence is ambiguous.

Shared rules are only useful if they are deterministic: teams increasingly write coding-agent rules once and expect them to apply everywhere, but local Claude files, version differences and plugin settings create multiple resolution paths. That means the real governance question is not whether the rules exist, but whether the same rules load across every repo, workstation and agent surface. A documented precedence model is now part of software governance, not just developer convenience.

Security context must be explicit, not assumed: rules such as scoped database access or logging limits only matter when the agent sees the exact project context they were written for. Claude Code's file precedence turns that context into a movable target, which means organisations need to define where mandatory guidance lives and how it is inherited. The right control objective is consistent instruction resolution, not just better prose in the instruction file.

Agent governance is becoming lifecycle governance for instructions: the same discipline used for identities and entitlements now applies to instruction files that shape agent behaviour. Teams need a named owner for instruction sources, change control for local overrides and a way to verify what the agent loaded before code reaches review. Without that, the repository can look governed while the session behaves otherwise.

From our research library:

What this signals

Instruction governance is becoming a control surface of its own: the next failure mode for coding agents is not only prompt injection or unsafe code generation, but silent divergence between the rules the organisation wrote and the rules the session actually loaded. Teams that standardise agent usage need a way to detect that divergence before it turns into insecure code or inconsistent access handling.

The practical shift is toward verifying instruction state with the same seriousness used for environment state. If the repository can swap out shared rules through local files, then compliance depends on session provenance, not just on policy authoring.

Managed context will matter more than static guidance: as agent adoption grows, the winning pattern is likely to be centrally governed instruction sources with local context layered on top, rather than ad hoc repo files scattered across teams. That approach reduces drift and gives security owners a clearer change-control point for agent security settings.


For practitioners

  • Define a single inheritance model for agent instructions Choose whether shared security rules live in AGENTS.md, managed CLAUDE.md, or both, then document which file wins when they conflict.
  • Verify the loaded instructions in every agent session Check the startup output, /memory and /config so developers can confirm which instruction file Claude Code actually loaded before trusting the session.
  • Move non-negotiable controls into managed settings Keep the minimum mandatory rules in an organisation-controlled CLAUDE.md so they survive local repo overrides and personal workspace files.
  • Review pull requests for policy drift, not just code correctness Treat agent output as untrusted context and look for missing access checks, unsafe logging and other governance rules that may have dropped out of scope.

Key takeaways

  • Claude Code can silently stop using shared AGENTS.md guidance when a local CLAUDE.md or CLAUDE.local.md takes precedence.
  • The risk is governance drift, not just configuration drift, because the agent may still generate plausible code while missing security constraints.
  • Teams need deterministic instruction inheritance, managed mandatory rules and review of agent output to prevent security guidance from dropping out of scope.

Related NHI Mgmt Group resources: AI Coding Agents Security Guide · AI IDE and Coding Agent Security Guide · What Is Claude Code? Features, Plans, Surfaces and History


Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-10 — Human Use of NHIClaude Code instruction loading affects how humans govern a non-human coding agent's behaviour and guardrails.
Recommendation — Define which instruction sources govern human-configured AI coding agents and verify they load consistently.
OWASP Agentic AI Top 10ASI03 — Identity & Privilege AbuseThe article's core problem is an agent operating under different instructions than the team intended.
Recommendation — Constrain agent authority by verifying the instruction set that shapes its runtime decisions.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsInstruction files govern who can authorise actions such as data access and logging behaviour in generated code.
Recommendation — Apply entitlement-style controls to the rules that permit agents to touch sensitive code paths.
CIS Controls v8CIS-5 — Account ManagementRepository instruction overrides create governance drift similar to unmanaged account changes.
Recommendation — Manage instruction ownership and review changes that alter agent behaviour boundaries.

Key terms

  • Claude Code Routine: A Claude Code Routine is a saved configuration that packages a prompt, repositories, and connectors so Claude Code can run automatically in Anthropic-managed cloud infrastructure. It is designed for unattended execution through schedules, APIs, or GitHub events, which makes governance, permissions, and auditability central concerns rather than optional extras.
  • AGENTS.md: A project-level instruction file that an AI coding agent may load before handling a task. In autonomous workflows it behaves like executable context, so any command, path, or setup step inside it must be treated as potentially adversarial until reviewed and approved.
  • CLAUDE.md: A project-level instruction file that shapes how Claude Code interprets the codebase and applies constraints. In governance terms, it acts like standing policy for the agent, defining architecture, testing, and behavioural expectations before any tool action begins.
  • Instruction precedence: Instruction precedence is the ordering rule that determines which prompt layer wins when multiple sources of guidance exist. In runtime-led AI systems, built-in defaults, project files, session context, tool instructions, and overrides may all contribute, so teams need clear precedence rules to predict the final behaviour.

Deepen your knowledge

NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, agentic AI identity and machine identity security. It helps practitioners turn identity controls into repeatable programme decisions across engineering and security teams.
NHIMG Editorial Note
Published by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org