When working with AI coding agents that can commit changes directly to your repository, it is helpful to distinguish between commits made by the AI and those made by human developers. This practice enhances the clarity of your project’s history and simplifies the process of reviewing AI-generated code.
A robust way to achieve this is by leveraging Git’s distinction between a commit’s author and its committer. The author is the person who originally wrote the changes, while the committer is the person who applied the commit to the repository. Even if an AI agent uses your credentials to commit code — making you the committer — you can instruct it to set itself as the author.
Instructing the AI
You can add a persistent instruction to your AI agent's configuration file (e.g., AGENTS.md
or CLAUDE.md
) to modify its commit behavior. The instruction should require the agent to use the --author
flag with every commit command.
## Source Control (Git)
- When invoking `git commit`, you MUST pass the `--author="AI <ai@example.com>"` argument to clearly identify commits made by the AI agent.
With this instruction in place, every commit the AI makes will be properly attributed, embedding the agent's identity directly into the version control history.
Filtering the Commit History
Once commits are tagged this way, you can easily filter your Git log to display only the changes made by the AI agent. Use the --author
flag with the git log
command to search for the specific author string you defined.
git log --author="AI"
This command provides a focused view of the AI's contributions, making it simple to track its work, review changes sequentially, and understand the evolution of the codebase in a hybrid human-AI development environment.