creating-hooks
Skill118 starsChanged 2 months agoMITView on GitHub
Creates GitHub Copilot hooks for VS Code using `hooks.json`, supporting scripts, and companion docs. Use when automating deterministic checks, pre/post tool policies, or reusable hook packs that need safe defaults, observability, and clear installation guidance.
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill when the right answer is not more advice, but deterministic behavior at a specific lifecycle point.
- Distinctive: line 15
Use this skill when the user asks for things like:
- Distinctive: line 44
Be explicit on denial: - if a hook blocks work, explain exactly why and what to do instead.
- Distinctive: line 52
Use a hook when deterministic automation is needed at a lifecycle event.
- Distinctive: line 53
If the need is guidance only, use instructions.
- Distinctive: line 70
write the denial or warning message in user language, not policy jargon
- Distinctive: line 71
make sure the hook fails safely when inputs are missing or malformed
- Distinctive: line 75
Use the resources below as the default starting point:
- Very specific: line 88
Check the result against ./resources/hook-quality-checklist.md.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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
Creating Copilot Hooks
Use this skill when the right answer is not more advice, but deterministic behavior at a specific lifecycle point. It helps design hooks that are safe, documented, and understandable.
When to Use
Use this skill when the user asks for things like:
- "create a Copilot hook for this policy"
- "block dangerous commands before they run"
- "log or validate tool usage automatically"
- "add a reusable hook pack with docs and scripts"
- "turn this manual guardrail into a hook"
Typical scenarios:
- pre-tool checks for risky shell commands
- post-tool validation or formatting triggers
- audit or observability hooks for shared environments
- installing a documented hook bundle for reuse across workspaces
Outcome Standard
A strong hook contribution usually includes:
- the right lifecycle event and the smallest useful behavior
- explicit safety defaults and clear denial or warning messages
- a documented
hooks.jsonconfiguration - cross-platform script guidance when Windows and Bash users both matter
- a README or pack that explains purpose, setup, and limitations
Hook Design Rules
- Start with observe or warn - block only when the policy is stable and the failure message is clear.
- Keep hooks fast - long-running hooks become friction generators instead of safeguards.
- Be explicit on denial - if a hook blocks work, explain exactly why and what to do instead.
- Separate policy from docs - the script enforces behavior; the README explains it.
- Prefer deterministic checks - hooks should not depend on fuzzy interpretation when avoidable.
Workflow
Phase 0: Decide whether a hook is the right primitive
Use a hook when deterministic automation is needed at a lifecycle event. If the need is guidance only, use instructions. If the need is a reusable workflow, use a skill. If the need is a user-started task, use a prompt.
Phase 1: Choose the lifecycle event
Clarify or infer:
- what event should trigger the hook
- whether the behavior is observe, warn, mutate, or deny
- how quickly the hook must complete
- whether it needs cross-platform script support
Phase 2: Design the safety model
Before scripting:
- define the exact condition being checked
- decide what the hook should output on allow, warn, or deny
- write the denial or warning message in user language, not policy jargon
- make sure the hook fails safely when inputs are missing or malformed
Phase 3: Create the hook pack
Use the resources below as the default starting point:
./resources/hook-template-pack.md./resources/hook-example-pack.md
A complete pack should usually include:
hooks.json- one or more supporting scripts
- a README with purpose, setup, and behavior notes
Phase 4: Validate the operational fit
Check the result against ./resources/hook-quality-checklist.md.
Pay special attention to:
- whether the hook is fast enough for the event it runs on
- whether the messages are actionable
- whether Windows and non-Windows paths are addressed when required
- whether the hook blocks only what it truly means to block
Common Failure Modes
- using a hook when a normal instruction would have been enough
- blocking large classes of commands without a helpful reason
- writing scripts that are too slow for frequent lifecycle events
- shipping
hooks.jsonwithout installation or behavior documentation - creating platform-specific hooks with no fallback or adaptation guidance
Resource Map
./resources/hook-template-pack.md- template pack with README, config, and script scaffolds./resources/hook-example-pack.md- worked example of a safe, documented policy hook./resources/hook-quality-checklist.md- final review checklist before shipping
Definition of Done
A task using this skill is complete when:
- the hook behavior matches a clear lifecycle need
- the configuration, scripts, and documentation agree with each other
- failure, allow, and deny messages are understandable
- the pack is install-ready or clearly adapted for the target environment
- the final result passes the quality checklist without obvious operational risk
In this repository51 other files it gives its agents.
- analyzing-quality-metricsSkill
- analyzing-regression-scopeSkill
- api-playwright-test-developerSkill
- assessing-comprehension-debtSkill
- assessing-release-readinessSkill
- attesting-manual-verificationSkill
- auditing-accessibilitySkill
- code-review-advancedSkill
- code-reviewSkill
- communicating-quality-findingsSkill
- creating-custom-agentsSkill
- creating-instructionsSkill
- creating-orchestration-packsSkill
- creating-pluginsSkill
- creating-promptsSkill
- creating-skillsSkill
- deriving-a-quality-contractSkill
- designing-functional-testsSkill
- designing-test-dataSkill
- documenting-test-suitesSkill
- generating-quality-gate-workflowsSkill
- governing-quality-waiversSkill
- handling-sensitive-test-dataSkill
- migrating-tests-to-playwrightSkill
- mocking-network-and-timeSkill
- planning-exploratory-testingSkill
- prd-generatorSkill
- recording-change-intentSkill
- reporting-bugsSkill
- requirements-test-coverage-mapperSkill
- reviewing-ai-output-groundednessSkill
- running-visual-regression-testsSkill
- scoping-change-relevanceSkill
- static-code-analysis-typescriptSkill
- tech-debt-analysisSkill
- test-driven-development-quickSkill
- test-driven-developmentSkill
- testing-agent-skillsSkill
- testing-api-contractsSkill
- testing-application-securitySkill
- testing-llm-featuresSkill
- testing-llm-guardrailsSkill
- testing-performance-and-loadSkill
- tracing-requirements-to-codeSkill
- tracking-quality-trendsSkill
- unslop-answersSkill
- unslop-testsSkill
- verifying-acceptance-criteriaSkill
- verifying-change-coverageSkill
- writing-unit-tests-quickSkill
- writing-unit-testsSkill
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.

