agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what…
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
Claude Code
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill hooks --agent claude-code
Codex
$ npx skills add nimadorostkar/Claude-Skills-collection --skill hooks -a codex -y
Cursor
$ npx skills add nimadorostkar/Claude-Skills-collection --skill hooks -a cursor -y
Gemini CLI
$ npx skills add nimadorostkar/Claude-Skills-collection --skill hooks -a gemini-cli -y
GitHub Copilot
$ npx skills add nimadorostkar/Claude-Skills-collection --skill hooks -a github-copilot -y
OpenCode
$ npx skills add nimadorostkar/Claude-Skills-collection --skill hooks -a opencode -y
Windsurf
$ npx skills add nimadorostkar/Claude-Skills-collection --skill hooks -a windsurf -y
name: hooks description: 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. metadata: category: agent-tooling version: 1.0.0 tags: [hooks, automation, lifecycle, enforcement]
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.
1. **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. 2. **Choose the event** — Before a tool call to block or validate; after one to format or verify; on session start to inject context. 3. **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. 4. **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. 5. **Prefer fixing over blocking** — A hook that formats the file is better than one that rejects the edit and demands the model format it. 6. **Test the hook itself** — A broken hook blocks everything, and the failure mode is confusing.
**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 0
The model receives the message, understands why it was blocked, and uses the suggested alternative — rather than retrying the same command.
A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory,…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling,…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base…
Use when creating reusable slash commands for an agent. Covers when a command beats a skill, argument handling, composing tool…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.