The skill allows persistent policy injection via local files, enabling
Claims to do
Writing Hookify Rules: Hookify rules are markdown files with YAML frontmatter that define patterns to watch for and messages to show when those patterns match. Rules are stored in `.claude/hookify.{rule-name}.local.md` files.
Actually does
This skill provides comprehensive instructions and examples for users to create and manage 'Hookify' rules. These rules are markdown files stored locally (`.claude/hookify.{rule-name}.local.md`) that define regex patterns and conditions to watch for in bash commands, file operations, agent stop events, or user prompts. When a pattern matches, the rule can trigger a warning message or block an operation. The skill itself does not execute commands, access data, or contact external URLs; it only describes how to configure a separate system.
The skill enables the definition and dynamic loading of arbitrary 'Hookify Rules' from local files (`.claude/hookify.{rule-name}.local.md`). An attacker with write access to these files can inject persistent policies to gain broad control over the agent's behavior, including blocking or warning about specific actions (`action: block|warn`), monitoring various events (bash commands, file operations, user prompts), and potentially hijacking the agent's goals or performing reconnaissance.
Rules are stored in `.claude/hookify.{rule-name}.local.md` files. (Line 10)
rules are read dynamically on next tool use (Line 180)
`action`: `warn`|`block` (Lines 50-53)
`event`: `bash`|`file`|`stop`|`prompt` (Lines 40-45)
Condition fields: `command`, `file_path`, `new_text`, `old_text`, `content`, `user_prompt` (Lines 100-103, 230-232)The `pattern` field uses Python regex syntax. Maliciously crafted complex regular expressions could lead to Regular Expression Denial of Service (ReDoS) when evaluated against input, potentially consuming excessive CPU resources and impacting agent performance or availability.
`pattern` (simple format): Regex pattern to match ... Python regex syntax (Lines 57-59) operator: `regex_match` (Line 96)
The skill refers to example rules located at `${CLAUDE_PLUGIN_ROOT}/examples/`. If these examples are not carefully vetted or if the `CLAUDE_PLUGIN_ROOT` can be manipulated, an attacker could introduce malicious example rules that an agent or user might adopt, leading to compromised behavior.
See `${CLAUDE_PLUGIN_ROOT}/examples/` for complete examples (Line 209)The `Message Body` of a rule is displayed to Claude when triggered. This allows for crafting messages that can influence the agent's reasoning, provide biased information, or, if relayed to a human, social engineer the human overseer, potentially leading to approval fatigue or misinformed decisions.
The markdown content after frontmatter is shown to Claude when the rule triggers. (Line 118) Explain what was detected, Explain why it's problematic, Suggest alternatives or best practices (Lines 121-123)
[](https://mondoo.com/ai-agent-security/skills/github/anthropics/claude-code/writing-rules)<a href="https://mondoo.com/ai-agent-security/skills/github/anthropics/claude-code/writing-rules"><img src="https://mondoo.com/ai-agent-security/api/badge/github/anthropics/claude-code/writing-rules.svg" alt="Mondoo Skill Check" /></a>https://mondoo.com/ai-agent-security/api/badge/github/anthropics/claude-code/writing-rules.svgSkills can read files, run commands, and access credentials. Mondoo helps organizations manage the security risks of AI agent skills across their entire fleet.