How to Get an Audit Trail of AI Coding Agent Changes
Version control gives you the diff an AI coding agent produced, but not the instructions it acted on or the files and external content it read to get there — to reconstruct that, you need a separate log of each agent run that captures its inputs, the files it touched, and the output, tied to a timestamp and a session. Without that second layer, a change made because the agent followed a legitimate request looks identical in the commit history to one made because it followed an instruction hidden in an issue, a file, or a dependency it read.
Tools like Claude Code, GitHub Copilot CLI, Cursor, and Windsurf write code the same way a developer does — they edit files, run commands, and often commit directly. That's the appeal. It's also why their changes are hard to audit with the tools teams already have.
Why git history alone isn't an audit trail
A commit shows you the diff, the author field, and a message. For an AI coding agent that's not enough to answer the questions a security review actually asks:
- What prompt or task produced this change?
- What files, issues, pull requests, or external content did the agent read before making it?
- Did the agent run anything — a script, a package install, a shell command — that isn't reflected in the diff itself?
- Was this change part of an autonomous run, or a single edit a person reviewed and approved in the moment?
Git wasn't built to answer any of these. The commit author field says "a developer" or sometimes nothing distinguishing at all, because the agent operates inside the developer's own editor and credentials.
Why this matters beyond code quality
Coding agents read a lot of content that isn't code: issue descriptions, README files, comments in pulled-in dependencies, error output from a service they're debugging. Any of that content can carry an instruction the agent follows without a human in the loop noticing — a hidden directive in an issue that gets the agent to add an unexpected dependency, change a config value, or alter an access check. The resulting commit looks like ordinary work. Without a log of what the agent was fed as input, there's no way to go back after the fact and tell the difference between a change a person intended and one the agent was steered into by something it read.
What a real audit trail needs to capture
| Element | Why it matters |
|---|---|
| The agent's inputs — prompt, files read, external content ingested | Lets you reconstruct why a change happened, not just what changed |
| The specific actions taken — edits, commands run, files touched | Shows activity that may not appear in the final diff at all |
| Timestamp and session boundary | Lets you tie a change to a specific run and a specific person at the keyboard |
| Separation from the commit metadata itself | A compromised or manipulated run shouldn't be able to erase its own record by editing the commit |
The practical way to get this is to log at the point where the agent operates — the desktop or editor — rather than trying to infer it later from source control, which was never designed to carry that information. A local agent on each machine that observes what Claude Code, Copilot CLI, Cursor, or Windsurf actually did, independent of what ends up in the repository, gives you a record that survives even if the change itself looks innocuous in the diff.
Making it usable across a whole engineering org
A log on one developer's machine is a start; it isn't an audit trail for the company until it's consistent across every laptop and reviewable in one place. That's the difference between a developer occasionally checking their own agent's output and IT or security being able to answer, across the whole codebase, which changes in a given week came from an agent, what those agents were told, and whether any of it touched a sensitive path. DriftLock runs locally to guard coding agents like Claude Code, Copilot CLI, Cursor, VS Code, and Windsurf, and feeds that activity into a Console so security teams get one place to review agent behavior across every machine, rather than piecing it together from git logs after something has already gone wrong.
What to take away
- Git history records the result of an agent's work, not the instructions or content that produced it — that gap is where hijacked behavior hides.
- Build the audit trail from the agent's inputs and actions at the point of execution, not by trying to infer intent from the diff afterward.
- Keep that log independent of the commit itself, so a manipulated run can't simply erase its own trace.
- Consistency across every developer's machine matters more than depth on any one — an audit trail that only exists on some laptops isn't one you can rely on.
- Centralize the review in one place so security can answer "what did our AI agents change this week, and why" without manually checking each machine.