Pull Request Workflows That Make Agent Definitions a First-Class Engineering Artifact
Treat agent permissions like infrastructure code to catch security gaps before deployment.

Agents-as-code means defining agent behavior and permissions in YAML configuration files stored in Git, then reviewing, approving, and versioning changes through pull requests. This workflow makes access, tool use, and spending limits explicit engineering decisions. Its effectiveness depends on both reviewed definitions and a runtime that enforces them.
Why agent YAML files are not just config — they are policy
An agent definition specifies which model runs, which tools it may call, what credentials it holds, and what it may spend. The Claude Code format makes several of these controls concrete in YAML frontmatter. Its tools field restricts access through an allowlist, while disallowedTools provides a denylist. The permissionMode field governs permission prompts and human checkpoints. The skills field preloads context, and hooks defines lifecycle enforcement points that can block or modify behavior, while instructions live in the Markdown body.
These fields are grants and constraints. Together with instructions, they establish the policy under which an agent acts. Microsoft’s Agent Framework has Microsoft.Agents.AI.Declarative and a CreateFromYamlAsync extension method, so a versioned document is another way to build an agent. The Kubernetes analogy is useful here. Just as a manifest declares what a container needs and the cluster decides how to run it, an .agf.yaml declares what an agent needs and the runtime decides how to execute it.
Instructions for the repository make that policy apply beyond a single agent definition. The AGENTS.md standard, stewarded by the Agentic AI Foundation under the Linux Foundation, gives compliant agents a shared place to read repository instructions. OpenAI reported that more than 60,000 open-source projects had adopted it after its August 2025 release. Those instructions need to be reviewed too. A tool restriction in YAML and a guardrail in AGENTS.md serve different functions, but both shape what an agent is authorized or instructed to do.
What happens when agent definitions are not reviewed like code
When these policy files ship without review, agents can gain more credentials, access more data, and spend more without engineers having decided to allow it. The 2026 incident record includes a worm propagated through AI coding agent configuration files, a production database deleted in a single API call, and a hijacked coding-assistant session that seeded a supply-chain worm across roughly 100 internal repositories. In each case, no one had checked the permission against least-privilege principles.
Anthropic’s 2026 trends report characterizes 2025 as the period when coding agents moved from experimental tools to production systems. That transition enlarges the consequences of unchecked definitions. A permission that once affected a developer’s workstation can put the whole organization at risk when the same agent works across production resources. MCP servers widen this boundary because they connect agents to external tools and databases. An unvetted server in a definition can introduce a remote code execution vector under the guise of an integration.
The reviewed alternative starts with the task. An agent that needs to read a production database rarely needs permission to drop it, and almost never needs permission to delete its backups. A reviewer can make that distinction before deployment. The definition then states what the agent is allowed to do, so the team can avoid giving it excessive access and trusting it to hold back.
The infrastructure-as-code precedent and what it tells teams to do with agent YAML
Terraform, Kubernetes manifests, and Helm charts moved infrastructure changes from click-ops into versioned desired-state files reviewed through pull requests. Agent YAML can inherit that established engineering pattern. The file becomes the proposed change, the diff exposes its scope, and approval records the decision to deploy it. Review becomes part of delivery. The same repository workflow that governs infrastructure can therefore govern changes to an agent’s capabilities.
For agent-based systems, the pipeline contains definition files in the way a traditional pipeline contains Dockerfiles. The processing is different, however. For agent definitions, schema validation and evaluation against golden datasets replace the container image build. A valid document proves that a definition can be read, while acceptable behavior by the resulting agent remains unproven.
That distinction limits the infrastructure-as-code analogy in an important way. Infrastructure as code governs deterministic systems, while agent YAML governs a non-deterministic model. Review is necessary, but it is not sufficient. Evals check whether agents do what their definitions say they should, while monitoring and execution-time budget gates cover what happens after deployment. Like a Terraform plan before an apply, these checks make the proposal inspectable, but behavioral evaluation must also accompany the agent into production.
How should teams manage agent definitions through pull requests and code review?
Teams should make each agent-definition PR a reviewable statement of identity scope, tool access, permission mode, credential binding, and spending limits. The author’s checklist should explain how those choices support the defined task, so the reviewer can assess capability grants. Identity deserves an explicit decision. The definition should name a scoped identity, and the runtime should mint credentials for the session and revoke them on completion.
Each tool in an allowlist should receive the scrutiny of a firewall rule. With an explicit allowlist, tools absent from the list are implicitly denied. The reviewer should ask whether every declared tool and credential is needed to complete the task. A PR-review agent does not need write access to the secrets store. In Claude Code definitions, permissionMode also needs explicit review because it determines how permission prompts are handled and whether a human checkpoint remains.
The author should make sure the review covers changes to instruction text, startup skills, lifecycle hooks, and any AGENTS.md guidance that applies. These can alter behavior without expanding a tool list. The definition should also declare a hard per-session spending limit, with an absent cap treated as a review finding. OWASP’s Agent Control Standard specifies an Agent Bill of Materials, or AgBOM, whose updated inventory gives reviewers a machine-readable diff of models, tools, capabilities, and dependencies. OWASP LLM Top 10 and NIST AI RMF supply the review vocabulary, while EU AI Act enforcement deadlines that began taking effect in August 2025 make documented review trails a regulatory requirement in covered jurisdictions.
Automating the checks that belong in CI before a human reviews
The mechanical parts of that checklist should run in CI before a reviewer spends attention on judgment calls. Schema validation should check the definition against the Open Agent Specification or a schema the team has defined. A schema that requires a spending limit can reject a definition that lacks one, while recognized-value checks can reject a permission mode that is invalid. Syntax alone is not the complete test. The schema needs to state how the definition under review must be structured.
Policy linting should then compare the definition with the organization’s approved inventory and rules. This check can identify prohibited tool names, unvetted MCP servers, missing budget declarations, and references to ambient credentials. It is analogous to a Terraform compliance check. Where schema validation asks whether the document is well-formed, policy linting asks whether its declared capabilities are allowed. Human reviewers can then concentrate on whether an allowed capability is appropriate for this particular task.
Behavioral evals check whether an agent with a valid definition behaves as it should. Microsoft Foundry’s reference architecture specifies thresholds including hallucination rate below 5%, task completion above a defined floor, and zero policy violations in CI. A PR that changes instructions should rerun golden-dataset evals and block merge when scores regress. For example, a change to instructions could remove a safety constraint and still leave every YAML field valid. An eval that tests that constraint can expose the behavioral regression that schema validation and capability linting would miss.
Versioning, rollback, and what the git history of agent definitions enables
When a deployed definition causes runaway spending or unexpected data access, rollback should use the same mechanism as a bad infrastructure change. The team reverts to the last known-good commit and redeploys. Because the definition was reviewed and versioned, the team has a specific prior capability set to restore rather than an undocumented collection of settings to reconstruct.
The same history answers who expanded an allowlist, when the change landed, and which PR approved it. Git blame connects the changed field to that record. In Mandiant’s cases, the damage happened during active sessions on developer workstations, beyond the static artifacts that a scanner could check beforehand. Versioned definitions let responders correlate a capability grant with the start of anomalous behavior.
Committing the AgBOM with the YAML makes capability changes searchable across that history. Reviewers can inspect changes to tools, models, capabilities, and dependencies alongside instruction-text diffs. The approval record also has a second audience. For teams subject to EU AI Act or SOC 2 requirements, reviewer identities, approval timestamps, and linked eval results provide evidence of documented human oversight. The PR workflow creates that audit artifact as teams deliver changes, so they can avoid writing a separate account of each decision.
Connecting runtime observability back to the definition that authorized each session
After deployment, every session should remain attributable to the definition version that authorized it. The trace context should connect the session to its Git SHA, the identity that triggered it, and the credential set it held. That link anchors the runtime governance loop. Without it, a tool call or unexpected cost is visible activity but is harder to connect to the reviewed capability grant. With it, responders can identify the precise definition commit associated with anomalous behavior.
The OpenTelemetry GenAI specification organizes conventions across six areas, including client spans, agent and workflow spans, MCP conventions, events, metrics, and provider-specific conventions. Its effectively mandatory histogram metrics, both in Development status, are gen_ai.client.operation.duration and gen_ai.client.token.usage. The first tracks latency, and the second tracks input and output token use separately. These provide the baseline for session cost and speed. Definition-level attribution adds the context needed to connect those measurements to cost per definition, developer, and PR.
Runtime tracing should also pair with eval gates that score live outputs and flag declining quality. Those scorers complement the golden-dataset gate used before merge. Production behavior still needs its own scrutiny. Coding-agent activity should enter telemetry like activity from any other service, and anomalous tool-call patterns should route to the security team like anomalous network traffic. The definition version in the trace tells the responder which capability set was in force, connecting runtime evidence back to the approved change.
Running this workflow in practice — how managed agent infrastructure fits in
A managed runtime completes this workflow only if it enforces what the reviewed definition declares. Isolated sandboxes, per-session credentials, hard spending caps, and attributable logs must be operational controls. A scoped credential declaration cannot revoke a shared key. The runtime must mint fresh credentials for each session and revoke them on completion for the declared identity boundary to become effective.
A budget field is advisory unless the runtime rejects requests that would breach the limit before they incur spend. Hierarchical enforcement at the session, developer, and organization levels closes that gap. These are concrete criteria for infrastructure selection. For teams moving from laptop experiments with Claude Code or Codex to organization-wide deployment, a successful local run establishes a prototype, while governed production requires enforcement and observability around the version-controlled definition.
Teams should therefore demand Git-based definitions, PR review, automated validation and evals, versioned audit records, and runtime policy enforcement from whichever infrastructure they choose. This workflow is achievable without building a bespoke platform. A declarative loader demonstrates that an agent can be constructed from YAML, but that alone does not establish managed governance. The runtime must be able to enforce the permissions and limits that reviewers approved, then attribute each session to that exact version.


