Guard Rules

Guard Rules is a skill for Claude Code, Codex from hex/claude-guard. It costs 190 tokens per session (3,382 once invoked), scanned D, original, MIT.

A set of safety rules for commands run by Claude Code, an AI coding assistant.

In plain words
What is it for?
Use it to understand why a command was blocked, which commands require confirmation, and how to choose safer alternatives. It covers risks involving files, databases, Kubernetes, cloud services, and GitHub.
Why use it?
It helps prevent dangerous actions such as deleting important files, destroying disks, exposing credentials, or removing cloud resources without confirmation.

Skill for Claude CodeCodex

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the claude-guard plugin — 1 skill, 1 command, 2 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hex/claude-guard/guard-rules
Any agent
npx skills add hex/claude-guard --skill guard-rules
Clone the repo
git clone --depth 1 https://github.com/hex/claude-guard

Made for: Claude Code, Codex.

Or install claude-guard, the plugin that ships this one along with the rest of its 1 skill, 1 command, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for Guard Rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/hex/claude-guard/guard-rules.svg)](https://agentmods.dev/skills/hex/claude-guard/guard-rules)
Your own site
<a href="https://agentmods.dev/skills/hex/claude-guard/guard-rules"><img src="https://agentmods.dev/badge/skills/hex/claude-guard/guard-rules.svg" alt="Measured on agentmods" height="20"></a>
Per session 190 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,382 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 3 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00190 $0.03382
Opus 5 $0.00095 $0.01691
Sonnet 5 $0.00038 $0.00676
Haiku 4.5 $0.00019 $0.00338

Measured 3d ago against content hash dd90b97a1069, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade D, and why

Guard Rules scanned grade D with 3 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

- **Pipe-to-interpreter**: `... | bash`, `| bash -s`, `| sudo bash`, `| python3` (which read stdin as code) are blocked; piping *data* into a script file (`cat data | python3 app.py`) is allowed

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

description: This skill should be used when a command is blocked by claude-guard, when the response contains "BLOCKED by claude-guard", when the user asks "why was my command blocked", "what commands are blocked", "guard

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- **Process substitution downloads**: `bash <(curl ...)`, `source <(wget ...)` — executes arbitrary remote code
skills/guard-rules/SKILL.md · 251 lines

How it starts

The opening of the file, as written. The whole thing — 251 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Guard Rules

The claude-guard plugin enforces a three-tier safety model that prevents destructive operations before they execute and warns about credential exposure after file writes. Understanding these tiers enables working effectively within the safety boundaries and selecting safe alternatives without triggering blocks.

Three-Tier Safety Model

Tier 1: Hard Deny

Catastrophic, irreversible commands that must never be executed by an AI agent. When a command is blocked at this tier, inform the user that the command must be run manually if truly needed. Do not attempt to find workarounds or alternative phrasings.

Categories:

  • Filesystem catastrophe: rm -rf /, rm -rf ~, rm -rf $HOME
  • Disk destruction: dd writing to block devices, mkfs, fdisk
  • Database catastrophe: DROP DATABASE, DROP SCHEMA
  • Kubernetes catastrophe: kubectl delete namespace, kubectl delete --all
  • AWS catastrophe: aws s3 rb --force, aws ec2 terminate-instances, aws rds delete-db-instance, aws rds delete-db-cluster
  • GCP catastrophe: gcloud projects delete
  • GitHub CLI catastrophe: gh repo delete
  • DNS catastrophe: aws route53 delete-hosted-zone

Tier 2: Confirm with User

Dangerous commands that have a safer alternative. The user is prompted for confirmation before execution. If the user approves, the command proceeds. If denied, suggest the safer alternative listed below.

Git Operations:

Blocked Command Safe Alternative
git push --force / -f git push --force-with-lease
git reset --hard git stash first, then reset
git reset --merge git stash first, then reset
git checkout -- . or git checkout -- <path> git stash or git diff first
git restore (not --staged) git restore --staged or git stash
git clean -f git clean -n (dry run) first
git branch -D git branch -d (merge check)
git stash drop/clear git stash list first
git commit --no-verify Remove flag, fix hook failures
git push --no-verify Remove flag, fix hook failures
git checkout . / git checkout <path> git stash or git diff first
git filter-branch, git reflog expire, git gc --prune=now Irreversible history rewrite/prune — confirm intent
git update-ref -d, git push --mirror Deletes/overwrites refs — confirm scope first

Read the full file on GitHub · 251 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 251 lines · 190 tokens per session scan D dd90b97a1069

Subscribe to this mod's changes

Guard Rules is a skill published in the GitHub repository hex/claude-guard (2 stars, last pushed 1mo ago), licensed MIT. It adds 190 tokens to every session and 3,382 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it D with 3 findings (asks for root, recursive force delete, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

wordpress-plugin-fundamentals

Modern WordPress plugin development with PHP 8.3+, OOP architecture, hooks system, database interactions, and Settings API.

bobmatnyc/claude-mpm-skills · 32 tokens

dsh-hooks-authoring

编写或调试已安装的 dsh-hooks-plugin 的 hook 脚本。配置在 /.dsh/hooks.json,事件挂 PreToolUse/PostToolUse/UserPromptSubmit/SessionStart 等;命令从 toolinput.command 读,决策只能通过 stdout JSON 表达(permissionDecision deny/ask/allow),退出码不 gate,hookEventName 必须回填,Windows 上 command 由 PowerShell 解释且可能被沙箱拦外部 exe。.

KYinCode/dsh-hooks-plugin · 112 tokens

rules

Show all active rules. Use when the user says "/rules", "show rules", "list rules", "what are my rules", or wants to see their current persistent instructions.

Lexxes-Projects/obey · 38 tokens

forget

Remove a rule. Use when the user says "/forget", "forget rule", "remove rule", "delete rule", or wants to stop a rule from being enforced.

Lexxes-Projects/obey · 36 tokens

claude-automation-recommender

Analyze a codebase and recommend Claude Code automations (hooks, subagents, skills, plugins, MCP servers). Use when user asks for automation recommendations, wants to optimize their Claude Code setup, mentions improving Claude Code workflows, asks how to first set up Claude Code for a project, or wants to know what…

mahmoud20138/Tradecraft · 77 tokens

remember

Save a rule that Claude must follow. Use when the user says "/remember", "remember this", "save this rule", or wants to save a persistent instruction that should be enforced across sessions.

Lexxes-Projects/obey · 41 tokens