Set up Guard
Install
Add yourself as a developer in the dashboard (Settings → Developers → Add Developer) and run the install snippet it gives you.
The snippet checks for Python 3.10 or later and your API key first, installs agentgovern 2.7.0 or later, saves your settings for new terminals and installs the hook.
Python
Guard needs Python 3.10 or later. The macOS system Python is 3.9, which is too old: install a newer one from python.org or with Homebrew (brew install python@3.12).
The Python SDK is an MIT-licensed SDK on PyPI. https://pypi.org/project/agentgovern/
What Guard sends and stores
- For each Claude Code tool call, Guard sends AgentGovern the tool's name and its full input, such as the command, the file path and any text being written, and after the call, the tool's output.
- It also sends your prompts and Claude's replies, and the folder, git branch and commit you are working in.
- Secrets in recognised formats, such as API keys, tokens, private keys and connection strings, are masked before AgentGovern stores anything. Other text, including personal data, is stored as sent.
- Inputs and outputs, up to 25 KB each, are kept for 90 days unless your organization's admin sets a different period. If PII redaction is on for your organization, a redacted copy of the full inputs and outputs is kept until your account is deleted.
- A one-line summary of each action, up to 200 characters of the command, file path, URL or search, or the first 97 characters of a prompt or reply, is kept until your account is deleted. A secret cut off by that limit may not be recognised.
- If AgentGovern can't be reached, Guard keeps your unsent prompts, tool calls with their inputs and outputs, and Claude's replies on your machine, unmasked, in ~/.agentgovern. It retries them for 48 hours, then keeps any it could not send in ~/.agentgovern/outbox-dead until you delete them or uninstall Guard.
We delete your data on request, within 30 days. After that, copies can remain for a limited time: in our database backups for up to 30 days, and in our service and error logs for up to 90 days, after which they are deleted automatically.
Uninstall
- To check it is installed, run
~/.venvs/agentgovern/bin/agentgovern hook status. It shows "Installed: yes", the four hook events, and your two variables, masked. - To stop Guard for good, run the lines for your platform below, in order: 4 on a Mac or Linux, 8 on Windows. The first prints "AgentGovern hook removed from … settings.json (all event types)."
Mac (or Linux), in Terminal:
"$HOME/.venvs/agentgovern/bin/agentgovern" hook uninstall
for AG_RC in "${ZDOTDIR:-$HOME}/.zshrc" "${ZDOTDIR:-$HOME}/.zprofile" "$HOME/.zshrc" "$HOME/.zprofile" "$HOME/.bashrc" "$HOME/.bash_profile"; do if [ -f "$AG_RC" ] && LC_ALL=C grep -a -q "# added by AgentGovern Guard$" "$AG_RC"; then ( umask 077; rm -f "$AG_RC.agentgovern.tmp" && { LC_ALL=C grep -a -v "# added by AgentGovern Guard$" "$AG_RC" >| "$AG_RC.agentgovern.tmp"; [ $? -le 1 ]; } && [ -f "$AG_RC.agentgovern.tmp" ] && cat "$AG_RC.agentgovern.tmp" >| "$AG_RC"; AG_S=$?; rm -f "$AG_RC.agentgovern.tmp"; exit $AG_S ) && echo "AgentGovern: removed its lines from $AG_RC"; fi; done
rm -rf "$HOME/.agentgovern/hook.py" "$HOME/.agentgovern/sessions" "$HOME/.agentgovern/outbox" "$HOME/.agentgovern/outbox-dead" "$HOME/.agentgovern/__pycache__" "$HOME/.venvs/agentgovern"; rmdir "$HOME/.agentgovern" 2>/dev/null; rmdir "$HOME/.venvs" 2>/dev/null
unset AGENTGOVERN_API_KEY AGENTGOVERN_ACTOR_USER_ID Windows, in PowerShell:
& "$HOME\.venvs\agentgovern\Scripts\agentgovern.exe" hook uninstall
[Environment]::SetEnvironmentVariable('AGENTGOVERN_API_KEY', [NullString]::Value, 'User')
[Environment]::SetEnvironmentVariable('AGENTGOVERN_ACTOR_USER_ID', [NullString]::Value, 'User')
foreach ($agP in "$HOME\.agentgovern\hook.py", "$HOME\.agentgovern\sessions", "$HOME\.agentgovern\outbox", "$HOME\.agentgovern\outbox-dead", "$HOME\.agentgovern\__pycache__", "$HOME\.venvs\agentgovern") { if (Test-Path $agP) { Remove-Item -Recurse -Force $agP } }
if ((Test-Path "$HOME\.agentgovern") -and -not (Get-ChildItem -Force "$HOME\.agentgovern")) { Remove-Item -Force "$HOME\.agentgovern" }
if ((Test-Path "$HOME\.venvs") -and -not (Get-ChildItem -Force "$HOME\.venvs")) { Remove-Item -Force "$HOME\.venvs" }
Remove-Item Env:\AGENTGOVERN_API_KEY -ErrorAction SilentlyContinue
Remove-Item Env:\AGENTGOVERN_ACTOR_USER_ID -ErrorAction SilentlyContinue - Run the lines in this order. The first one removes Guard from Claude Code's settings and needs the Guard install that a later line deletes.
- The first line also prints "The hook script at … was not deleted." That is expected: it only removes Guard from Claude Code's settings, and a later line deletes the hook script.
- The settings. On a Mac or Linux, the second line removes only the lines the snippet added, the ones ending in
# added by AgentGovern Guard, from~/.zshrc,~/.zprofile,~/.bashrcand~/.bash_profile. Anything else in those files stays, including anyAGENTGOVERN_line you added yourself: remove that by hand. On Windows, the twoSetEnvironmentVariablelines remove the settings saved for new windows. - Then it deletes what Guard left on disk: the hook script, Python's cache of it (
__pycache__, written whenhook statusreads the script's version) and any unsent events in~/.agentgovern(anything else you keep in that folder stays, and the folder goes only if it is then empty), and Guard's Python environment in~/.venvs/agentgovern(then~/.venvs, only if it is empty). The last lines clear the settings from the window you are in. - Then start a new Claude Code session. It shows no Guard messages and sends nothing to AgentGovern.
To pause it, delete the two lines ending in # added by AgentGovern Guard from your shell profile (on Windows, run the two SetEnvironmentVariable lines above), then open a new terminal.