Git Repository Structures That Natively Store and Serve Agent Configuration Files

Agents-as-code means defining agent behavior, skills, and runtime settings in YAML and plain-text instruction files stored in Git, so changes pass through branches, pull requests, and code review like other infrastructure. A repository can be the shared source for those definitions if its layout keeps portable instructions separate from agent-native settings and makes clear which rules take precedence at runtime. Version control governs the intended behavior, while runtime infrastructure governs execution.
Why repos become the natural home for agent configuration
Agent configuration has a placement problem before it has a format problem. Personal dotfiles, one-off shell scripts, and undiscoverable wiki pages scatter instructions across places that teammates cannot reliably review and agents do not consistently read. Git already supplies the missing foundation. A single authoritative remote establishes the shared source, diff and blame history make changes traceable, branches isolate experiments, and pull requests provide a review gate. Those properties apply to agent configuration just as they apply to application code.
Coding agents, agentic IDEs, and MCP servers already work with Git, so a repository provides a distribution path without a separate configuration service. The files travel with the project they describe. But having the files does not mean every consumer reads them the same way. For the files to work reliably as a configuration system, they need shared file conventions and clear rules for how they load.
The small set of config files that agents actually read
AGENTS.md supplies the shared project context, including the project overview, directory structure, setup commands, coding standards, and Git conventions. It describes what an agent needs to know before working. Codex supports hierarchical instructions, with deeper files providing directory-scoped context that extends the root file. Claude Code added support in v2.1.277, but uses it as a fallback when no CLAUDE.md is present in the directory chain. Nested subdirectory instructions load on demand, and only when that subdirectory has no CLAUDE.md.
CLAUDE.md holds Claude-specific instructions without needing a second copy of the shared context. Used as a pointer file, it can begin with @AGENTS.md and then add overrides. The distinction is explicit in the file itself. By contrast, .claude/settings.json controls tool permissions. It can allow read and edit commands but require confirmation for git commit and git push, so permission to work is separate from permission to change shared version history.
SKILL.md defines a reusable, invocable workflow as a role description. The Agent Skills specification sets out a universal format that 40+ agents use, in which name and description fields are required. The name uses lowercase letters, numbers, and hyphens and matches its directory name. The file should remain concise, with detailed supporting documents in references/. Its purpose is to explain what the role knows and how it makes decisions.
GitAgent formalizes another set of responsibilities across agent.yaml, SOUL.md, and RULES.md. The YAML file holds model and runtime configuration, while the first plain-text instruction file sets out personality and identity and the second sets out behavioral constraints. These definitions can be branched and merged like code. MCP registrations remain a separate, agent-native concern, with Claude using JSON in .mcp.json per project or claude_desktop_config.json globally, and Codex using TOML. These native formats do not themselves provide a shared canonical source or synchronization layer.
A concrete directory layout that makes config first-class
In a useful shared layout, AGENTS.md is at the repository root, with CLAUDE.md beside it as the pointer and the place for Claude-only overrides. Below them, .agents/ is the canonical hub where shared assets are kept. This makes ownership visible in the filesystem. Portable instructions belong in the shared layer, generated files are derived from it, and settings that only one agent understands remain in that agent’s native directory. Keeping these categories separate stops a generated copy from becoming a second source to maintain.
Within the hub, .agents/skills/ contains committed skills, each in a subdirectory with its own SKILL.md. .agents/skills-local/ provides space for private, machine-specific development, with only a .gitkeep committed and local skill content ignored. Shared skills have a separate publication boundary. The script .agents/scripts/link-skills.sh creates symlinks from native skill directories to the shared definitions, so agents read the same underlying files without separate copies to maintain.
For a team that wants shared MCP registrations, .agents/mcp/servers.json can serve as a canonical source, with .agents/scripts/sync-mcp.sh generating the required native formats. This is a repository convention. Claude still consumes JSON and Codex still consumes TOML, while the script supplies the translation layer absent from those native conventions. In this layout, .codex/config.toml is generated from the canonical source rather than edited as another authoritative definition.
The .claude/skills/ entries point into ../../.agents/skills/, while .claude/settings.json stays native, unsymlinked, and independently reviewable. Other agent-specific rules likewise remain in place. The .gitignore completes this separation by excluding OS clutter such as .DS_Store and Thumbs.db, editor files in .vscode/ and .idea/, secrets such as .env, credentials.json, and secrets/, and generated artifacts. The governing rule is straightforward. Generated, local, and secret material stays out, while the context needed by a future collaborator or agent is committed.
For repositories that represent the agent itself, GitAgent extends this shared-project pattern with additional dedicated directories. Its memory/ directory stores Git-committed agent memory, tools/ holds declarative YAML tool definitions, hooks/ contains lifecycle hooks, and compliance/*.yaml holds audit configuration. Those additions serve a different repository purpose. A single-agent repository can keep its native settings and still put instructions and runtime definitions through review, without generating copies for consumers it does not have.
How precedence rules determine which config an agent uses at runtime

In the hierarchical pattern, root instructions establish repository-wide defaults, while deeper instructions override or extend them for work in their directory. The deeper scope wins within that scope. Claude’s fallback behavior means this cannot be assumed to work identically across agents, so the pointer pattern makes inheritance explicit before Claude-specific overrides apply. Tool permissions operate separately and constrain restricted actions regardless of what an instruction requests, while symlinked skills resolve to the same underlying file.
A production fleet of named agents illustrates how these definitions govern actual work. Its /cli-tester skill defines 52+ test scenarios organized into multiple tiers, while /performance-tester detects resource leaks through lifecycle endurance runs. The /software-engineer role operates both reactively and proactively. When an issue receives the agent-fix label, a macOS runner picks it up and opens a pull request. In its weekly proactive mode, the role scans for quality issues, produces up to five findings, sends them through the project-manager for triage, and spawns three macOS runners in parallel to fix three of them. These skill definitions give each role work to handle and context for its decisions, leaving it free to adapt when a fixed sequence would break.
The team’s documented lesson was to build locally first and deploy to CI second. The commit-push-wait-read-logs cycle slows the work of building skills, while debugging in the terminal makes it faster to find out what went wrong. That lesson favors building private skills in the local directory and establishing that they can be debugged in the terminal before promoting them into the committed shared set for use in a workflow. Promotion brings the definition into review, but it does not establish that every part of the repository is safe to execute.
The security risk that lives in.git/config, not in the agent

Manifold Security reported eight security flaws in seven command-line AI coding agents in September 2026 under the name GitSpawn. Four remained unpatched at publication. The findings concerned commands named in a repository’s own .git/config, which affected agents caused to run on the developer’s machine. This is distinct from malicious instructions in a skill file. It involves Git’s local execution behavior before the agent’s own protections become active.
The flaws involve core.fsmonitor, a documented Git performance setting that can be set to a command to find changed files. Git runs that command so it can skip scanning the whole directory. Operations that refresh the index, including git status and git diff, can therefore execute it with the permissions of the person running Git. All seven affected agents called Git when a session started to find the current branch and changed files, before their trust gate or sandbox was active. The command then ran as the user, outside the agent sandbox and without an approval prompt.
GitHub assigned the goose finding, CVE-2026-72718, a CVSS 4.0 base score of 7.0. Separate CVEs covered the Codex findings, including CVE-2026-19592 and CVE-2026-19593, and the Hermes Agent finding, CVE-2026-71963. Exploitation required a particular repository delivery path. A shared archive, shared drive, sync folder, or USB stick can preserve the .git directory containing the setting, whereas an ordinary git clone does not preserve that supplied directory.
The affected agents requested helpful repository context before activating their permission controls, even though the Git setting intentionally supports command execution. The hidden directory was outside the files meant to hold configuration but still inside the repository the agent was using. That makes the trust boundary broader than the committed files under review. Sandboxing, credential scoping, and audit trails provide the infrastructure-level controls needed to address this exposure.
The governance layer that config files alone cannot provide
Version-controlled definitions establish what an agent should do, while runtime controls determine what it may do and record what it actually did. Both layers need to be designed together. A recommended isolation stack combines a branch or Git worktree for each agent, Docker containers with --network=none and --cap-drop=ALL, and gVisor runtime hardening for kernel exploit protection. Each layer serves a distinct purpose. Git isolation separates concurrent changes, container restrictions constrain execution, and runtime hardening addresses the boundary beneath the container.
Docker Cloud Sandboxes provide another concrete isolation mechanism by running each agent inside a microVM with its own kernel and Docker daemon. Secrets are injected per request through a proxy, so the agent never holds the raw token. Timing remains essential to the protection. A core.fsmonitor command executing inside a network-isolated microVM with revoked credentials cannot reach external systems, but isolation must already apply when Git is invoked. Starting a sandbox after repository inspection leaves the sequencing problem intact.
Credential scoping narrows authority independently of instruction quality. Each agent session should receive freshly minted credentials that are revoked when the session ends, rather than a long-lived token shared across agents or sessions. Agent-level confirmation prompts serve a narrower function. Requiring approval for commits and pushes expresses a boundary in configuration, while infrastructure-level scoping enforces the available authority regardless of what that configuration says.
Limits on spending belong in the same version-controlled orchestration configuration. Production workflows use four limits, namely maximum tokens per LLM call, maximum tokens per agent step, maximum steps per task, and maximum total tokens per task. Together, they bound the cost of an execution. Uber’s Claude Code adoption consumed its entire annual AI budget in months as use spread across a large engineering organization, with monthly API costs per engineer varying widely. Committing limits makes those decisions reviewable, auditable, and consistent across environments and subjects model-driven expenditure to configured limits.
A five-plane reference architecture distinguishes low-stakes work, such as reading code and running tests, from high-stakes actions, such as triggering deployment, which require a gate. Friction belongs where the consequence warrants it. Every tool call, diff, and token should be logged and attributable to a person or trigger. Git preserves what the agent was told to do, while runtime records establish what happened under those instructions.


