Hook Development

A guide to building hooks for Copilot CLI plugins. Hooks are actions that run when events such as tool use, session start, or agent completion occur.

In plain words
What is it for?
Use it to configure pre- and post-tool checks, block disallowed operations, load project context, run commands, and enforce completion standards.
Why use it?
It helps automate checks and enforce rules during an agent session, such as reviewing tool calls before they run or checking results afterward.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/poorgramer-zack/copilot-cli-things/hook-development
Any agent
npx skills add Poorgramer-Zack/copilot-cli-things --skill hook-development
Clone the repo
git clone --depth 1 https://github.com/Poorgramer-Zack/copilot-cli-things

Made for: Claude Code, Codex.

Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,444 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00048 $0.03444
Opus 5 $0.00024 $0.01722
Sonnet 5 $0.00010 $0.00689
Haiku 4.5 $0.00005 $0.00344

Measured 2d ago against content hash b320e210ee6f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Hook Development scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 6 executable files (examples/load-context.sh, examples/validate-bash.sh, examples/validate-write.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/plugin-dev/skills/hook-development/SKILL.md · 665 lines

How it starts

The opening of the file, as written. The whole thing — 665 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Hook Development for Copilot CLI Plugins

Create event-driven hooks that validate operations, enforce policies, add context, and integrate external tools into Copilot CLI workflows.

  • Validate tool calls before execution (preToolUse)
  • React to tool results (postToolUse)
  • Enforce completion standards (agentStop, subagentStop)
  • Load project context (sessionStart)
  • Automate workflows across the development lifecycle

Hook Types

Command Hooks

Execute commands for deterministic checks:

{
  "type": "command",
  "command": "bash hooks/scripts/validate.sh",
  "timeout": 60000
}

Use for:

  • Fast deterministic validations
  • File system operations
  • External tool integrations
  • Performance-critical checks

Hook Configuration Formats

Plugin hooks.json Format

For plugin hooks in hooks/hooks.json, use wrapper format:

{
  "description": "Brief explanation of hooks (optional)",
  "hooks": {
    "preToolUse": [...],
    "agentStop": [...],
    "sessionStart": [...]
  }
}

Key points:

  • description field is optional
  • hooks field is required wrapper containing actual hook events
  • This is the plugin-specific format

Example:

{
  "description": "Validation hooks for code quality",
  "hooks": {
    "preToolUse": [
      {
        "matcher": "edit",
        "hooks": [
          {
            "type": "command",
            "command": "hooks/scripts/validate.sh"
          }
        ]
      }
    ]
  }
}

Settings Format (Direct)

For user settings in .github/settings.json, use direct format:

{
  "preToolUse": [...],
  "agentStop": [...],
  "sessionStart": [...]
}

Key points:

  • No wrapper - events directly at top level
  • No description field
  • This is the settings format

Important: The examples below show the hook event structure that goes inside either format. For plugin hooks.json, wrap these in {"hooks": {...}}.

Hook Events

preToolUse

Execute before any tool runs. Use to approve, deny, or modify tool calls.

Read the full file on GitHub · 665 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 665 lines · 0 tokens per session scan A b320e210ee6f

Subscribe to this mod's changes

Hook Development is a skill published in the GitHub repository Poorgramer-Zack/copilot-cli-things (2 stars, last pushed 5mo ago), licensed MIT. It adds 48 tokens to every session and 3,444 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

taiyi-forge

TaiyiForge 引擎控制面 — 用户只说 /taiyi: 斜杠,Agent 代跑 scripts/taiyi-forge.sh.

Dong90/oh-my-taiyiforge · 38 tokens

taiyi-ultrawork

TaiyiForge ultrawork — 并行切片 + Cursor Task 自动派发契约(对标 OMC ultrawork + spawnagent).

Dong90/oh-my-taiyiforge · 39 tokens

winui-session-report

Analyze the current or a recent agent session (GitHub Copilot CLI or Claude Code) and generate a diagnostic report. Use only when the user explicitly asks for session feedback, agent debugging, or a review of what happened during a build session. Do not inspect session data automatically.

microsoft/win-dev-skills · 61 tokens

re0-loop

Run repeated build -> QA -> re0-memo -> re0-work cycles while preserving learning and letting code die. Use for long agentic projects where progress must be measured by quality-cleared templates, reusable modules, and eliminated anti-patterns rather than hours spent or features accumulated.

LilMGenius/paperthin · 60 tokens

ask-codex

Consult OpenAI Codex for investigation, debugging, or code review. Use when user explicitly asks to "ask codex", "check with codex", "codex review", or as a last resort when stuck after 4+ failed attempts at debugging, investigation, or bug fix and completely out of ideas. Codex is slow (2-5 min), so only escalate…

umputun/cc-thingz · 103 tokens

taiyi-orchestrator

TaiyiForge 统一入口 — 意图解析、阶段路由、Token预算、工件预检。Use when 用户说"开始/继续/审查/测试/设计"等流程相关意图。.

Dong90/oh-my-taiyiforge · 51 tokens