hooks
Skill33 starsChanged 22 days agoMITView on GitHub
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should not be trusted to remember, and avoiding hooks that make an agent unusable. Trigger on "run prettier after every edit", "block rm -rf", "claude keeps forgetting to run tests". Do not use for guidance the agent should usually follow — see the agent-instructions skill; for a workflow run on demand, see the slash-commands skill.
- Deletes or force-pushes
- Commits and pushes
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 20 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 54
Do not put slow operations in a synchronous hook.
- Distinctive: line 82
Every file the agent writes is formatted.
“Common” is measured: kept by at least 6 in 10 of the 20 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.
Files
Hooks
Purpose
Enforce a rule deterministically rather than asking the model to remember it. A hook runs every time, regardless of the model's attention, its context, or its mood — which is exactly what a rule requires.
When to Use
- A rule must hold every time: formatting, a forbidden command, a required check.
- The agent keeps forgetting an instruction despite it being in the instructions.
- Automating a step that should happen around every edit or command.
- Blocking a dangerous action before it executes.
Capabilities
- Lifecycle events: before and after a tool call, on session start, on stop.
- Deterministic enforcement: formatting, linting, blocking.
- Injecting context at the right moment.
- Notification and logging.
Inputs
- The rule and when it must apply.
- The event that should trigger it.
- What should happen when it fails: block, warn, or fix.
Outputs
- Hook configuration that runs reliably.
- Rules enforced without depending on the model's memory.
- A fast hook — one that does not make the agent unpleasant to use.
Workflow
- Identify the rule that keeps being broken — If an instruction is in the instruction file and is still violated, it is a hook, not an instruction. Instructions are guidance; hooks are enforcement.
- Choose the event — Before a tool call to block or validate; after one to format or verify; on session start to inject context.
- Make it fast — A hook runs on every matching event. Two seconds on every file edit is a hostile environment. Under 500ms, or run it asynchronously.
- Fail informatively — A hook that blocks must say why and what to do instead. A silent block is maddening and the model cannot recover from it.
- Prefer fixing over blocking — A hook that formats the file is better than one that rejects the edit and demands the model format it.
- Test the hook itself — A broken hook blocks everything, and the failure mode is confusing.
Best Practices
- A rule the model must remember is a rule the model will eventually forget. If it matters, enforce it in a hook.
- Do not put slow operations in a synchronous hook. A full test suite on every edit is a way to make the agent unusable.
- Blocking hooks must explain themselves.
exit 2with an explanatory message on stderr is what lets the model correct course. - Match narrowly. A hook that fires on every tool call, including reads, wastes time on operations it does not care about.
- Auto-formatting after an edit is the single most valuable hook: it removes an entire class of diff noise and lint failures for free.
- Guard against the destructive command (
rm -rf, a force push, a production deploy) in a pre-tool hook. This is cheap insurance.
Examples
Format on write — the highest-value hook:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_FILE_PATHS\" | grep -qE '\\.(ts|tsx)$'; then pnpm prettier --write $CLAUDE_FILE_PATHS 2>/dev/null; fi"
}
]
}
]
}
}Every file the agent writes is formatted. The model never has to think about it, the diff is always clean, and the lint step never fails on formatting.
Blocking a destructive command, with an explanation the model can act on:
#!/usr/bin/env bash
# PreToolUse hook on Bash. Exit 2 blocks the call; stderr is shown to the model.
set -euo pipefail
command=$(jq -r '.tool_input.command' <<<"$(cat)")
if [[ "$command" =~ (^|[[:space:]])rm[[:space:]]+(-[a-zA-Z]*f[a-zA-Z]*[[:space:]]+)*/ ]]; then
echo "Blocked: 'rm -rf' targeting an absolute path is not permitted." >&2
echo "If you need to remove build artifacts, use 'pnpm clean'." >&2
exit 2
fi
if [[ "$command" =~ git[[:space:]]+push.*--force([[:space:]]|$) ]]; then
echo "Blocked: force-push is not permitted on this repository." >&2
echo "Use 'git push --force-with-lease' if you must rewrite a branch you own." >&2
exit 2
fi
exit 0The model receives the message, understands why it was blocked, and uses the suggested alternative — rather than retrying the same command.
Notes
- Exit code 2 from a
PreToolUsehook blocks the tool call and returns stderr to the model. Any other non-zero code is treated as a hook error, which is a different and less useful outcome. - Hooks run with your credentials and permissions. A hook is arbitrary code executing on every matching event — review them as carefully as any other code with that reach.
- The instinct to add many hooks should be resisted. Each one is latency on every operation. Add the ones that prevent real, observed failures.
Other versions21 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 21
- parcadei/Continuous-Claude★ 3.9ksame name
- parcadei/Continuous-Claude-v2★ 3.9ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- duncan-buildroom/freeskills★ 65same name
- AI-Answer/ContentRepurposeSystem★ 26same name
- duncan-buildroom/profit-room-skills★ 18same name
- coopersimson96/ai-content-system★ 17same name
- issue-orchestrator/issue-orchestrator★ 10same name
- Samin12/skills★ 8same name
- Samin12/content-skill-pack★ 5same name
11 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use yt-titles, outlines and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Samin12Skillyt-titles
Generate high-performing YouTube title ideas based on the user's video content description, cross-referenced with your recent top-performing videos. Use this skill whenever the user wants YouTube title suggestions, asks "what should I title this video", "give me title ideas", "title options for my video about...", "help me name this video", brainstorming video titles, or any request involving YouTube title generation or optimization. Also trigger when the user mentions titling, naming, or headlining a YouTube video even casually.
Also in 3 projects that use this
Clay-HHKSkilloutlines
Guarantee valid JSON/XML/code structure during generation, use Pydantic models for type-safe outputs, support local models (Transformers, vLLM), and maximize inference speed with Outlines - dottxt.ai's structured generation library
Also in 3 projects that use this
BlockSkillfrontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Also in 3 projects that use this
In this repository137 other files it gives its agents.
- agent-instructionsSkill
- agent-memorySkill
- plugin-developmentSkill
- skill-authoringSkill
- skill-reviewSkill
- slash-commandsSkill
- subagentsSkill
- agent-designSkill
- context-engineeringSkill
- fine-tuningSkill
- llm-cost-optimizationSkill
- llm-evaluationSkill
- llm-integrationSkill
- mcp-serverSkill
- ml-pipelineSkill
- model-selectionSkill
- prompt-engineeringSkill
- ragSkill
- structured-outputSkill
- api-designSkill
- background-jobsSkill
- cachingSkill
- djangoSkill
- event-driven-architectureSkill
- fastapiSkill
- graphqlSkill
- microservicesSkill
- nestjsSkill
- realtime-websocketsSkill
- spring-bootSkill
- competitive-analysisSkill
- lead-researchSkill
- product-analysisSkill
- resumeSkill
- user-researchSkill
- database-performanceSkill
- data-modelingSkill
- data-qualitySkill
- pandasSkill
- postgresSkill
- sparkSkill
- brand-guidelinesSkill
- generative-artSkill
- themingSkill
- ui-reviewSkill
- visual-designSkill
- architecture-decisionsSkill
- bug-fix-protocolSkill
- cli-developmentSkill
- code-reviewSkill
- debuggingSkill
- design-patternsSkill
- domain-modelingSkill
- git-workflowSkill
- legacy-modernizationSkill
- refactoringSkill
- repository-explorationSkill
- simple-designSkill
- system-designSkill
- aws-cdkSkill
- The first 60 shown.
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.

