By NHI Mgmt Group Editorial TeamDomain: AI SecuritySource: ObotPublished March 30, 2026

TL;DR: Claude Code users get only about 40% of the tool’s value until they treat CLAUDE.md, context management, forks, hooks, and MCP as governance controls rather than productivity tricks, according to Obot. The deeper lesson is that agentic coding becomes a security and operating-model problem the moment teams need isolation, scoped permissions, and auditability.


At a glance

What this is: This is a practitioner guide arguing that Claude Code scales only when teams treat its configuration, context, and agent controls as governance primitives.

Why it matters: It matters because the same patterns that improve coding output also shape how organisations govern agentic AI, tool access, and the identity boundaries around software agents.

👉 Read Obot's guide to scaling Claude Code with context, hooks, and MCP


Context

Claude Code becomes harder to govern as usage shifts from isolated prompts to multi-session, multi-agent development. The issue is not just model quality, but how instructions, context, and tool access are structured around the agent. For identity and security teams, that makes agent configuration an access-control problem as much as a productivity problem.

The article’s central point is that predictable agentic coding depends on explicit boundaries, scoped permissions, and enforced workflow states. That intersects with NHI governance because tools, hooks, and MCP servers behave like non-human access paths that need ownership, auditability, and containment. When those controls are informal, drift and cross-session contamination become the real failure modes.


Key questions

Q: How should teams govern AI-assisted development workflows that use coding agents?

A: Treat them as identity-governed execution paths, not just productivity tools. Define who can start the workflow, which tools and data sources it can reach, what evidence is required for review, and how access is revoked if the workflow expands beyond its intended scope. The key is to govern the chain of delegated action, not only the final code output.

Q: Why do long agent sessions create security and quality risks?

A: Long sessions accumulate stale assumptions, repeated corrections, and contradictory state, which degrades output quality and makes bad decisions harder to unwind. In governed workflows, that drift also creates accountability problems because the agent’s behaviour becomes less reproducible. Resetting or compacting state is a control, not a convenience.

Q: What breaks when agents share memory and context too broadly?

A: When agents share memory too broadly, one incorrect or malicious write can shape multiple downstream decisions. The system may reinforce a bad assumption until it looks normal in logs and outputs. That makes investigation harder because the contaminated state becomes part of the workflow’s history, not just a single bad message.

Q: Who should own MCP access governance in an enterprise?

A: Ownership should sit with identity and security teams, not only application developers, because MCP connects user intent to privileged execution. The governing team needs authority over policy design, review cadence, and audit evidence. That keeps MCP aligned with enterprise authorization standards rather than ad hoc server behaviour.


Technical breakdown

CLAUDE.md as standing orders for an agent

CLAUDE.md is effectively the agent’s first policy file. If it is read before any code is generated, then it functions like a persistent instruction layer that sets architectural, testing, and behavioural constraints for every session. The security analogy is straightforward: a non-human actor with broad tool access still needs policy at the point of entry, not after the fact. The article’s guidance treats CLAUDE.md as a governance document, not a documentation dump. That matters because vague instructions get interpreted probabilistically, while explicit boundaries behave more like policy. In agentic environments, the quality of that policy determines how much correction work follows.

Practical implication: define non-negotiable rules in CLAUDE.md the same way you would define baseline access policy for a service account.

Context windows degrade like unmanaged session state

Long agent sessions do not just consume tokens. They accumulate stale assumptions, repeated corrections, and conflicting decisions that reduce the reliability of later outputs. The article’s emphasis on /compact, /undo, and /btw reflects a core operational reality: an agent with too much retained context starts behaving like a session with poor state hygiene. That is a governance issue because the agent’s working memory becomes a de facto control surface. When the state is bloated or noisy, instructions lose precision and earlier mistakes echo forward. For practitioners, context management is less about prompt craft and more about limiting uncontrolled state growth.

Practical implication: treat long-running sessions as bounded workflows and reset state deliberately when reasoning begins to drift.

Forked branches and hooks create isolation that prompts cannot

Parallel agents introduce cross-talk unless each branch is isolated by design. /fork creates a separate lineage for reasoning, plans, and transcripts, which is materially different from simply compacting a shared conversation. Hooks add another layer by enforcing action-level controls that the agent cannot override through discussion. Together, they resemble a policy and execution boundary around a non-human worker. This is especially relevant in agentic AI governance because the problem is not whether the agent can follow instructions, but whether those instructions survive concurrency, retries, and tool calls. The article correctly points to isolation and enforcement as the scaling mechanism.

Practical implication: use isolated branches and hooks together when multiple agents can touch the same codebase or tools.


NHI Mgmt Group analysis

Agentic coding is turning developer tooling into a non-human identity governance problem. Once Claude Code can read policy files, call tools, and persist session state, the control question is no longer only how well it writes code. It is what boundaries define its authority, what state it carries forward, and who can override its actions. That is exactly the kind of governance question identity teams already face with service accounts and automation. The practitioner conclusion is that agentic development needs explicit ownership, scoped permissions, and auditable control points.

CLAUDE.md is a naming point for a broader concept: policy-as-context. In this model, instructions are not an adjunct to the agent workflow. They are part of the execution environment, shaping every decision the model makes before any tool call occurs. That pattern aligns with identity governance because policy only works when it is present at the moment of action, not as a retrospective review artifact. For teams adopting agentic AI, the lesson is to write configuration as enforceable policy, not as developer folklore.

Isolation is the difference between usable parallelism and unsafe drift. The article’s emphasis on /fork, absolute paths, and hooks shows that concurrency without separation produces invisible contamination across tasks. In identity terms, this is the same failure mode that appears when roles, sessions, and permissions are shared too broadly across actors. Agentic systems need per-branch lineage and per-action controls if they are going to scale without corrupting decision quality. The practitioner conclusion is to design for separation first, then increase autonomy.

MCP governance will become the enterprise boundary for agentic tool use. Once agents connect to external tools and data sources, the security question shifts to authentication, authorisation, and audit of those tool relationships. That is where NHI, IAM, and agentic AI security converge most clearly. The article points toward the right direction: local power-user patterns eventually become centrally managed controls. The practitioner conclusion is to govern MCP connections as you would any other privileged machine-to-machine access path.

The market is moving from prompt engineering to governed agent operations. The practical value in this article comes from showing that power users converge on the same controls enterprises eventually need: state management, role separation, enforced boundaries, and traceability. That mirrors the maturation path seen in identity programmes, where convenience alone gives way to lifecycle control. For practitioners, the signal is clear: agentic AI will be governed less by clever prompting and more by the policy layer around tools and workflows.

What this signals

Policy-as-context is likely to become the dominant operating pattern for agentic development. The more an agent relies on persistent instructions, the more important it becomes to treat those instructions as governed policy rather than developer convenience. That shifts control ownership toward IAM, platform security, and engineering governance teams that can define and audit the boundaries of agent action.

As agent use expands, the practical challenge will move from prompt quality to control consistency across branches, tools, and workspaces. Teams should expect pressure to standardise approval paths for MCP connections, hook-based enforcement, and session reset patterns so that agent behaviour remains predictable across the programme.


For practitioners

  • Define CLAUDE.md as an enforceable policy layer Write the file as standing orders for architecture, testing, and prohibited actions, then review it like any other control document. Include only rules that should apply at every session boundary, and keep them specific enough to reduce interpretation.
  • Reset long sessions before reasoning drifts Use compact and undo intentionally when an agent starts repeating itself, contradicting earlier decisions, or carrying stale context into new work. Treat the session as stateful infrastructure that needs periodic control, not an endless conversation.
  • Separate parallel work into isolated branches Use forked branches for any task where one agent’s reasoning could contaminate another’s, and pair that with absolute paths for file references across workspaces. Isolation prevents silent cross-task drift that is hard to detect after the fact.
  • Enforce action boundaries with hooks Use hooks to block writes, shell commands, or API calls that should never occur in a given workflow phase. Set the control so an action can be prevented mechanically even when the agent is otherwise confident.
  • Govern MCP connections like machine identities Require central review of which MCP servers agents can reach, how they authenticate, and what tools they are allowed to call. That gives security and compliance teams a visible control point over agent tool use rather than leaving it to local developer choice.

Key takeaways

  • Claude Code scales only when teams govern context, boundaries, and tool access as control problems, not productivity tips.
  • Parallel agent work fails most often through drift and contamination, which makes isolation and enforcement the real scaling levers.
  • Identity and security teams should treat agent configuration, hooks, and MCP access as non-human identity governance in practice.

Standards & Framework Alignment

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

OWASP Agentic AI Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST AI RMF, NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10The article centers on agent tool use, context control, and stateful behaviour.
NIST AI RMFGOVERNGovernance, ownership, and accountability are the article's central themes.
NIST CSF 2.0PR.AC-4Scoped access and least privilege are needed for agent tools and MCP connections.
NIST SP 800-53 Rev 5AC-6Least privilege is directly relevant to hooks, forks, and restricted tool use.
MITRE ATT&CKTA0003 , Persistence; TA0006 , Credential AccessThe article touches on persistent session state and credential-bearing tool access.

Map agent tool boundaries and prompt-injection exposure to agentic AI controls before broadening deployment.


Key terms

  • 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.
  • Context Window: The context window is the text a model receives at one time, including prompts, retrieved documents, and conversation history. Security teams care about it because it becomes the practical boundary between trusted instructions and untrusted content, especially when the application assembles that text automatically.
  • Forked Branch: An isolated conversation or work branch created so that one agent’s reasoning does not contaminate another’s. It is a practical control for parallel agent work, preserving lineage, limiting cross-task drift, and making decisions easier to review later.
  • MCP Server: An MCP server is a tool endpoint that connects an AI agent to external systems and data sources through Model Context Protocol. Because it extends what the agent can reach, it becomes part of the identity and access surface and must be reviewed like any other privileged connector.

What's in the full article

Obot's full article covers the operational detail this post intentionally leaves for the source:

  • Step-by-step examples of CLAUDE.md structures for different project types and governance styles
  • Practical walkthroughs of /compact, /btw, /fork, and hook usage in live agent workflows
  • Debug logging and state-manager behaviour that help teams understand how sessions change over time
  • Local MCP server setup patterns and the mechanisms behind structured elicitation in agent workflows

👉 Obot's full article covers the session patterns, hook controls, and multi-agent workflows in detail.

Deepen your knowledge

NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, and secrets management. It helps practitioners translate agent and automation risk into controls that fit IAM and security operating models.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 19, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org