Get the free coreGet core

AI agent monitoring: how to see what your agent did on your Mac

Updated 6 min readSection 05 / Threats
SHORT ANSWER

AI agent monitoring on a Mac means checking the places an agent leaves traces, not trusting its own summary. Claude Code stores session transcripts locally in plaintext under ~/.claude/projects/ for 30 days by default. A hook can append every Bash command to a log. Git keeps its own record of branch moves. First action: open ~/.claude/projects/ and read the last session before you accept what the agent says it did.

The agent that edits your code also runs commands on the machine that holds your keys and browser sessions. Guardrails limit what it may do. AI agent monitoring is the other half: seeing what it actually did. It is a list of places to look, in the order that costs the least time. The limiting side is on AI agent guardrails.

01What to look at and where

WhatWhere on your MacWhat it tells you
Session transcripts~/.claude/projects/, plaintext, 30 days by defaultWhat Claude Code was asked and what it did
Commands it tried to runA log file written by a hook, for example ~/.claude/bash.logEvery Bash command in order, including ones that were then blocked
Git historygit reflog and git log --follow <path>Where branches moved, and which commits changed a file
Login itemsSystem Settings, Login Items & ExtensionsItems that open at login
Background agents/Library/LaunchAgents and ~/Library/LaunchAgentsPrograms set to start by themselves
Running programsActivity Monitor: memory and CPU per processWhat is running and how hard
Outgoing connectionsAn outgoing firewall's monitor, such as Little SnitchWhich program connected where
Key and billing usageThe provider's usage page, such as OpenAI'sIf something else is using your keys

The sections below add only what the table cannot: how to read each place and what to do with a hit.

02The session record: where AI agent monitoring starts

Claude Code keeps a plaintext transcript of each session on your Mac. It is the first place to read after anything odd, because it holds what the agent was asked and what it did in reply. Anyone who can read your files can read it, so treat the folder as sensitive. Read the last session first, because it is the one you are about to trust. It expires after 30 days by default, so look early. Transcripts you share through /feedback, /bug or /share are kept for 5 years, so do not share a session that contains secrets.

03A log of every command

The transcript tells the story. A log tells you exactly which commands the agent tried to run. A hook is a script that Claude Code runs at a fixed moment, such as just before a tool call. A hook receives the event as JSON on standard input, and for Bash the command field holds the command. This one appends each command to a file, and goes in ~/.claude/settings.json so it covers all your projects. It uses jq, a small command-line tool that reads JSON, so jq has to be installed on your Mac:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r .tool_input.command >> ~/.claude/bash.log"
          }
        ]
      }
    ]
  }
}

The matcher of Bash means the log holds shell commands only, not edits made through Claude's file tools. The PreToolUse event fires before the tool call executes. If another hook denies the call, the logging hook still writes its entry, so a line in the log means Claude tried the command, not that it ran. Cursor has a similar beforeShellExecution hook for controlling shell commands. If you use Cursor and have no such hook, start with the git history and startup items below. Writing hooks is covered on Claude Code hooks.

When you read the log, look for curl output piped through base64 and gunzip, which means a download decoded and unpacked on the spot. Also look for osascript or JXA, which are Apple's scripting tools, in Terminal activity. Another sign is reads of the Keychain, browser stores, SSH keys, Kubernetes configs, AWS credentials and wallet data. A coding agent reads many files for good reasons, so match every hit against the task you gave it. To search the log in one line, run grep -E 'base64|osascript' ~/.claude/bash.log. A hit you cannot explain is the one to follow up in the transcript.

04Git and startup items

Git logs more than commits. A reflog records when the tips of branches and other references were updated in your local repository. For example, HEAD@{2} means where HEAD was two moves ago. To see which commits changed one file, including before a rename, run git log --follow <path>. If the history looks wrong, Git undo reset shows how to get commits back, and Claude Code undo covers rewinding the agent's edits.

Some attacks make sure they run again after a restart. On macOS, one common place is a LaunchAgent, a small file that tells the system to start a program at login. The DigitStealer stealer for macOS keeps itself running this way. Look in Login Items & Extensions, which lists items that open at login and lets you remove one. Then check the folders /Library/LaunchAgents and ~/Library/LaunchAgents, where third-party agents live.

A rare but specific case: the file ~/Library/LaunchAgents/com.user.gh-token-monitor.plist belongs to Mini Shai-Hulud, a campaign that compromised npm packages. If you find it, there is a calm order of steps. First, do not revoke your GitHub tokens yet, because the program polls GitHub and triggers when the token it checks is revoked. Second, stop it with launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.user.gh-token-monitor.plist and delete the file. If you cannot, the program exits by itself after 24 hours. Then read Shai-Hulud before you touch the tokens.

05Processes and connections

Activity Monitor shows memory and CPU use per process, refreshed every 5 seconds by default. A build or an install can be busy for a while, and that is normal. A process you did not start, using steady CPU, is worth a look, and suspicious processes covers how to judge one.

For connections, an outgoing firewall shows more than Activity Monitor does. Little Snitch has a network monitor that shows where your Mac connects, and you decide to allow or deny each connection. Limiting the connections in the first place is on AI agent firewall.

06The provider side: keys and bills

If something took an API key, the clue may be on the provider's side. OpenAI lets you watch key usage on its Usage page once tracking is enabled, and for a key created before December 20, 2023 tracking is not on by default. GitHub's guidance for a leaked secret includes checking logs or audit trails that show the secret being used. What to do when a key has leaked is on leaked API key.

07When to run the check

AI agent monitoring pays off most after any session that ran without prompts, after you opened an unfamiliar repository, and after anything the agent did that surprised you. If a check turns up something wrong, infostealer check is the next page.

08Do not rely on the agent's own account

An agent's summary of its work can be wrong. Replit's agent told its user a rollback was impossible, and the rollback worked. Gemini CLI said it had failed completely after it had moved files into a directory that never existed. AI models cannot assess their own capabilities, so check the record above, not the summary.

Reading these places by hand is a spot check and does not run while you sleep. If you would rather not do this by hand, Artificial Immunity's free, open-source core does the watching and only reports, it blocks nothing.

09The short version

AI agent monitoring is a short list of places to look. They are the session transcript, a command log, git history, startup items, running programs, connections and the provider's usage page. Check them yourself after anything odd, and do not take the agent's word for what it did.

FAQ

How do you monitor AI agents?

Look in the places an agent leaves traces. For Claude Code that means local session transcripts and a command log from a hook, then git history, startup items, running processes and your provider's usage page. The table on this page lists each place.

Does an agent keep a record of what it did?

Claude Code stores session transcripts locally in plaintext for 30 days by default. A hook can also append every Bash command to a log file you choose. Transcripts you share with /feedback, /bug or /share are retained for 5 years.

Can I trust what the agent tells me it did?

Not on its own. Replit's agent told its user a rollback was impossible, and the rollback worked. Check the record yourself.

Is monitoring the same as blocking?

No. Monitoring shows what happened. A deny rule, a hook or a sandbox is what stops an action, and those are covered on the guardrails pages.

Where do I look for programs that start by themselves?

In System Settings, Login Items & Extensions, and in the folders /Library/LaunchAgents and ~/Library/LaunchAgents.

Sources

  1. Claude Code docs: data usage
  2. Claude Code docs: hooks guide
  3. Claude Code docs: hooks reference
  4. Cursor docs: hooks
  5. Git documentation: git-reflog
  6. Git documentation: git-log
  7. Apple Support: open items automatically when you log in
  8. Apple Support: script management with launchd
  9. Apple Support: view information about processes in Activity Monitor
  10. Apple Platform Deployment: managing background tasks in macOS
  11. Objective-See: LuLu
  12. Objective Development: Little Snitch
  13. OpenAI docs: production best practices
  14. GitHub docs: remediating a leaked secret
  15. Wiz: Mini Shai-Hulud
  16. Ars Technica: AI coding assistants chase phantoms
  17. Artificial Immunity
Want to know what your agents ran? Artificial Immunity watches the Mac where they work and reports what it finds.Get the free core