my-git

AI Agent Governance

English 中文

When AI agents start creating branches, committing code, and opening PRs, the repository gains a new class of participants. Governance now covers agents as well as humans, and existing branch protection, review rules, and CI policies deserve a fresh look.

This guide answers five questions:

  1. What identity do agents use to commit code?
  2. How should agent permissions be scoped down?
  3. Who approves PRs opened by agents?
  4. How do agents trigger CI, and how are secrets isolated?
  5. How do you trace a problem back to a specific agent session?

Three Identity Models for Agents

1. Tools running locally under a human account

Claude Code, Codex CLI, and Aider run on a developer’s machine, and commits appear under the developer’s own identity.

Governance focus:

fix(order): handle empty timeout config

Co-authored-by: Claude <noreply@anthropic.com>

2. Platform-hosted agents

Agents such as GitHub Copilot cloud agent and Codex cloud run in platform sandboxes and commit under separate bot identities.

Taking Copilot cloud agent as an example, GitHub ships these built-in restrictions (see the official documentation at the end):

Governance focus: confirm these defaults have not been loosened before deciding which repositories to open up to hosted agents.

3. Agents inside self-built automation

When teams run agents inside GitHub Actions or internal platforms, the identity is usually a GitHub App or a machine user.

Governance focus:

Permission Design

Core principle: grant agents the smallest permission set that the task requires.

PR Approval Rules

CI Triggers and Secrets Isolation

Once agent-authored code runs in CI, that code holds execution rights in the CI environment. Three control points:

Hosted agent environments restrict outbound network access through a firewall by default. Confirm the list of required domains before loosening it.

Traceability

When something goes wrong, you need to answer: whose agent produced this code, in which session, started by whom.

Minimal Setup

A small team needs only four things to start:

  1. Agree on an agent branch prefix and write it into AGENTS.md and the branch naming convention.
  2. Enable Require a pull request before merging and Require approvals on the main branch.
  3. Agree on commit trailers that mark AI involvement.
  4. Move deployment secrets into environments.

Growing teams can then add:

Common Mistakes

1. Granting agents the same permissions as humans

Agents do not need admin, do not need bypass, and do not need access to every repository. Oversized permissions make audits unable to tell humans and agents apart.

2. Sharing one token across all agents

A shared token means no accountability and no selective revocation. One identity per purpose.

3. Treating AI review as human approval

AI review can run a first pass, but Required approvals must be satisfied by a human.

4. No naming convention for agent branches

Without a unified prefix, auditing, cleanup, and Ruleset targeting all become impossible.

Extended Reading