hooks
Guidance for writing safe, fast and clear hooks, with reusable hook examples.
- Kind
- Rules
- Works with
- GitHub Copilot
- Source
- Awesome Copilot @ d85f762d6e52
- Path
- instructions/hooks.instructions.md
- Jobs
- Guardrails, Automation
Credit
- Made by
- github
- Original
- github.com/github/awesome-copilot/blob/d85f762d6e521abf5fe167…
- License
- MIT
Listed by Skill Manifest; not made by us.
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
- Adds
- Text to merge into your CLAUDE.md or AGENTS.md (no new files)
- Runs scripts
- Yes
- shell block in the text
- Uses the network
- Yes
- downloads npm packages
- git clone / pull / push
- Needs secrets
- None found
- Reads environment variables
- CWD
- ERRORS
- TSC_OUT
- HAS_LINT
- LINT_OUT
- HAS_TEST
- Reads outside the project
- /usr/bin/env (hooks.instructions.md)
- ~/.claude/settings.json (hooks.instructions.md)
- Source revision
- d85f762d6e52
- Licence
- MIT
- Last activity
- 25 Nov 2026
- Source changed after the scan
- Yes
- Last push 25 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
- Review
- Reviewed
Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.
# Hook Authoring Guidelines
Hooks are **small, deterministic commands or scripts** that run at specific lifecycle events.
An awesome hook does one clear job, runs quickly, and makes its side effects explicit.
## Folder Structure
A GitHub Copilot hook lives in `.github/hooks/` inside your repository:
```text
.github/
└── hooks/
├── block-dangerous-commands.json ← hook config (which event, which script, options)
└── scripts/
├── block-dangerous-commands.sh ← Bash implementation
└── block-dangerous-commands.ps1 ← PowerShell implementation (optional if Bash-only)
```
You can have multiple `.json` files — each one registers hooks for one or more events. The host loads all of them.
## The Config File
Each `.json` file maps events to an array of hook entries.
- **Command hooks** (`type: "command"`): run a local script. The host passes event JSON on stdin, your script responds through exit code and stdout.
### Config example
```json
{
"version": 1,
"hooks": {
"preToolUse": [
{
"matcher": "bash",
"type": "command",
"bash": "./.github/hooks/scripts/block-dangerous-commands.sh",
…