copilot-hooks

Configure GitHub Copilot Agent hooks for lifecycle event governance.

Updated Oct 24, 2024
One-click install
npx skills add https://github.com/tuannguyen151/nestjs-clean-architecture --skill copilot-hooks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: copilot-hooks
Source: https://github.com/tuannguyen151/nestjs-clean-architecture/tree/main/.claude/skills/copilot-hooks
Command: npx skills add https://github.com/tuannguyen151/nestjs-clean-architecture --skill copilot-hooks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Defines and configures GitHub Copilot Agent hooks that run commands at lifecycle events, enabling you to block dangerous commands, auto-format code, log usage, and inject project context.

Core Features & Use Cases

  • Hook events support: PreToolUse, PostToolUse, SessionStart, Stop, SubagentStart, SubagentStop, UserPromptSubmit, PreCompact, and more.
  • Location-first configuration: Workspace hooks are discovered in standard locations (.github/hooks, .claude/settings.json, .claude/settings.local.json, and user-global).
  • Templates & scripts: Ready-to-use templates and scripts for common safeguards like blocking destructive commands, formatting changes, auditing, approvals, and context injection.

Quick Start

Use the Copilot Hooks skill to create a .github/hooks/config.json and a starter script in scripts/ to enforce a simple PreToolUse block for dangerous commands.

Frequently Asked Questions about copilot-hooks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Copilot Agent hooks to block dangerous commands during automation?

You configure Copilot Agent hooks by creating a .github/hooks/config.json and a starter script to define PreToolUse events. This governance setup enforces safety by intercepting and blocking destructive commands before execution.

What lifecycle events are supported by Copilot Agent hooks?

Copilot Agent hooks support PreToolUse, PostToolUse, SessionStart, Stop, SubagentStart, SubagentStop, UserPromptSubmit, and PreCompact events. These lifecycle triggers enable automated command execution, context injection, and usage logging.

Where does Copilot look for workspace hook configurations?

Workspace hooks are discovered in standard locations using a location-first approach. Copilot looks for configurations in .github/hooks, .claude/settings.json, .claude/settings.local.json, and user-global settings to apply local kickoffs.

Can I auto-format code and audit usage automatically with Copilot hooks?

Yes, you can auto-format code and audit usage using ready-to-use templates and scripts. PostToolUse hooks apply formatting changes after execution, while audit templates log session activity for consistent governance.

Do I need any external dependencies to enforce safe automation with Copilot hooks?

No external dependencies are required to enforce safe automation with Copilot hooks. The configuration relies on standard workspace locations and included script templates to handle lifecycle events and inject project context.

When should I use Copilot hooks for workflow governance instead of manual checks?

Use Copilot hooks for workflow governance when sessions require predefined events like SessionStart or PreToolUse. This approach is necessary for consistent safety enforcement, automated auditing, and context injection across automated sessions.