agentleFS
agenticlukeagenticluke/hookify-guardrails-plus/skill/SKILL.md

hookify-rules

Skill0 starsChanged 48 days agoMITView on GitHub

Use this skill when the user asks to create, write, add, or set up Hookify rules, or needs help with Hookify rule patterns and syntax.

  • Reads credentials
  • Deletes or force-pushes

8 other projects use a version of this, 8 of them edited.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 1 is common, 6 are distinctive, and 8 are very specific to this project.

  • 1

    Common

    Most of the 8 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep the rule name short and clear.

    line 18
  2. Very specific:

    Use either pattern or conditions.

    line 46
  3. Distinctive:

    Use this for work rules, such as requiring a plan for a large change.

    line 95
  4. Very specific:

    Use all only when the same rule makes sense for every event.

    line 101
  5. Very specific:

    Use conditions when every check must pass.

    line 105
  6. Common:

    All conditions must match for the rule to run.

    line 125
  7. Very specific:

    Do not use a field from the wrong event.

    line 135
  8. Distinctive:

    Use a clear pattern:

    line 178
  9. Distinctive:

    If the pattern contains a single quote, write two single quotes inside the YAML string:

    line 216
  10. Distinctive:

    Test the pattern against text that should match:

    line 224
  11. Very specific:

    Test the full rule in a safe place before using action: block.

    line 238
  12. Very specific:

    Put rules in the project root .claude/ folder.

    line 278
  13. Very specific:

    Add .claude/*.local.md to .gitignore if rules should stay local.

    line 281
  14. Distinctive:

    Do not put keys, passwords, or private data in a rule or its message.

    line 282
  15. Very specific:

    Use warn for advice. Use block only when the action must not run.

    line 284

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Write Hookify Rules

What a Rule Does

A Hookify rule checks an action for a text pattern. When the pattern matches, the rule shows a message or blocks the action.

Store each rule in this path:

.claude/hookify.{rule-name}.local.md

Keep the rule name short and clear.

Basic Rule

---
name: warn-force-delete
enabled: true
event: bash
action: warn
pattern: rm\s+-rf
---

This command can delete many files. Check the path before you run it.

The message after the frontmatter is shown when the rule runs.

Frontmatter Fields

FieldNeededAllowed valuesPurpose
nameYesA unique kebab-case nameNames the rule. Start with warn-, block-, or require- when it fits.
enabledYestrue or falseTurns the rule on or off.
eventYesbash, file, stop, prompt, or allSets when the rule checks for a match.
actionNowarn or blockwarn shows a message. block stops the action. The default is warn.
patternUsuallyA regular expressionSets the text to match. Use conditions instead for more than one check.

Use either pattern or conditions. Do not use both unless your Hookify version says this is allowed.

Events

bash

Checks a shell command.

Useful patterns:

rm\s+-rf
dd\s+if=
mkfs
sudo\s+
su\s+
chmod\s+777

Match the command itself. Do not match the command output.

file

Checks a file change.

Useful patterns:

console\.log\(
debugger
eval\(
innerHTML\s*=
\.env$
credentials
\.pem$

A file rule may check the file path, old text, new text, or full content.

stop

Runs when Claude is about to stop.

Use this to remind Claude about tests, checks, or other final work. The pattern .* matches any text, including empty text in many regular expression tools. If your Hookify version does not run the rule for empty text, use a condition or test the rule first.

prompt

Checks the user's prompt.

Use this for work rules, such as requiring a plan for a large change. Keep prompt rules narrow. A wide pattern may run on tasks that do not need it.

all

Checks all supported events.

Use all only when the same rule makes sense for every event. Event data is not always the same, so test the rule for each event.

Rules With More Than One Condition

Use conditions when every check must pass.

---
name: warn-env-api-keys
enabled: true
event: file
action: warn
conditions:
  - field: file_path
    operator: regex_match
    pattern: '\.env$'
  - field: new_text
    operator: contains
    pattern: API_KEY
---

You are adding an API key to an .env file. Make sure the file is in .gitignore.

All conditions must match for the rule to run.

Fields by Event

EventFields
bashcommand
filefile_path, new_text, old_text, content
promptuser_prompt

Do not use a field from the wrong event. For example, command does not work with a file event.

Operators

OperatorMatch rule
regex_matchThe field matches a regular expression.
containsThe field includes the text.
equalsThe whole field is the same as the text.
not_containsThe field does not include the text.
starts_withThe field starts with the text.
ends_withThe field ends with the text.

These checks may be case-sensitive. Add both forms or use a case-free regular expression when needed.

Write Safe Patterns

A regular expression is a text pattern.

Common parts:

TextMeaning
\.A real dot
\(A real opening parenthesis
\sA space or other blank character
\dA number
\wA letter, number, or underscore
+One or more
*Zero or more
?Optional
``Either pattern

Avoid Wide Matches

This pattern is too wide:

log

It also matches words such as login and dialog.

Use a clear pattern:

console\.log\(

Allow Small Command Changes

This pattern is too exact:

rm -rf /tmp

This pattern allows one or more blank characters:

rm\s+-rf

Think about flags in a different order, quoted paths, full command paths, and line breaks. One pattern may not catch every form.

Quote YAML With Care

Plain patterns often work:

pattern: rm\s+-rf

Single quotes are safer when YAML may treat a character as special:

pattern: '\.env$'

Inside single quotes, keep backslashes as written. Do not add a second backslash.

If the pattern contains a single quote, write two single quotes inside the YAML string:

pattern: 'user''s file'

Test Before Use

Test the pattern against text that should match:

python3 -c "import re; print(bool(re.search(r'rm\s+-rf', 'rm   -rf build')))"

Also test text that should not match:

python3 -c "import re; print(bool(re.search(r'rm\s+-rf', 'rm -r build')))"

The first test should print True. The second should print False.

Test the full rule in a safe place before using action: block. Start with action: warn when you are not sure.

Concrete Example

The user asks:

Warn me when I add console.log to a JavaScript file.

Create this file:

.claude/hookify.warn-console-log.local.md

Use this content:

---
name: warn-console-log
enabled: true
event: file
action: warn
conditions:
  - field: file_path
    operator: regex_match
    pattern: '\.(js|jsx|ts|tsx)$'
  - field: new_text
    operator: regex_match
    pattern: 'console\.log\s*\('
---

You added console.log to a JavaScript or TypeScript file. Remove it if it is only for debug work.

This rule checks both the file name and the new text. It will not run for a Python file.

File Setup

  • Put rules in the project root .claude/ folder.
  • Name files .claude/hookify.{clear-name}.local.md.
  • Give each rule a unique name.
  • Add .claude/*.local.md to .gitignore if rules should stay local.
  • Do not put keys, passwords, or private data in a rule or its message.
  • Set enabled: false to turn off a rule without deleting it.
  • Use warn for advice. Use block only when the action must not run.

Commands

/hookify [description]

Creates a rule. With no text, it may use the current chat as the source.

/hookify-list

Shows all rules.

/hookify-configure

Turns rules on or off.

/hookify-help

Shows the full Hookify help.

Smallest Valid Rule

---
name: warn-dangerous-command
enabled: true
event: bash
pattern: dangerous_command
---

This command may be unsafe. Check it before you run it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.