Rightshold™ Sign up

Answers · agent safety

How do I give an AI coding agent its own git identity for commits?

Last updated

TL;DR: Set the author and committer for the agent's environment only, not your global config. Git takes the author and committer from GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL when they are set, and otherwise from user.name and user.email (author.* and committer.* can split the two). So give the agent's process those variables, or a repository or worktree config, with a name like 'Build Agent' and an email you control, ideally the GitHub-provided noreply address of a machine account. Keep the human in the record with a Co-authored-by: trailer, and push with the machine account's own narrowly scoped credential. Remember that these fields are labels: the git docs say the name has no effect on authentication, and anyone can type any name, so use commit signing if you need the identity to be provable.

What should I check, step by step?

1. Pick who the commits should say wrote them: the agent alone (author = agent, with you as co-author), or you (author = you, committer = agent). git lets author and committer differ.

  1. Set the identity where only the agent sees it: environment variables in the agent's process or container, or `git config user.name` / `git config user.email` without --global inside the agent's clone or worktree.
  2. Use an email you control and don't mind being public forever in history. On GitHub, a noreply address keeps a real inbox out of the log.
  3. On GitHub, if you want the commits linked to an account, create a machine account: the Terms of Service allow one free machine account per person, set up and owned by a human who is responsible for its actions and used only for automated tasks.
  4. Give that account only the repository access the agent needs and its own token or deploy key, so its pushes, not just its commit labels, are separate from yours and can be revoked alone.
  5. Add a Co-authored-by: Name <email> trailer for the human who directed the work; GitHub attributes the commit to every listed co-author whose email is on their account (or their noreply address).
  6. Sign the agent's commits with its own key (git supports OpenPGP, X.509 and SSH signing via gpg.format) if reviewers need to tell a real agent commit from someone typing the same name.
  7. Protect the default branch so the agent's account opens pull requests and a human reviews and merges.
  8. Check before every push that the agent isn't committing as you: run `git log --format='%an <%ae> / %cn <%ce>' origin/main..HEAD` and compare.

How git decides who wrote a commit

git-commit reads GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL and GIT_COMMITTER_DATE if they are set; if not, it uses user.name and user.email from config, then the EMAIL variable, then the system user name and host.

GitHub accounts for agents

GitHub's Terms of Service (effective April 27, 2026) say accounts registered by bots or automated methods are not permitted, but machine accounts are: one set up by an individual human who accepts the Terms, provides a valid email address and is responsible for its actions, used exclusively for automated tasks. You may keep no more than one free machine account in addition to your free personal account.

How do I ask Rightshold about this (free, no key)?

Add the MCP server https://www.rightshold.com/mcp to Claude, Cursor, ChatGPT, Grok or VS Code, then ask: “Issue a credential for my coding agent's current configuration with a narrow scope, so reviewers can check which configuration made these commits.”

One-click setup

{
  "tool": "issue_agent_credential",
  "arguments": {
    "agent": "build-agent",
    "public_key_pem": "<Ed25519 PEM>",
    "config": {
      "model_id": "provider/model@version",
      "system_prompt_sha256": "<hex>",
      "tools": [
        "read_file",
        "edit_file",
        "git_commit"
      ],
      "code_version": "v1.2.0"
    },
    "scope": [
      "repo:commit"
    ],
    "ttl_hours": 24,
    "signature": "<agent key signs the CredentialRequest>"
  }
}

Rightshold does not create GitHub accounts, set git config or sign commits. A credential describes a configuration and an accountable owner at a point in time; it is not a guarantee of behaviour. Not legal advice.

What are the sources?

Related

Not legal advice. JSON · Markdown · All answers

Get a free API key in one call

No card and no email needed. 100 free credits; the license and policy checks stay free without a key.

curl -s -X POST https://www.rightshold.com/v1/accounts/signup -H "Content-Type: application/json" -d '{"accept_terms":true}'
export RIGHTSHOLD_API_KEY=rs_...   # the api_key from the reply (shown once)
curl -s https://www.rightshold.com/v1/licenses/check -H "Authorization: Bearer $RIGHTSHOLD_API_KEY" \
  -H "Content-Type: application/json" -d '{"license":"MIT","intended_use":{"commercial_use":true}}'