Skip to content

Commit 7cf01eb

Browse files
authored
Merge pull request #35 from kenryu42/feat/copilot-cli-doctor
feat: copilot cli doctor
2 parents 46a35a7 + b88c5a7 commit 7cf01eb

13 files changed

Lines changed: 1517 additions & 39 deletions

File tree

README.md

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,21 @@ gemini extensions install https://github.com/kenryu42/gemini-safety-net
210210
Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-hooks).
211211

212212
> [!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+`
218+
> - Inline `hooks` inside Copilot config files on Copilot CLI `1.0.8+`:
219+
> - user: `~/.copilot/config.json`
220+
> - repository: `.github/copilot/settings.json`
221+
> - 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.
214228

215229
1. **Create the hooks directory** in your repository:
216230

@@ -238,7 +252,50 @@ Safety Net supports GitHub Copilot CLI via its [hooks system](https://docs.githu
238252

239253
3. **Restart Copilot CLI** — hooks are loaded at session start.
240254

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`.
291+
292+
If you need to turn hooks off explicitly, set:
293+
294+
```json
295+
{
296+
"disableAllHooks": true
297+
}
298+
```
242299

243300
## Status Line Integration
244301

0 commit comments

Comments
 (0)