GitHub Copilot Integration
Install FireGuard hooks for GitHub Copilot CLI and Copilot cloud agent tool calls.
Use the GitHub Copilot integration when you want FireGuard to check Copilot CLI sessions and Copilot cloud agent jobs before tool calls run.
This integration covers Copilot CLI (~/.copilot/hooks/) and Copilot cloud agent (.github/hooks/ on the default branch). It does not cover VS Code inline completions, Tab suggestions, or Microsoft Copilot Studio.
Requirements
python3available onPATH.- A FireGuard API key.
- A FireGuard project ID with the policies and security guardrails you want to enforce.
Install
User-level (Copilot CLI)
curl -fsSL https://raw.githubusercontent.com/fireravenai/fireraven-agent-hooks/refs/heads/main/install.sh | sh -s -- --agent github-copilotOr install from a local clone of github.com/fireravenai/fireraven-agent-hooks:
./fg install --agent github-copilot
./fg doctorThis writes:
| Path | Purpose |
|---|---|
~/.copilot/hooks/fireraven-fireguard.json | Hook registration |
~/.copilot/hooks/fireraven/ | Scripts and config.env |
Project-level (Copilot cloud agent)
From your repository root:
./fg install --agent github-copilot --projectThis writes:
| Path | Purpose |
|---|---|
.github/hooks/fireraven-fireguard.json | Hook registration (commit to default branch) |
.github/hooks/fireraven/ | Scripts (commit); config.env (gitignored) |
Cloud agent only loads .github/hooks/*.json from the cloned repository on the default branch.
Configure
Edit config.env in the installed hooks directory:
FIRERAVEN_GUARDRAILS_API_KEY=fg_...
FIRERAVEN_PROJECT_ID=00000000-0000-0000-0000-000000000000| Install target | config.env path |
|---|---|
| Copilot CLI | ~/.copilot/hooks/fireraven/config.env |
| Copilot cloud agent | .github/hooks/fireraven/config.env |
Optional overrides (installer defaults are normal / open if omitted):
FIRERAVEN_API_URL=https://api.fireraven.ai
# FIRERAVEN_EXECUTION_MODE=fast
FIRERAVEN_REQUEST_TIMEOUT_SEC=15
# FIRERAVEN_FAIL_MODE=closedRestart Copilot CLI or merge hook files to the default branch after editing config.env.
Configuration reference
| Variable | Required | Default | Description |
|---|---|---|---|
FIRERAVEN_GUARDRAILS_API_KEY | yes | — | Organization FireGuard API key. See FireGuard API keys. |
FIRERAVEN_PROJECT_ID | yes | — | FireGuard project ID from Project Settings → General. See Project configuration. |
FIRERAVEN_API_URL | no | https://api.fireraven.ai | FireGuard API base URL. |
FIRERAVEN_EXECUTION_MODE | no | normal | Execution mode sent on each guardrail API call. See below. |
FIRERAVEN_REQUEST_TIMEOUT_SEC | no | 15 | HTTP timeout in seconds for FireGuard requests. |
FIRERAVEN_FAIL_MODE | no | open | Hook behavior when FireGuard cannot be reached. See below. |
FIRERAVEN_EXECUTION_MODE
| Value | Default | Use when |
|---|---|---|
normal | yes | Full sequential checks with complete policy and security details. |
fast | Lower latency. FireGuard runs eligible checks in parallel and returns as soon as a blocking result is known. |
See FireGuard concepts — Execution modes.
FIRERAVEN_FAIL_MODE
| Value | Default | Use when |
|---|---|---|
open | yes | Allow tool use through on transient FireGuard API failures. Policy violations and missing credentials still block. |
closed | Block tool use when FireGuard cannot be reached (network, timeout, or HTTP error). Use for strict production enforcement. |
For preToolUse, GitHub Copilot treats hook crashes and non-zero exits as deny when fail-closed.
What GitHub Copilot Checks
| Event | What FireGuard checks | Blocking? |
|---|---|---|
userPromptSubmitted | User prompts | No — Copilot does not process hook output |
preToolUse | Shell commands, file reads, edits, and other tool calls | Yes |
postToolUse | Tool result text | Audit only |
Unlike Cursor, GitHub Copilot cannot block prompts via userPromptSubmitted. Enforcement happens on tool calls through preToolUse.
GitHub Copilot blocks by returning:
{
"permissionDecision": "deny",
"permissionDecisionReason": "Blocked by Fireraven FireGuard."
}See the GitHub Copilot hooks documentation for platform details.
Copilot cloud agent prerequisites
- Merge
.github/hooks/fireraven-fireguard.jsonand.github/hooks/fireraven/to your repository default branch. - Configure
.github/hooks/fireraven/config.envwith Fireraven credentials (do not commit secrets). - Ensure outbound network allows
api.fireraven.ai(org admin firewall allow rule may be required). - Cloud agent runs Linux/bash only —
powershellhook entries are ignored.
Verify
Smoke-test the hook script directly (no Copilot required):
echo '{"sessionId":"test","prompt":"hello"}' \
| python3 ~/.copilot/hooks/fireraven/github_copilot_guardrail.py
echo '{"sessionId":"test","toolName":"bash","toolArgs":"{\"command\":\"rm -rf /\"}"}' \
| python3 ~/.copilot/hooks/fireraven/github_copilot_guardrail.pyFrom a clone of the hooks repository, use:
./fg doctorWindows
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/fireravenai/fireraven-agent-hooks/refs/heads/main/install.ps1))) -Agent github-copilotProject install:
powershell -ExecutionPolicy Bypass -File .\install.ps1 -Agent github-copilot -ProjectIf py -3 is unavailable in the Copilot hook environment, edit fireraven-fireguard.json to use run_github_copilot_guardrail.ps1 for the powershell field.