Hooks
Hooks是一款productivity方向的AI技能,核心价值是Portable guidance for authoring safe, fast, and clear hooks and reusable hook examples,可用于解决开发者在productivity领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。
Portable guidance for authoring safe, fast, and clear hooks and reusable hook examples
mkdir -p ./skills/hooks && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/hooks/SKILL.md -o ./skills/hooks/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
# 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:
.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
{
"version": 1,
"hooks": {
"preToolUse": [
{
"matcher": "bash",
"type": "command",
"bash": "./.github/hooks/scripts/block-dangerous-commands.sh",
"powershell": "./.github/hooks/scripts/block-dangerous-commands.ps1",
"cwd": ".",
"timeoutSec": 5,
"env": {
"BLOCK_MODE": "deny"
}
}
]
}
}Config fields
| Field | Required | What it does |
| ---- | ---- | ---- |
| `type` | yes | `"command"` for scripts |
| `matcher` | no | Host-level filter — hook only fires when the tool name matches this value (e.g. `"bash"`, `"powershell"`, `"edit"`, `"create"`). Locally verified working in Copilot CLI v1.0.36; not yet used in repo hook samples. |
| `bash` | one or both | Command line invoked on Unix / Bash-capable hosts |
| `powershell` | one or both | Command line invoked on Windows / PowerShell-capable hosts |
| `cwd` | no | Working directory, relative to repo root |
| `timeoutSec` | no | Max seconds before the host kills the process (default 30) |
| `env` | no | Extra process environment variables passed to the script |
Why matchers matter
Without a matcher, every `preToolUse` hook fires on **every** tool call. Your script starts with boilerplate like:
tool_name="$(printf '%s' "$payload" | jq -r '.toolName')"
[[ "$tool_name" != "bash" ]] && exit 0With a matcher, the host does this filtering for you — no boilerplate, no process spawn for irrelevant tools. This will likely become the standard pattern once the feature stabilizes.
If your hooks must work on both the CLI and the cloud agent (or on older CLI versions), keep the in-script filtering as a fallback even when using matchers.
`env` — static configuration for your script
`env` is a **standard host field**. The keys inside it are **author-defined variables** — you choose the names and values.
They arrive as **process environment variables**, not inside the stdin JSON payload. Use them for static configuration that should not be hardcoded:
| Pattern | Example |
| ---- | ---- |
| Mode flag | `"BLOCK_MODE": "deny"` — same script logs in one repo, blocks in another |
| Threshold | `"MAX_CHANGED_FILES": "20"` |
| Path | `"AUDIT_LOG_PATH": ".github/logs/hooks.log"` |
| Feature toggle | `"ENABLE_NOTIFICATIONS": "false"` |
`bash` and `powershell` — when to provide one or both
The host picks whichever entry matches the current environment. It does not run both, and does not fall back from one to the other.
| Situation | Provide |
| ---- | ---- |
| Private hook, one known platform | Only that platform's entry |
| Published hook claiming cross-platform support | Both entries |
| Single cross-platform runtime (Python, Node, pwsh) | Expose the same script through both entries |
| Bash-only dependency | `bash` only |
| Windows-only dependency | `powershell` only |
Cross-platform example using Python through both entries:
{
"type": "command",
"bash": "python3 ./.github/hooks/scripts/check.p🎯 Best For
- UI designers
- Product designers
- Claude users
- GitHub Copilot users
- Knowledge workers
💡 Use Cases
- Generating component mockups
- Creating design system tokens
- Using Hooks in daily workflow
- Automating repetitive productivity tasks
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply Hooks to Your Work
Provide context for your task — paste source material, describe your audience, or share existing work to guide the AI.
- 4
Review and Refine
Edit the AI output for accuracy, tone, and completeness. Add human insight where the AI lacks context.
❓ Frequently Asked Questions
Does this work with Figma?
Some design skills integrate with Figma plugins. Check the Works With section for supported tools.
How do I install Hooks?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/hooks/SKILL.md, ready to use.
Can I customize this skill for my team?
Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.
⚠️ Common Mistakes to Avoid
Skipping usability testing
AI-generated designs should be validated with real users before development.
Not reading the full skill
Skills contain important context and edge cases beyond the quick start.