Copilot Hooks
Akto Guardrails for GitHub Copilot provides security validation for AI-assisted development across VS Code and the CLI. It intercepts prompts when submitted and tool executions before and after they run, validates against security policies, blocks risky behavior, and reports events to your Akto dashboard.
Key Features
✅ Zero Installation - No standalone apps to install
✅ Transparent Integration - Uses GitHub Copilot's native hook mechanism in both VS Code and CLI
✅ Real-time Tool Blocking - Can block dangerous tool executions before they run
✅ Centralized Monitoring - All events reported to Akto dashboard
✅ Flexible Deployment - Supports Argus and Atlas modes
✅ Configurable Behavior - Blocking or observation modes
⚠️ Prompt Monitoring Only - GitHub Copilot limitation prevents blocking prompts at submission
How Hooks Works
GitHub Copilot's hook system executes custom scripts at three critical points in both VS Code and the CLI:
3 Hook Points:
userPromptSubmitted- Monitors prompts when submitted to Copilot (reporting only, cannot block)preToolUse- Validates tool use before execution and can block dangerous operationspostToolUse- Ingests tool execution results for monitoring and audit
GitHub Copilot Limitation: The userPromptSubmitted hook cannot block prompt execution. Prompts flagged by guardrails will still reach the LLM. Only preToolUse can prevent operations from executing. For complete prompt blocking, consider using a network proxy.
File Structure
Key Files:
Wrapper scripts (
.sh): Set environment variables, invoke Python scripts⚠️ Contains
AKTO_DATA_INGESTION_URLplaceholder - Must be set to your Akto instance URL
Python scripts (
.py): Core validation logic and Akto API communicationakto_machine_id.py: Generates unique device identifiers for Atlas modehooks.json: Links hooks to wrapper scripts
Note:
hooks.jsonis loaded from the project root's.github/hooks/directory.
Setup Guide
Prerequisites
GitHub CLI installed or VS Code
Akto instance URL
Python 3
macOS or Linux with bash/zsh
Installation Steps
Create the Hooks Directory
Download Hook Scripts
Configure Akto Ingestion URL ⚠️ CRITICAL STEP
All wrapper scripts contain the variable AKTO_DATA_INGESTION_URL that must be set to your actual Akto instance URL.
Automated replacement:
Manual replacement (alternative):
Edit each wrapper script and replace:
With:
Files to update:
akto-validate-prompt-wrapper.shakto-validate-pre-tool-wrapper.shakto-validate-post-tool-wrapper.sh
Verify hooks.json Configuration
The hooks.json file should already be configured after downloading. Verify it contains all three hooks:
Note:
timeoutSecis in seconds (30 = 30 seconds). Hooks are loaded from.github/hooks/hooks.jsonin the directory you run copilot from.
Configure Hook Behavior (Optional)
Edit wrapper scripts to customize:
Mode Options:
Argus: Standard validation and reporting
Atlas: Includes device-specific metadata
Sync Mode:
true: Validates in real-time;
preToolUseblocks dangerous tool executionsfalse: Monitoring only; all tool executions pass through but are logged
Verify Installation
Check logs to confirm hooks are working:
Configuration Reference
Wrapper Script Variables
Environment Variables (Optional)
Override defaults via environment variables (e.g. in ~/.bashrc or ~/.zshrc):
Troubleshooting
Hooks Not Executing
Ingestion URL Not Configured
Check Logs for Errors
Events Not in Dashboard
Hook Timing Out
Increase timeoutSec in hooks.json (value in seconds, e.g. "timeoutSec": 60). Ensure AKTO_DATA_INGESTION_URL is reachable from your machine.
Permission Denied on Scripts
Uninstallation
Complete Removal
Selective Removal (Keep Logs)
Backup Before Removal
Verify Removal
Enterprise Deployment
Automated Deployment Script
Deploy to developers:
Quick Setup Summary
Resources
GitHub Copilot CLI: https://github.com/features/copilot/cli
Support: [email protected]
Community: https://www.akto.io/community
Last updated