How to use hooks in the GitHub Copilot CLI | demo
GitHub explains how hooks work in the GitHub Copilot CLI, focusing on the agent lifecycle and the specific events where hooks fire so you can customize tool calls and workflow behavior.
Full summary based on transcript
What “hooks” are in Copilot CLI
Hooks are event-driven customization points in the GitHub Copilot CLI that let you run logic at specific moments during an agent session, including around tool invocation.
Understanding the agent lifecycle
The video breaks down the overall lifecycle/loop of a Copilot CLI agent session, framing hooks as events that occur at predictable points in that loop.
How the agent loop works
GitHub walks through the agent loop at a high level to clarify:
- When a session begins
- When user prompts are submitted
- When tools are about to be called and after they return
Hook events covered
The demo calls out key events you can hook into:
- Session start
- User prompt submitted
- Pre tool use
- Post tool use
Pre- and post-tool-use hooks
The video highlights how hooks around tool usage can be used to control or shape tool calls, enabling more predictable or customized behavior during the session.
Blocking vs non-blocking hooks
GitHub explains the difference between:
- Blocking hooks: hooks that can stop or gate progress in the agent flow
- Non-blocking hooks: hooks that run without preventing the agent from continuing