calibrate-hooks
Skill1 starsChanged 6 months agoMITView on GitHub
Audits and tunes hooks across user / project / plugin-shipped layers — both the `hooks` blocks inside any `settings.json` and standalone hook scripts under `.claude/hooks/` or a plugin's `hooks/`. Flags bare-`*` matchers on hot events (`PreToolUse`/`PostToolUse`/`UserPromptSubmit`), enforcement scripts that use `exit 1` (non-blocking warning) instead of `exit 2` (block), hook commands that `curl`/`wget`/`npx` remote payloads, heavy work (`build`/`test`/`tsc`/`webpack`) on hot events, hooks pointing to non-local binaries, duplicates across layers, and invalid JSON. Also scaffolds the `create` row when a recurring `subagent:missing-tools`, `skill:side-effecting-no-dmi`, `claude-md:must-rule-with-no-hook`, or `hook:exit-1-non-blocking` pattern needs a new enforcement hook. Invoked by the calibration orchestrator (`/calibrate`) and standalone via `/claude-calibration:calibrate-hooks`.
- Pipes a download into a shell
In this repository25 other files it gives its agents.
- agents/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- .claude/skills/CLAUDE.mdCLAUDE.md
- hooks/CLAUDE.mdCLAUDE.md
- rules/CLAUDE.mdCLAUDE.md
- skills/CLAUDE.mdCLAUDE.md
- docs-statusSkill
- docs-updateSkill
- plugin-updateSkill
- calibrate-claude-mdSkill
- calibrate-generalSkill
- calibrate-mcpSkill
- calibrate-pluginsSkill
- calibrate-rulesSkill
- calibrate-settingsSkill
- calibrateSkill
- calibrate-skillsSkill
- calibrate-subagentsSkill
- calibration-auditSkill
- calibration-diffSkill
- calibration-doctorSkill
- calibration-flowSkill
- calibration-onboardingSkill
- calibrationSkill
- calibration-trackSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 82
When the planner detects a recurrence that this bundle owns (per rules/dispatch.md):
- Very specific: line 104
After every edit or create, re-run bash <BUNDLE>/scripts/lint.sh <changed path> and record verify: ✓ if the signature no longer fires (or …
- Very specific: line 109
Never wire a hook that fetches a remote payload at fire time (curl/wget/npx <remote>).
- Very specific: line 111
Never use exit 1 when the intent is to block — Claude treats it as a non-blocking warning.
- Very specific: line 112
Never put build/test/tsc/webpack/compile on a PreToolUse/PostToolUse hook — defer to Stop.
- Distinctive: line 116
Don't reformat unrelated content when applying a fix.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
calibrate-hooks — per-feature bundle
You audit and tune hook configurations and hook scripts. Two entry points:
- Direct invocation (
/claude-calibration:calibrate-hooks) — audit everything, report findings, propose fixes inline. - Dispatch from the calibrator — one approved plan row at a time, applied surgically.
The workflow is the same; only the framing differs.
1. Enumerate
bash <BUNDLE>/scripts/enumerate.sh "$PROJECT_DIR"Yields TSV scope\tpath. Scope is settings (a settings.json with a hooks block — user or
project), script (a project-local hook script under .claude/hooks/), script-user (user
hook script under ~/.claude/hooks/), or plugin-self (when the project is itself a plugin and
ships hooks at <plugin-root>/hooks/).
2. Lint
bash <BUNDLE>/scripts/lint.sh <path …>Yields TSV path\tsignature\tseverity\tdetail. The signatures this bundle owns
(see reference.md):
hook:matcher-bare-star(MEDIUM)hook:exit-1-non-blocking(HIGH)hook:remote-untrusted(HIGH)hook:duplicate-across-layers(LOW) — only fires when multiple settings files are passedhook:not-locally-sourced(LOW)hook:heavy-on-pretooluse-heuristic(MEDIUM)hook:invalid-json(HIGH)
3. Fix — kind: edit rows
For each finding, the remediation pattern lives in examples/<case>/:
hook:matcher-bare-star→examples/matcher-bare-star/{before,after}.md. Narrow the matcher to the specific tool(s) (Edit|Write|MultiEdit) plus a path pattern. Bare*on a hot event fires on every tool call.hook:exit-1-non-blocking→examples/exit-1-non-blocking/{before,after}.md. Replaceexit 1withexit 2when the intent is to block; keepexit 1only for non-blocking warnings. The semantics:exit 0= pass,exit 1= non-blocking warning surfaced to the user,exit 2= block the tool call and surface stderr to Claude.hook:remote-untrusted→ vendor the script locally under${CLAUDE_PROJECT_DIR}/.claude/hooks/or${CLAUDE_PLUGIN_ROOT}/hooks/. Hooks thatcurl | shre-fetch on every fire and are a supply-chain risk.hook:heavy-on-pretooluse-heuristic→ move the heavy work to aStophook (runs at session end) or a manual command.PreToolUse/PostToolUsemust stay sub-second.hook:not-locally-sourced→ point the command at${CLAUDE_PROJECT_DIR}/...or${CLAUDE_PLUGIN_ROOT}/...rather than relying on systemPATH.hook:duplicate-across-layers→ delete the duplicate from one layer (usually the user layer defers to project, or vice versa — keep the one closer to the change).hook:invalid-json→ fix the JSON. Runpython3 -m json.tool <settings.json>to find the parse error.
4. Create — kind: create rows
When the planner detects a recurrence that this bundle owns (per rules/dispatch.md):
subagent:missing-tools×N → scaffold aPreToolUsehook onEdit(.claude/agents/*.md)that fails (exit 2) when the edited file lackstools:frontmatter. Usetemplates/hooks.json.tmpl.skill:side-effecting-no-dmi×N → similarPreToolUsehook onEdit(.claude/skills/*/SKILL.md)requiringdisable-model-invocation: truewhen the body contains side-effecting verbs. Usetemplates/hooks.json.tmpl.claude-md:must-rule-with-no-hook×N → for each recurring "must"/"never" rule, scaffold the matching enforcement hook (aPreToolUsematcher that fails on the disallowed pattern). Usetemplates/hooks.json.tmpl.hook:exit-1-non-blocking×N → companionStophook that lints.claude/rules/hook-conventions.mdis in sync (the rule itself is created bycalibrate-rules).
For each, copy templates/hooks.json.tmpl, fill in {{matcher}}, {{command}},
{{description}}, and append the block to the right settings.json layer (project for
project-wide enforcement; plugin-shipped at hooks/hooks.json when the recurrence is across
many projects under a plugin author's control).
5. Verify
After every edit or create, re-run bash <BUNDLE>/scripts/lint.sh <changed path> and record
verify: ✓ if the signature no longer fires (or verify: ✗ <signature> if it still does).
Hard rules
- Never wire a hook that fetches a remote payload at fire time (
curl/wget/npx <remote>). Vendor the script under${CLAUDE_PROJECT_DIR}or${CLAUDE_PLUGIN_ROOT}. - Never use
exit 1when the intent is to block — Claude treats it as a non-blocking warning. - Never put
build/test/tsc/webpack/compileon aPreToolUse/PostToolUsehook — defer toStop. - Preserve early-exit-when-not-applicable behaviour in any hook this bundle authors (zero-cost when the hook doesn't apply).
- Don't reformat unrelated content when applying a fix.
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
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.

