docs(learning-hub): update for Copilot CLI v1.0.64-v1.0.65 features (#2127)

- creating-effective-skills: add 'copilot skill' CLI subcommand for
  listing, adding, and removing skills (v1.0.65); add '/skill' alias
- automating-with-hooks: document userPromptSubmitted additionalContext
  injection into model-facing prompt (v1.0.65); update hook events table
- copilot-configuration-basics: add opt-in CI check status bar indicator
  for current branch (v1.0.65)
- building-custom-agents: add note that /security-review is now available
  to all users without --experimental (v1.0.64)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2026-06-26 15:36:40 +10:00
committed by GitHub
parent 0d855afc2e
commit cd420ca862
4 changed files with 43 additions and 6 deletions
@@ -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-06-23
lastUpdated: 2026-06-25
estimatedReadingTime: '8 minutes'
tags:
- hooks
@@ -89,7 +89,7 @@ Hooks can trigger on several lifecycle events:
|-------|---------------|------------------|
| `sessionStart` | Agent session begins or resumes | Initialize environments, log session starts, validate project state |
| `sessionEnd` | Agent session completes or is terminated | Clean up temp files, generate reports, send notifications |
| `userPromptSubmitted` | User submits a prompt | Log requests for auditing and compliance; handle requests directly without invoking the LLM (v1.0.44+) |
| `userPromptSubmitted` | User submits a prompt | Log requests for auditing and compliance; handle requests directly without invoking the LLM (v1.0.44+); inject `additionalContext` into the model prompt (v1.0.65+) |
| `preToolUse` | Before the agent uses any tool (e.g., `bash`, `edit`) | **Approve or deny** tool executions, block dangerous commands, enforce security policies |
| `postToolUse` | After a tool **successfully** completes execution | Log results, track usage, format code after edits |
| `postToolUseFailure` | When a tool call **fails with an error** | Log errors for debugging, send failure alerts, track error patterns |
@@ -118,6 +118,28 @@ cat <<EOF
EOF
```
### userPromptSubmitted additionalContext (v1.0.65+)
The `userPromptSubmitted` hook also supports the `additionalContext` field. When your hook returns `{"additionalContext": "..."}`, that text is **injected into the model-facing prompt** before the model processes the user's message. This is distinct from the `response` field (which bypasses the model entirely) — here the model still runs, but with extra context prepended.
This is useful for per-prompt enrichment: adding the current git diff, environment state, or dynamic instructions that should influence the model's response for this specific request.
```bash
#!/usr/bin/env bash
# Inject the current git status into every prompt for context awareness
INPUT=$(cat)
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
STAGED=$(git diff --cached --stat 2>/dev/null | tail -1)
cat <<EOF
{
"additionalContext": "Active branch: $BRANCH. Staged changes: ${STAGED:-none}."
}
EOF
```
> **How it works**: If your hook writes `{"additionalContext": "..."}` to stdout and exits with code `0`, the text is prepended to the model prompt for this turn. The hook can also write both `additionalContext` and `response` — if `response` is present, that wins and the model call is skipped.
### 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.