Files
awesome-copilot/docs/README.hooks.md
Ajith Raghavan 7446df7054 Add tool guardian hook (#1044)
* Tool Guardian Hook

Add Tool Guardian hook for blocking dangerous tool operations

   Introduces a preToolUse hook that scans Copilot agent tool invocations
   against ~20 threat patterns (destructive file ops, force pushes, DB drops,
   permission abuse, network exfiltration) and blocks or warns before execution.

* Address review feedback: move hook to .github/, remove accidental log file

  - Move hooks/tool-guardian/ to .github/hooks/tool-guardian/
  - Remove accidentally committed guard.log
  - Update all path references in README.md

* Move log directory to .github/, revert hook files back to
  hooks/

  - Revert hook files from .github/hooks/ back to hooks/tool-guardian/
  - Update default log path to .github/logs/copilot/tool-guardian/
  - Update all path references in README.md and hooks.json
2026-03-19 16:06:48 +11:00

2.8 KiB

🪝 Hooks

Hooks enable automated workflows triggered by specific events during GitHub Copilot coding agent sessions, such as session start, session end, user prompts, and tool usage.

How to Contribute

See CONTRIBUTING.md for guidelines on how to contribute new hooks, improve existing ones, and share your use cases.

How to Use Hooks

What's Included:

  • Each hook is a folder containing a README.md file and a hooks.json configuration
  • Hooks may include helper scripts, utilities, or other bundled assets
  • Hooks follow the GitHub Copilot hooks specification

To Install:

  • Copy the hook folder to your repository's .github/hooks/ directory
  • Ensure any bundled scripts are executable (chmod +x script.sh)
  • Commit the hook to your repository's default branch

To Activate/Use:

  • Hooks automatically execute during Copilot coding agent sessions
  • Configure hook events in the hooks.json file
  • Available events: sessionStart, sessionEnd, userPromptSubmitted, preToolUse, postToolUse, errorOccurred

When to Use:

  • Automate session logging and audit trails
  • Auto-commit changes at session end
  • Track usage analytics
  • Integrate with external tools and services
  • Custom session workflows
Name Description Events Bundled Assets
Dependency License Checker Scans newly added dependencies for license compliance (GPL, AGPL, etc.) at session end sessionEnd check-licenses.sh
hooks.json
Governance Audit Scans Copilot agent prompts for threat signals and logs governance events sessionStart, sessionEnd, userPromptSubmitted audit-prompt.sh
audit-session-end.sh
audit-session-start.sh
hooks.json
Secrets Scanner Scans files modified during a Copilot coding agent session for leaked secrets, credentials, and sensitive data sessionEnd hooks.json
scan-secrets.sh
Session Auto-Commit Automatically commits and pushes changes when a Copilot coding agent session ends sessionEnd auto-commit.sh
hooks.json
Session Logger Logs all Copilot coding agent session activity for audit and analysis sessionStart, sessionEnd, userPromptSubmitted hooks.json
log-prompt.sh
log-session-end.sh
log-session-start.sh
Tool Guardian Blocks dangerous tool operations (destructive file ops, force pushes, DB drops) before the Copilot coding agent executes them preToolUse guard-tool.sh
hooks.json