docs(learning-hub): update pages with CLI v1.0.10-1.0.12 features (#1200)

- automating-with-hooks: add plugin hook env vars (CLAUDE_PROJECT_DIR,
  CLAUDE_PLUGIN_DATA, {{project_dir}}, {{plugin_data_dir}}); add
  .claude/settings.json as hooks config location
- copilot-configuration-basics: add /allow-all on/off/show subcommands;
  document .claude/settings.json and .claude/settings.local.json as
  per-repo config sources; add model picker full-screen and inline
  reasoning effort note
- understanding-mcp-servers: add MCP sampling (LLM inference) section;
  note that blocked servers are hidden from /mcp show

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-03-30 11:49:48 +11:00
committed by GitHub
parent 7e375eac04
commit c63db63a7e
3 changed files with 68 additions and 4 deletions

View File

@@ -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-24
lastUpdated: 2026-03-27
estimatedReadingTime: '8 minutes'
tags:
- hooks
@@ -328,6 +328,34 @@ The `subagentStart` hook fires when the main agent spawns a subagent (e.g., via
This is especially useful in multi-agent workflows where subagents may not automatically inherit context from the parent session.
### Plugin Hook Environment Variables
When hooks are defined inside a **plugin**, Copilot CLI automatically injects two extra environment variables so scripts can locate project-specific and plugin-specific directories:
| Variable | Description |
|----------|-------------|
| `CLAUDE_PROJECT_DIR` | Absolute path to the working project directory |
| `CLAUDE_PLUGIN_DATA` | Absolute path to the plugin's persistent data directory |
You can also reference these paths as template variables in your hook configuration:
```json
{
"version": 1,
"hooks": {
"postToolUse": [
{
"type": "command",
"bash": "{{plugin_data_dir}}/scripts/format.sh {{project_dir}}",
"timeoutSec": 30
}
]
}
}
```
This is useful for plugins that bundle scripts or data files alongside their hooks, since `{{plugin_data_dir}}` always points to the correct installed location regardless of where the plugin is installed.
## Writing Hook Scripts
For complex logic, use bundled scripts instead of inline bash commands:
@@ -377,6 +405,7 @@ echo "Pre-commit checks passed ✅"
A: There are several supported locations, loaded in order of precedence:
- **Repository-level** (shared with team): `.github/hooks/*.json` in your repository — all JSON files in this folder are loaded automatically
- **Claude/Copilot project settings**: `.claude/settings.json` and `.claude/settings.local.json` — hooks defined here are applied to the current repository without committing them to `.github/`
- **Global settings**: `settings.json` or `settings.local.json` (user-level CLI config)
- **Legacy config**: `config.json` (also supported)