You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks).
211
211
212
212
> [!NOTE]
213
-
> Copilot CLI hooks must be installed at the **project level** (in each repository). User-level hooks (`~/.github/hooks/` or `~/.copilot/hooks/`) are not currently supported by Copilot CLI. See [copilot-cli#1067](https://github.com/github/copilot-cli/issues/1067) to track progress on user-level hook support.
213
+
> Copilot CLI currently supports two hook configuration styles:
214
+
>
215
+
> - Hook files:
216
+
> - repository: `.github/hooks/*.json`
217
+
> - user: `~/.copilot/hooks/*.json` on Copilot CLI `0.0.422+`
> - local override: `.github/copilot/settings.local.json`
222
+
>
223
+
> Copilot settings cascade from user -> repository -> local (later files override earlier ones, so local overrides repository overrides user). `disableAllHooks: true` disables both repo-level and user-level hooks. If you use `COPILOT_HOME`, replace `~/.copilot` with that directory.
224
+
225
+
#### Option A: Hook Files
226
+
227
+
This is the classic hook-file format. It still works, and it is the easiest shared setup for a repository.
214
228
215
229
1.**Create the hooks directory** in your repository:
216
230
@@ -238,7 +252,50 @@ Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.githu
238
252
239
253
3.**Restart Copilot CLI** — hooks are loaded at session start.
240
254
241
-
The hook will intercept bash commands and block destructive operations before they execute.
255
+
The hook will intercept shell commands and block destructive operations before they execute.
256
+
257
+
To install the same hook globally for your user account on Copilot CLI `0.0.422+`, place the same JSON file in:
258
+
259
+
-`~/.copilot/hooks/safety-net.json`
260
+
261
+
#### Option B: Inline Hooks In Copilot Settings
262
+
263
+
On Copilot CLI `1.0.8+`, you can define the same hook inline in Copilot settings files instead of a separate `.json` file under `.github/hooks` or `~/.copilot/hooks`.
264
+
265
+
```json
266
+
{
267
+
"hooks": {
268
+
"preToolUse": [
269
+
{
270
+
"type": "command",
271
+
"bash": "npx -y cc-safety-net --copilot-cli",
272
+
"cwd": ".",
273
+
"timeoutSec": 15
274
+
}
275
+
]
276
+
}
277
+
}
278
+
```
279
+
280
+
Use that schema in one of these files:
281
+
282
+
-`~/.copilot/config.json`
283
+
-`.github/copilot/settings.json`
284
+
-`.github/copilot/settings.local.json`
285
+
286
+
Recommended usage:
287
+
288
+
- Use `~/.copilot/config.json` for your personal default across repositories.
289
+
- Use `.github/copilot/settings.json` for a committed repository-wide setup.
290
+
- Use `.github/copilot/settings.local.json` for personal repo-specific overrides, and add it to `.gitignore`.
0 commit comments