mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-12 03:05:55 +00:00
docs: update Learning Hub for CLI v1.0.10/v1.0.11 features (#1150)
- Add monorepo support section to copilot-configuration-basics: customizations discovered at every directory level up to git root - Add personal skills directory (~/.agents/skills/) documentation - Add /clear vs /new session command distinction + /undo command - Add MCP organization policy enforcement to understanding-mcp-servers - Add sessionStart additionalContext injection to automating-with-hooks - Add extension hooks merging behaviour to automating-with-hooks Source: https://github.com/github/copilot-cli/releases/tag/v1.0.11 Source: https://github.com/github/copilot-cli/releases/tag/v1.0.10 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7471eb5492
commit
f1004d04c0
@@ -3,7 +3,7 @@ title: 'Automating with Hooks'
|
||||
description: 'Learn how to use hooks to automate lifecycle events like formatting, linting, and governance checks during Copilot agent sessions.'
|
||||
authors:
|
||||
- GitHub Copilot Learning Hub Team
|
||||
lastUpdated: 2026-03-22
|
||||
lastUpdated: 2026-03-24
|
||||
estimatedReadingTime: '8 minutes'
|
||||
tags:
|
||||
- hooks
|
||||
@@ -99,6 +99,26 @@ Hooks can trigger on several lifecycle events:
|
||||
|
||||
> **Key insight**: The `preToolUse` hook is the most powerful — it can **approve or deny** individual tool executions. This enables fine-grained security policies like blocking specific shell commands or requiring approval for sensitive file operations.
|
||||
|
||||
### sessionStart additionalContext
|
||||
|
||||
The `sessionStart` hook supports an `additionalContext` field in its output. When your hook script writes JSON to stdout containing an `additionalContext` key, that text is **injected directly into the conversation** at the start of the session. This lets hooks dynamically provide environment-specific context—such as the current git branch, deployment environment, or team onboarding notes—without requiring the user to paste it manually.
|
||||
|
||||
Example hook script that surfaces context:
|
||||
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
# Output JSON with additionalContext to inject into the session
|
||||
cat <<EOF
|
||||
{
|
||||
"additionalContext": "Current branch: $(git rev-parse --abbrev-ref HEAD). Open tickets: $(gh issue list --limit 3 --json number,title | jq -r '.[] | \"#\(.number) \(.title)\"' | tr '\n' '; ')"
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
### Extension Hooks Merging
|
||||
|
||||
When multiple IDE extensions (or a mix of extensions and a `hooks.json` file) each define hooks, all hook definitions are **merged** rather than the last one overwriting the others. This means you can layer hooks from different sources—a project's `.github/hooks/` file, an extension you have installed, and a personal settings file—and all of them will fire for the relevant events.
|
||||
|
||||
### Cross-Platform Event Name Compatibility
|
||||
|
||||
Hook event names can be written in **camelCase** (e.g., `preToolUse`) or **PascalCase** (e.g., `PreToolUse`). Both are accepted, making hook configuration files compatible across GitHub Copilot CLI, VS Code, and Claude Code without modification. Hooks also support Claude Code's nested `matcher`/`hooks` structure alongside the standard flat format.
|
||||
|
||||
Reference in New Issue
Block a user