Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion website/src/content/docs/learning-hub/automating-with-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-04-01
lastUpdated: 2026-04-02
estimatedReadingTime: '8 minutes'
tags:
- hooks
Expand Down Expand Up @@ -93,6 +93,7 @@ Hooks can trigger on several lifecycle events:
| `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 |
| `PermissionRequest` | When the CLI shows a **permission prompt** to the user | Programmatically approve or deny permission requests, enable auto-approval in CI/headless environments |
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Hook Events table, all event names are listed in camelCase (e.g., preToolUse, postToolUseFailure), but this new entry uses PascalCase (PermissionRequest). Since the doc later says both casing styles are accepted, consider listing the canonical/primary name in camelCase here (e.g., permissionRequest) for consistency and to reduce confusion.

This issue also appears on line 219 of the same file.

Suggested change
| `PermissionRequest` | When the CLI shows a **permission prompt** to the user | Programmatically approve or deny permission requests, enable auto-approval in CI/headless environments |
| `permissionRequest` | When the CLI shows a **permission prompt** to the user | Programmatically approve or deny permission requests, enable auto-approval in CI/headless environments |

Copilot uses AI. Check for mistakes.
| `agentStop` | Main agent finishes responding to a prompt | Run final linters/formatters, validate complete changes |
| `preCompact` | Before the agent compacts its context window | Save a snapshot, log compaction event, run summary scripts |
| `subagentStart` | A subagent is spawned by the main agent | Inject additional context into the subagent's prompt, log subagent launches |
Expand Down Expand Up @@ -207,6 +208,42 @@ automatically before the agent commits changes.

## Practical Examples

### Auto-Approve Permissions in CI with PermissionRequest

The `PermissionRequest` hook fires when the CLI shows a permission prompt to the user — for example, when the agent wants to run a shell command for the first time. Unlike `preToolUse` (which can block specific tool *calls*), `PermissionRequest` intercepts the permission approval UI itself, making it ideal for **headless and CI environments** where no one is available to click "Allow".

When your hook script exits with code `0`, the permission request is **approved**. Exit with a non-zero code to **deny** it (the user will still see the prompt).

```json
{
"version": 1,
"hooks": {
"PermissionRequest": [
{
"type": "command",
"bash": "./scripts/ci-permission-policy.sh",
"cwd": ".",
"timeoutSec": 5
}
]
}
}
```

Example policy script that auto-approves all permissions when running in CI:

```bash
#!/usr/bin/env bash
# scripts/ci-permission-policy.sh
# Auto-approve all permission requests in CI environments
if [ "${CI}" = "true" ]; then
exit 0 # approve
fi
exit 1 # deny (let the user decide interactively)
```

> **Security note**: Use `PermissionRequest` hooks carefully. Blanket auto-approval in non-CI environments removes an important safety check. Scope the auto-approval logic precisely (e.g., only in CI, only for specific tools).

### Handling Tool Failures with postToolUseFailure

The `postToolUseFailure` hook fires when a tool call fails with an error — distinct from `postToolUse`, which only fires on success. Use it to log errors, send failure alerts, or implement retry logic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'Copilot Configuration Basics'
description: 'Learn how to configure GitHub Copilot at user, workspace, and repository levels to optimize your AI-assisted development experience.'
authors:
- GitHub Copilot Learning Hub Team
lastUpdated: 2026-04-01
lastUpdated: 2026-04-02
estimatedReadingTime: '10 minutes'
tags:
- configuration
Expand Down Expand Up @@ -457,6 +457,8 @@ The `/share html` command exports the current session — including conversation

The exported file contains everything needed to view the session without a network connection and can be shared with teammates or stored for later reference. This complements `/share` (which shares via URL) for cases where an offline or attached format is preferred.

**Keyboard shortcuts for queuing messages**: Use **Ctrl+Q** or **Ctrl+Enter** to queue a message (send it while the agent is still working). **Ctrl+D** no longer queues messages — it now has its default terminal behavior. If you have muscle memory for Ctrl+D queuing, switch to Ctrl+Q.

The `/allow-all` command (also accessible as `/yolo`) enables autopilot mode, where the agent runs all tools without asking for confirmation. It now supports `on`, `off`, and `show` subcommands:

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: 'Installing and Using Plugins'
description: 'Learn how to find, install, and manage plugins that extend GitHub Copilot CLI with reusable agents, skills, hooks, and integrations.'
authors:
- GitHub Copilot Learning Hub Team
lastUpdated: 2026-03-30
lastUpdated: 2026-04-02
estimatedReadingTime: '8 minutes'
tags:
- plugins
Expand Down Expand Up @@ -142,6 +142,23 @@ Or from a local path:
copilot plugin marketplace add /path/to/local-marketplace
```

### Sharing Marketplace Registrations Across a Team

To automatically register an additional marketplace for everyone working in a repository, add an `extraKnownMarketplaces` entry to your `.github/copilot-settings.json` (or `config.json`):

Comment on lines +145 to +148
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs recommend adding extraKnownMarketplaces to .github/copilot-settings.json, but elsewhere the Learning Hub states Copilot CLI configuration lives in ~/.copilot-cli/config.json with per-project overrides in .claude/settings.json / .claude/settings.local.json (see website/src/content/docs/learning-hub/copilot-configuration-basics.md:375-402). Unless .github/copilot-settings.json is a real supported config path, this will mislead readers—please update the path(s) here to match the documented config locations and clarify whether this is a global vs per-repo setting.

Copilot uses AI. Check for mistakes.
```json
{
"extraKnownMarketplaces": [
{
"name": "my-org-plugins",
"source": "my-org/internal-plugins"
}
]
}
```

With this in place, team members automatically get the `my-org-plugins` marketplace available without running a separate `marketplace add` command. This replaces the older `marketplaces` setting, which was removed in v1.0.16.

## Installing Plugins

### From Copilot CLI
Expand Down