Bootstrapping a Version-Controlled Agent Definition From a Blank Repository
Build an agent's YAML definition field by field, with review.

Agents-as-code means defining an agent in a YAML configuration file stored in a version-control repository, with its model, instructions, tools, credentials, triggers, budgets, and audit settings subject to code review. Starting from a blank repository, the definition grows incrementally. This reviewable operating contract makes the agent easier to govern, audit, and change.
Why expressing every agent decision as reviewable configuration — rather than runtime choice — matters
Moving a coding agent from a laptop experiment into a shared repository exposes a governance gap. Decisions that belonged to one operator now affect a team. Terraform configurations separated what infrastructure should exist from how it is provisioned. A checked-in agent definition makes the same separation between the agent’s declared behavior and the model or runtime that executes it.
YAML diffs show what changed without every reviewer having to know the underlying framework, and pull-request approval can hold those changes back until they are approved to run. Engineering Reliable Coding Agents describes reliability as a “dependency chain” spanning the model, harness, permissions, execution environment, and observability. The definition file makes those dependencies explicit rather than leaving them scattered across runtime settings. Building that file incrementally brings each decision into the same review process already used for infrastructure and application code.
How do you define AI agents in YAML for version control?
A complete definition begins with identity fields, including name, description, and tags, which connect the agent to audit records, cost attribution, and access policies. The model field selects the version that will execute its work. System instructions establish the operating mandate, either inline or through a path to versioned Markdown. Environment and repository scope identify where that mandate applies. These fields describe the agent before granting it authority.
The tool allowlist then declares permitted capabilities and their scope, while credential references identify the secret bindings that authorize access. Neither field substitutes for the other. Triggers set when a run starts, and budget fields set per-session and per-request limits. Observability fields set what evidence is kept from a run, including its destination, level, and retention policy.
This is the reference map for the build. Each concern belongs in reviewed configuration because each can change the agent’s behavior or exposure independently of model capability. The file is therefore more than a prompt wrapper. Its usefulness depends on a runtime enforcing the declared permissions, limits, and execution conditions, which is the problem Ellipsis, a cloud agent platform that runs agents defined as YAML in your repository on managed infrastructure, was built to solve.
Starting with identity and model selection, and why pinning matters more than it appears
The initial definition needs a name, a description, and a model reference. The name anchors the agent’s cost attribution, audit-log attribution, and access-control scope. The description explains what the agent is for to someone who reads the repository without knowing its background. Together, they distinguish the agent’s intended role from the capabilities of its underlying model.
The model reference should name an exact version. An alias such as “claude-latest” leaves a consequential choice outside the reviewed file. If that alias changes silently, an unchanged definition can produce different behavior, unexpected test failures, or changed output formats. Pinning moves the upgrade into a visible configuration diff.
Pinning is a prerequisite for controlled change. Reliability also depends on the instructions, permissions, and execution environment declared later. Nevertheless, a reviewer cannot assess a model upgrade as a deliberate change if the model reference can change meaning without a commit. Establishing this anchor first gives later behavioral tests and audit records a specific model version to refer to.
Writing system instructions that constrain behavior without becoming a maintenance burden
Once the identity and model are set, the instructions field states what the agent is to do. It should state the task, the systems in scope, prohibited actions, and how uncertainty should be handled. “Help with the repo” leaves authority largely undefined. “Review pull requests in the auth service for security anti-patterns; do not merge or push” identifies both useful work and an explicit boundary.
The instructions field can reference an external Markdown path. Keeping that file in version control gives instructions their own diff history, reviewers, and semantic version, without turning the YAML into a long prose document. The path is part of the definition, and the referenced content remains a reviewed artifact. Instructions kept only in a chat window or runtime variable have no such review history.
Precision should not become an exhaustive script for every edge case. The instructions should name the tasks, repositories or systems, and actions to rule out, and give the agent a policy for what to do when it is unsure. Humans are Missing from AI Coding Agent Research identifies task alignment as a core point of failure in human-agent collaboration. Scoped instructions address that problem before execution, while versioning makes a harmful instruction update reversible.
Declaring the tool allowlist as the agent's permission boundary
Instructions express intent, but tool permissions enforce authority. An agent told not to modify a database should not receive a database-write tool merely because the model could use it. For the auth-service review example, repository reading and pull-request review are the relevant capabilities. Database write remains absent from the allowlist.
The default is deny. Every permitted tool should have its scope declared, including whether access is read-only or read-write, which repositories or namespaces it reaches, and whether execution requires human approval. A review capability that permits writing must be distinguished from permission to push code or merge a pull request. Those distinctions belong in the definition.
Adding a tool therefore changes the agent’s authority. The reliable-agents paper treats permissions as a dependency of the system in its own right, regardless of what the model can do. That distinction explains why a more capable model does not remove the need for a hard boundary. The runtime must enforce the allowlist.
Scoping credentials so each agent session runs with exactly the access it needs and no more
The allowlist governs which tools may run, while credentials govern what those tools can access. The definition should keep the secret value external by referencing a vault binding or secret name. Deleting a committed key from the current file does not remove it from version-control history.
Credential lifetime is a separate control from storage. Repository-lifetime credentials outlast an individual task, whereas session-scoped credentials are minted when work starts and revoked when it ends. Revocation prevents that credential from being reused after the session. Its lifetime matches the work it authorizes.
The definition should also declare the OAuth scopes the agent may request, the APIs it may reach, and the repositories it may touch. A reference alone is not least privilege. The referenced credential must have the access appropriate to the agent’s mandate and session. Setting these constraints before a run lets reviewers check the tool boundary and the identity boundary together and spot a mismatch before the agent runs.
Setting triggers so the agent runs on the right event, not on demand or on a schedule alone
Once authority is bounded, triggers connect execution to the team’s workflow. Pull-request events such as opened, updated, or labeled can start a review. A cron schedule serves recurring tasks such as dependency audits or test-suite triage. Webhooks and direct API calls support activation from external systems, other agents, or workflows.
Trigger breadth affects both cost and authorization. Running on every push to any branch can start sessions that are not needed, while running reviews only for pull requests targeting main with a needs-review label lets the team choose when a review starts. The condition belongs in the definition. It can then be reviewed together with the work it initiates.
Scheduled execution complements event-driven execution. The trigger also establishes an authorization context. A push on a feature branch should not inherit the permissions appropriate to a merge to main. Matching trigger conditions with credential scope in the same file makes that relationship visible before the agent runs.
Declaring budget caps in the definition file so runaway token spend is stopped before it compounds
Agentic workflows consume substantially more tokens per task than standard chat interactions, and multi-agent architectures compound that demand. A manageable test run is therefore a poor substitute for an enforced budget. The definition should have both per-session and per-request limits. These place cost control at the point where execution is authorized.
The limits must be machine-readable so the platform can enforce them. A platform consuming the definition can stop the next provider request before it is made, rather than report excessive usage after the bill arrives. Per-request limits constrain individual requests, while the session cap bounds the work as a whole. Both should be in reviewed configuration, even if they are also in a dashboard.
A cap and an alert are different controls. An alert reports when usage crosses a threshold, while an enforced cap stops further use at the declared limit. The agent’s judgment is not the enforcement mechanism because the agent has no financial stake in stopping. Defining the stop condition before the first run prevents cost policy from depending on someone noticing an expanding loop.
Adding observability fields so every tool call and diff is attributable from the first run
Observability completes the definition by specifying what evidence execution leaves behind. The file should declare logging for tool calls, diffs, thinking tokens, token usage, and the model version in use. It should also declare the log destination, log level, and retention policy. These are governance choices.
Every log entry needs attribution to its execution context. The required anchors are the session ID, trigger identity, and agent name declared in the file. Without them, an output may be visible while the session and activation that produced it remain unclear.
At this point, the assembled definition includes identity, a pinned model, versioned instructions, environment and repository scope, tools, credential references, triggers, budgets, and observability. The referenced instructions remain part of that reviewed configuration even though their text lives in Markdown. The complete artifact now describes both the work and its controls. This provides the basis for evaluating later changes without reconstructing the agent from disconnected runtime settings.
Evolving the definition through pull requests, and what makes a config change safe to merge
Maintaining the definition now follows the application-code workflow. A change moves through a branch, proposal, review, and merge, with rollback available by reverting the change in version control. A useful pull-request description explains the intended behavioral change, the fields affected, any change in authority or cost exposure, and the evidence supporting the update. Reviewers should not have to infer purpose from a YAML diff alone.
Review depth should follow the scope of the change. Adding a trigger, tightening a budget cap, or updating a log destination can be lower-risk changes suitable for a single approver. Adding a tool, widening credential scope, or changing instructions for sensitive operations needs review by more people. Trigger changes still need to be checked against credential scope because when the agent runs is tied to what it can access.
Behavioral testing makes instruction and model changes safer to merge. Golden IO tests use fixed input/output pairs to detect regressions, while run fingerprinting hashes the model version, prompt template, and tool definitions. These controls help detect drift before production. An agent’s proposal to change its own definition remains a pull request subject to the same gates.
What teams gain when the definition file is the agent's source of truth across its whole lifecycle
A versioned definition lets a new engineer understand the agent without inheriting an operator’s private context. Git records who changed its configuration, when, why, and what review approved the change. An auditor can follow that history while execution logs connect activity to sessions and triggers. This makes continuity of governance visible as the agent evolves.
Reviewed configuration also creates a basis for reuse. A Case-Bundle Operating Model for Coding Agents in OpenFOAM-Based CFD demonstrates the pattern with 140 geometry variants executed from a single reviewed bundle. A separate replay exercise using four different LLM backends also produced verified results.
That reuse gives the team an established baseline against which to assess future changes. Model upgrades, tighter budgets, and revised triggers become bounded changes with a history, rather than reasons to reconstruct trust from scratch. Starting from a blank repository, the team ends with an agent whose behavior is governed, whose spend is bounded by configured enforcement, and whose operating contract can be handed to a new engineer or compliance auditor with confidence.


