mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-11 10:45:56 +00:00
docs: update Learning Hub for Copilot CLI v1.0.11/v1.0.12 changes (#1208)
Add documentation for new features released in the past 7 days:
- /rewind command and double-Esc timeline picker (v1.0.12)
- /allow-all on/off/show subcommands (v1.0.12)
- .claude/settings.json and .claude/settings.local.json as additional
repo config sources (v1.0.12)
- preCompact hook event in the events table (v1.0.5, previously missing)
- Plugin hooks CLAUDE_PROJECT_DIR and CLAUDE_PLUGIN_DATA env variables
and {{project_dir}}/{{plugin_data_dir}} template variables (v1.0.12)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Aaron Powell <me@aaron-powell.com>
This commit is contained in:
committed by
GitHub
parent
c63db63a7e
commit
819a8fa89c
@@ -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-27
|
||||
lastUpdated: 2026-03-28
|
||||
estimatedReadingTime: '8 minutes'
|
||||
tags:
|
||||
- hooks
|
||||
@@ -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 completes execution | Log results, track usage, format code after edits, send failure alerts |
|
||||
| `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 |
|
||||
| `subagentStop` | A subagent completes before returning results | Audit subagent outputs, log subagent activity |
|
||||
| `errorOccurred` | An error occurs during agent execution | Log errors for debugging, send notifications, track error patterns |
|
||||
@@ -123,6 +124,34 @@ When multiple IDE extensions (or a mix of extensions and a `hooks.json` file) ea
|
||||
|
||||
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.
|
||||
|
||||
### Plugin Hooks Environment Variables
|
||||
|
||||
When hooks are defined inside a **plugin**, the hook scripts receive two additional environment variables automatically:
|
||||
|
||||
| Variable | Description |
|
||||
|----------|-------------|
|
||||
| `CLAUDE_PROJECT_DIR` | The path to the current project (working) directory |
|
||||
| `CLAUDE_PLUGIN_DATA` | The path to a persistent data directory scoped to the plugin |
|
||||
|
||||
You can also use these as **template variables** directly in the `bash` or `powershell` fields of your `hooks.json` configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 1,
|
||||
"hooks": {
|
||||
"sessionStart": [
|
||||
{
|
||||
"type": "command",
|
||||
"bash": "{{plugin_data_dir}}/scripts/init.sh --project {{project_dir}}",
|
||||
"timeoutSec": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This makes it straightforward to write plugin hooks that are portable across machines and projects without hardcoding paths.
|
||||
|
||||
### Event Configuration
|
||||
|
||||
Each hook entry supports these fields:
|
||||
|
||||
@@ -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-03-27
|
||||
lastUpdated: 2026-03-28
|
||||
estimatedReadingTime: '10 minutes'
|
||||
tags:
|
||||
- configuration
|
||||
@@ -416,6 +416,14 @@ GitHub Copilot CLI has two commands for managing session state, with distinct be
|
||||
|
||||
Both commands accept an optional prompt argument to seed the new session with an opening message, for example `/new Add error handling to the login flow`.
|
||||
|
||||
The `/rewind` command opens a timeline picker that lets you roll back the conversation to any earlier point in history, reverting both the conversation and any file changes made after that point. You can also trigger it by pressing **double-Esc**:
|
||||
|
||||
```
|
||||
/rewind
|
||||
```
|
||||
|
||||
Use `/rewind` when you want to branch off from a different point in the conversation, rather than just undoing the most recent turn.
|
||||
|
||||
The `/undo` command reverts the last turn—including any file changes the agent made—letting you course-correct without manually undoing edits:
|
||||
|
||||
```
|
||||
@@ -432,15 +440,15 @@ The `/cd` command changes the working directory for the current session. Each se
|
||||
|
||||
This is useful when you have multiple backgrounded sessions each focused on a different project directory.
|
||||
|
||||
The `/allow-all` command (also accessible as `/yolo`) enables a mode where the agent can execute tools without per-action confirmation. It now supports explicit subcommands:
|
||||
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:
|
||||
|
||||
```
|
||||
/allow-all on # Enable allow-all mode
|
||||
/allow-all off # Disable allow-all mode
|
||||
/allow-all show # Check whether allow-all mode is currently active
|
||||
/allow-all on # enable allow-all mode
|
||||
/allow-all off # disable allow-all mode
|
||||
/allow-all show # check current allow-all status
|
||||
```
|
||||
|
||||
Path permissions granted via `/allow-all` persist across `/clear`, so if you've granted access to a directory in one session, that access carries into the new session.
|
||||
> **Note**: `/allow-all on` permissions persist after `/clear` starts a new session, so you don't need to re-enable it each time.
|
||||
|
||||
The `--effort` flag (shorthand for `--reasoning-effort`) controls how much computational reasoning the model applies to a request:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user