GitHub Copilot
Copilot has three parts, and only some can be protected.
| Part of Copilot | Protected? | How |
|---|---|---|
| Copilot CLI and cloud agent: tool calls | Yes | Hook |
| Agent mode in VS Code: tool calls | Yes | Hook |
| Copilot Chat in VS Code with your own model and API key | Yes | Gateway |
| Default Copilot models, inline suggestions, prompts typed into the CLI | No | GitHub offers no way to intercept them |
Be clear about the gap
Inline suggestions and the default Copilot models send data through GitHub's own servers. pii-airlock cannot sit in front of that. Do not rely on it there.
Protect tool calls (hook)
pii-airlock initRun in a project, init installs the Copilot hook for your user (in ~/.copilot/hooks/) when it finds Copilot, and guards this project. The hook only acts in projects that have a .pii-airlock/ folder. It checks shell commands, file reads and edits, web fetches and MCP calls, and asks you before anything containing personal data goes ahead.
The cloud agent runs on GitHub's machines and does not see your user hooks. For it, write the hook into the repository:
pii-airlock install-hook --target copilot # .github/hooks/pii-airlock.jsonChat in VS Code
Copilot hooks cannot block what you type in chat. Instead, add your own model that goes through the gateway.
- Start the gateway:
pii-airlock proxy - In VS Code open Manage Models and add a custom endpoint model, using
chatLanguageModels.json.
[
{
"name": "OpenAI via pii-airlock",
"vendor": "customendpoint",
"apiKey": "${input:openaiKey}",
"apiType": "chat-completions",
"models": [{
"id": "gpt-4o", "name": "GPT-4o", "toolCalling": true,
"url": "http://127.0.0.1:8745/openai/v1/chat/completions",
"maxInputTokens": 100000, "maxOutputTokens": 16000
}]
}
]For Claude models use "apiType": "messages" and the URL http://127.0.0.1:8745/anthropic/v1/messages (for example model id claude-sonnet-4-6). "apiType": "responses" also works, with http://127.0.0.1:8745/openai/v1/responses. Your own API key is forwarded to the provider and never logged.
How the hook behaves (details)
- Same checks as Claude Code.
hook_decision,entity_actions: blockandhook_on_errorall apply. Shell commands,grepandglobpatterns, paths and source files get the same code filter, sonpm testis not stopped. The hook registerspreToolUsewith no matcher, so it sees every tool call. - What it reads. Copilot's tools are
bash,powershell,view,edit,create,glob,grep,web_fetch,web_search,task,ask_user,update_todo,str_replace_editor,apply_patch,rg, plus MCP tools. GitHub does not document their argument names, so every string argument of every tool is scanned.viewalso scans the file's content. Both payload shapes are accepted: camelCase (toolName, withtoolArgsas an object or as JSON text) and snake_case (tool_name,tool_input). - Only guarded projects. As with Claude Code, the hook stays silent in a folder that has no
.pii-airlock/. Runpii-airlock initin each project you want checked. - Project-scope hooks need a trusted folder. Copilot CLI skips a repository's
.github/hooks/until the folder is listed undertrustedFoldersin~/.copilot/config.json. The user-level hook thatinitinstalls (~/.copilot/hooks/pii-airlock.json) needs no trust. - Non-interactive runs.
copilot -pcannot ask, so anaskdecision denies the call. - Failure modes (from GitHub's hooks reference). A hook that errors or exits with code 2 denies the tool call, so detection failures fail closed. A hook timeout is fail-open, so keep the helper on (
hook_daemon: auto, the default) to stay far below the 30 second default. The cloud agent treatsaskasdenyand honours only thebashcommand. - One install is enough. Copilot CLI also reads a repository's
.claude/settings.json. If you registered the Claude Code hook there by hand (install-hook --scope project), do not add the Copilot file as well, or every call is scanned twice.initwrites neither. - Reply format. One JSON object carries both Copilot's top-level
permissionDecisionand Claude Code's nestedhookSpecificOutput. Each side reads its own part.
Honest status
The Claude Code hook is tested end to end. The Copilot hook was checked against live Copilot CLI sessions (version 1.0.114, November 2026, non-interactive copilot -p, user-level hook):
| Checked live | Result |
|---|---|
~/.copilot/hooks/pii-airlock.json is loaded | yes |
A top-level permissionDecision with exit code 0 stops the call | yes |
bash, view, create, edit, grep calls carrying personal data | stopped |
Clean bash, view, create, glob calls | run untouched |
Not yet checked live: the interactive ask dialog, a trusted project-scope hook, the timeout and exit-code-2 paths, the cloud agent, and Copilot in VS Code. Those still rest on GitHub's and VS Code's published specifications. If a tool call slips through, please open an issue with the hook payload.