Skip to content
agents.store
opsoperations

agent-guard-ops

Safety guards for Claude Code, three PreToolUse hooks that ask before the riskiest operations and stay silent on everyday work: irreversible deletion, takeover of the host or of the guards themselves, and secrets leaving the machine. One hook for Bash, one for MCP tools, one for the file tools. Never blocks, only asks. The host's own production paths, trusted domains and API hosts are set once in the plugin options, nothing is built into the code.

v1.0.3Updated

  • safety
  • guard
  • hooks
  • pretooluse
  • permissions
  • secrets
  • destructive-commands
  • ops
  • agents-store

Install

Pick your agent for the steps.

Install on Claude Code

  1. 1.Add the marketplace

    /plugin marketplace add Agents-Store/claude-plugins
  2. 2.Install the plugin

    /plugin install agent-guard-ops@agents-store-claude-plugins

    Type it inside Claude Code.

Claude Code install docs

What is inside

Skills (1)

  • examples

    This skill should be used when the user asks "why did the guard ask me", "what does agent-guard-ops protect", "set up the guard for my server", "add my domain or production folder to the guard", "the guard asks about my own API", "how do I approve or change a guard", or wants an end-to-end walkthrough of the guard hooks and their options.

Hooks (1)

  • PreToolUse

README

Safety guards for Claude Code, shipped as three PreToolUse hooks. They ask before the riskiest operations and say nothing about everyday work, so a prompt always means something and is not approved out of habit.

The hooks never deny: the decision is ask, the user can always approve. A hook that cannot read its input, or fails, asks as well, because a crashing guard that stays silent is a silent allow.

What asks

RiskAsks beforePasses
Irreversible deletionrecursive removal of a repository or of a folder of repositories, a home directory, a system or production path, Claude's memory; find ... -delete under such a path; Docker volumes and every prune; compose down -v; DROP and TRUNCATE; force push, branch deletion, reset --hard, clean -f, a whole-tree checkout .; stopping or removing a container that has been up longer than long_running_hours; Dokploy, GitHub, Infisical, Cloudflare and Directus deletionsrm -rf node_modules, dist, a path in /tmp, one file's checkout, fresh test containers
Takeover of the host or of the guardswrites into the system directories, ~/.ssh, ~/.config, Claude Code's settings, plugins and hooks, a project's .claude/settings*.json and .claude/hooks/, .mcp.json, git hooks, and every path in production_paths; the plugin's own files; a pipe of a download into a shell; privileged or docker.sock containers; crontab, users, firewall; stopping docker, ssh, nginx (also nginx -s stop); nginx run with a configuration of its own (-c, -p, -g, even with -t), which hands the host's nginx temp folders to another user; apt without NEEDRESTART_MODE=l; making a repository public; collaborators, deploy keys, branch protectioncode, docs, rules, memory, scratch files
Secrets leaving the machinea secrets file (.env* except .env.example, settings.local.json, .mcp.json, SSH keys, *.pem, credentials) sent by curl, wget, scp, rsync or gist; a variable named ...KEY, ...TOKEN, ...SECRET, ...PASSWORD sent to a host that is not its own service; env, printenv or cat .env piped into a sender; a raw nc to another machine; Google Drive share_file; a new GitHub repository that is not privatea key sent to a trusted host, writes to localhost
The guards themselvesan edit or write of any file under a folder named agent-guard-ops (a copy of the Agents Store repository, the plugin cache), a write there through the GitHub MCP, and the merge of a pull request in Agents-Store/claude-plugins (a merge cannot be tied to the plugin without the network, so every merge there asks)any other plugin's files, reading the guard files

Commands the guard cannot fully read ($(...), heredocs, eval) are not asked: the permission rules and the auto-mode classifier judge them. A guard that asks on every substitution gets approved blindly.

The three hooks

HookMatcherFile
BashBashhooks/guard-bash.sh
MCP toolsmcp__.*hooks/guard-mcp.sh
File toolsEdit|Write|MultiEdit|NotebookEdithooks/guard-files.sh

They need bash, git (for the merge check) and python3 3.7 or newer (the hooks use subprocess.run(capture_output=..., text=...)). Python is started by its full system path first (a pyenv shim in a folder whose .python-version is not installed would exit 1 and make the guard ask about everything); PATH is only the fallback.

The MCP guard covers Dokploy (deletion, exposure, takeover), GitHub (a repository that is not private, the guards' own files), Directus and Plane deletions, Google Drive sharing and trashing, Cloudflare and Sentry deletions. Read-only tools of every other server are untouched.

Options

The hooks hold no host name, no domain and no path of any machine. What belongs to one machine is an option of the plugin, asked once in the dialog that appears when the plugin is enabled (list options are not shown in the /config panel; to see or change them later use claude plugin configure agent-guard-ops, which saves values from stdin with --values-stdin) and stored in the user's settings under pluginConfigs. Claude Code exports each option to the hooks as CLAUDE_PLUGIN_OPTION_<KEY>. Project and local settings cannot set them, so a cloned repository cannot widen the guard.

OptionTypeDefaultMeaning
production_pathslist of stringsemptyAbsolute paths where production lives. A write or deletion there asks, on top of the built-in system paths.
trusted_domainslist of stringsemptyDomain suffixes of your own services. A key may go to them and to any subdomain.
trusted_api_hostslist of stringsemptyExact hosts of your own APIs. A key may go there, and a DELETE request there asks.
long_running_hoursnumber6A container up longer than this counts as production.

A list is read as a JSON array (["/srv/<app>", "/srv/<db>"]) or as a plain text split on commas and newlines. A value that cannot be read leaves the built-in defaults in force; it never makes the hook fail. Leaving every option empty is a valid install: the system paths and the public API hosts built into the guard (GitHub, Cloudflare, Stripe, OpenAI, Google, Anthropic and similar) still apply.

Example for a machine with one application folder and its own domain:

{
  "pluginConfigs": {
    "agent-guard-ops@agents-store-claude-plugins": {
      "options": {
        "production_paths": ["/srv/<app>", "/srv/<app-db>"],
        "trusted_domains": ["example.com"],
        "trusted_api_hosts": ["deploy.example.org"],
        "long_running_hours": 12
      }
    }
  }
}

The settings file itself is a guarded path: a write to ~/.claude/settings.json (or to $CLAUDE_CONFIG_DIR/settings.json when that variable moves Claude's configuration), by the file tools or by a shell command, asks. So do claude plugin disable, uninstall, remove and configure for this plugin (or with no plugin name), and claude plugin marketplace remove: one command each would otherwise switch the guards off or rewrite their options.

Limits

This is a tripwire for the agent's own commands, not a sandbox. Not modelled: what a script file does once it runs, functions and aliases defined earlier in the session, variables set earlier in the same command, git aliases, arithmetic evaluation. Claude Code's permission rules (permissions in settings.json) are the real boundary. See the header of hooks/guard-bash.sh for the full list.

Tests

tests/ holds three shell suites, one per hook, that feed each hook a PreToolUse payload on stdin and read only its JSON answer. No command of a test runs, nothing is written outside a temporary directory, there is no network. GUARD_HOOK=<copy of a hook> points a suite at a mutant copy of the hook.

bash tests/guard-bash.test.sh
bash tests/guard-mcp.test.sh
bash tests/guard-files.test.sh
bash tests/old-bash.test.sh   # every hook under bash 3.2, the /bin/bash of macOS (skips where /bin/bash is newer)

Installation

claude plugin marketplace add Agents-Store/claude-plugins
claude plugin install agent-guard-ops@agents-store-claude-plugins