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.
- 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.
- 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.
- 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.
- 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.
- 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).
- 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.
- Protect the default branch so the agent's account opens pull requests and a human reviews and merges.
- 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.
- git-config's author.name, author.email, committer.name and committer.email override user.* for one role, and all of them are overridden by the environment variables. That makes environment variables the cleanest switch for an agent: they apply to its process and nothing else.
- The git docs say the name is by convention a personal name but git does not enforce any form, and that it has no effect on authentication. A commit labeled 'Build Agent' proves nothing about who made it; a signature or the credential that pushed it does.
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.
- GitHub's account docs call this a machine user, for example for continuous integration, and its commit-email docs let you set either a noreply address or any address, per repository or globally.
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.”
{
"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>"
}
}- verify_agent_credential checks it for free. If you record the credential id in the commit message (a trailer name of your own choosing), anyone reviewing the history can look it up.
- revoke_agent_credential revokes it instantly if the agent's configuration changes or misbehaves.
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?
- Git documentation: git-commit (Commit information)
- Git documentation: git-config (user.*, author.*, committer.*, gpg.format)
- GitHub Docs: Creating a commit with multiple authors
- GitHub Docs: Setting your commit email address
- GitHub Terms of Service (effective April 27, 2026): Account requirements
- GitHub Docs: Types of GitHub accounts (machine users)
Related
- Who owns code written by an AI coding agent
- How to give an MCP server least-privilege access to GitHub
- How to run parallel Claude Code sessions with git worktrees
- How to keep .env secrets and API keys away from AI coding agents
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}}'
