From experiments
This skill should be used when the user asks to "hookify", "optimize CLAUDE.md", "convert instructions to hooks", "enforce CLAUDE.md rules", or when starting a session to review project instructions for hookifiable rules. Analyzes CLAUDE.md/AGENTS.md for deterministic instructions convertible to Claude Code hooks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/experiments:hookifyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Convert deterministic CLAUDE.md/AGENTS.md instructions into enforced Claude Code hooks.
Convert deterministic CLAUDE.md/AGENTS.md instructions into enforced Claude Code hooks.
CLAUDE.md instructions are soft rules — Claude tries to follow them but can forget or skip them. Deterministic instructions (always/never + concrete CLI action) are more reliable as hooks: zero exceptions, zero latency, zero token cost.
This skill reads project instruction files, identifies the single highest-impact hookifiable instruction, proposes it, and on user confirmation implements the hook end-to-end.
Before anything else, run:
which jq
If jq is not found, warn the user:
jq is required for hook scripts. Install it before proceeding:
- macOS:
brew install jq- Ubuntu/Debian:
sudo apt-get install jq- Other: https://jqlang.github.io/jq/download/
Stop here if jq is missing.
Read CLAUDE.md and AGENTS.md from the project root (the working directory).
Before analyzing, remove all content between HTML comment delimiters:
<!-- X start -->
...content to skip...
<!-- X end -->
Matching rules:
<!-- NX Configuration Start --> matches)X can be any identifier (e.g., nx configuration, auto-generated, plugin managed)<!-- X start --> pairs with the nearest subsequent <!-- X end --> where X is identical (case-insensitive)Only analyze content outside these managed sections.
For each instruction/rule/directive found in the unmanaged content, classify it as hookifiable or not hookifiable.
Hookifiable — an instruction is hookifiable when ALL of these are true:
Bash tool input (the command string)Examples of hookifiable instructions:
npm, yarn, pnpm in command stringsrm -rf /" — can match the exact patternnx commands with the workspace package manager prefix" — can match bare nx without prefixExamples of NOT hookifiable:
If multiple instructions are hookifiable, select the ONE with highest gain. Evaluate these factors (descending priority):
Use your judgment to weigh these factors. No scoring formula — pick the clear winner.
Report:
All good! No hookifiable instructions found in your project files. All instructions are either managed sections (auto-generated) or conceptual guidance that requires human judgment.
Stop here.
Present it using this format:
Source: CLAUDE.md or AGENTS.md, line(s) N-M
Original instruction: Quote the instruction text here.
Proposed hook: PreToolUse on Bash tool
What the hook does: Describe what the bash script will match and block (1-2 sentences).
Why this is better as a hook: Describe deterministic enforcement, token savings, etc. (1-2 sentences).
Use the AskUserQuestion tool to ask:
Convert this instruction to a hook? (yes/no)
On confirmation, do all three of these:
Write to .claude/hooks/hookify-<slug>.sh where <slug> is a kebab-case descriptor (e.g., enforce-bun, block-force-push).
Template:
#!/usr/bin/env bash
# Generated by hookify — <short description>
# Source: <file>:<line range>
set -euo pipefail
# Read tool input from stdin
INPUT=$(cat)
# Extract the command being run
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
if [ -z "$COMMAND" ]; then
exit 0
fi
# <PATTERN MATCHING LOGIC>
# Match against the rule and exit 2 with descriptive message on violation
# Exit 0 if the command is allowed
<custom matching logic here>
Key rules for the script:
.tool_input.command via jqbun add instead of npm install")chmod +x)Read .claude/settings.json (or create if missing). Add the hook entry under hooks.PreToolUse:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/hookify-<slug>.sh"
}
]
}
]
}
}
If hooks.PreToolUse already has entries, append the new matcher only when no existing matcher applies. If an existing entry already matches Bash, append to its hooks array only if the same command path is not already present (dedupe by command string). Preserve all existing settings.
Remove the instruction (and any supporting content like tables or examples that are now redundant — the hook's stderr message replaces them) from the source file.
After removal:
/experiments:hookify): always runs full analysis regardless of prior runs in the session.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub pabloimrik17/monolab --plugin experiments