fix: align hooks docs with official GitHub Copilot hooks spec

- Remove non-existent copilotAgentCommit event from all articles
- Add 5 missing hook events: preToolUse, postToolUse, agentStop,
  subagentStop, errorOccurred
- Fix hooks location from .copilot/hooks.json to .github/hooks/*.json
- Add powershell field to config format
- Add preToolUse security gating example (approve/deny tool executions)
- Update glossary and coding agent article cross-references

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Aaron Powell
2026-02-26 14:01:17 +11:00
parent a88c9f89d5
commit 31c41a6a1c
3 changed files with 83 additions and 46 deletions

View File

@@ -185,9 +185,9 @@ A standardized protocol for connecting AI assistants like GitHub Copilot to exte
### Hook
A shell command or script that runs automatically in response to lifecycle events during a Copilot agent session. Hooks are defined in a `hooks.json` file and can trigger on events like session start, prompt submission, or before a commit. They provide deterministic automation—linting, formatting, governance scanning—that doesn't depend on the AI remembering to do it.
A shell command or script that runs automatically in response to lifecycle events during a Copilot agent session. Hooks are stored as JSON files in `.github/hooks/` and can trigger on events like session start/end, prompt submission, before/after tool use, and when errors occur. They provide deterministic automation—linting, formatting, governance scanning—that doesn't depend on the AI remembering to do it.
**Example**: A `copilotAgentCommit` hook that runs Prettier before every commit the agent makes.
**Example**: A `postToolUse` hook that runs Prettier after the agent edits files, or a `preToolUse` hook that blocks dangerous shell commands.
**When to use**: For deterministic automation that must happen reliably, like formatting code, running linters, or auditing prompts for compliance.