Skip to content

Automations for GitHub Copilot: hooks in CLI, VS Code and the cloud agent #245

Backlog

Description

@vsn411

Part of #240. Builds on #242 and #241. Packaging: #227 (VS Code/Copilot row). CI: the existing secfoo GitHub Action (action.yml, #108).

What GitHub Copilot offers (checked against the docs on 2026-12-03)

Sources: Hooks reference, Use hooks, VS Code hooks, Plugins, Customize the agent environment.

  • One hook system across Copilot CLI, VS Code agent mode, the GitHub Copilot app and Copilot cloud agent. JetBrains support was not confirmed; check it.

  • Config: .github/hooks/*.json (repo), ~/.copilot/hooks/ (user, or $COPILOT_HOME/hooks/), inline hooks in .github/copilot/settings.json, plugin hooks.json, policy files (CLI only). Copilot also reads .claude/settings.json.

  • Format:

    {"version": 1, "hooks": {"preToolUse": [{"type": "command", "bash": "…", "powershell": "…", "timeoutSec": 30}]}}

    The CLI also accepts exec + args (no shell). Use that wherever supported. Default timeoutSec is 30.

  • Events (camelCase):

    • preToolUse: permissionDecision allow|deny|ask. ask becomes deny in the cloud agent. Non-zero exit denies, but timeouts fail open.
    • postToolUse: additionalContext, cannot undo.
    • agentStop / subagentStop: decision: "block" forces another turn, with a cap of 8.
    • Also sessionStart, sessionEnd, errorOccurred.
    • PascalCase names select a VS Code-compatible snake_case payload. Pick one form and test it.
  • Cloud agent:

    • Reads hooks only from .github/hooks/*.json on the default branch.
    • Setup runs from .github/workflows/copilot-setup-steps.yml. The job must be named copilot-setup-steps. Runners are Ubuntu x64 or Windows only, and the maximum timeout is 59 min.
    • By default only GitHub and Copilot hostnames are reachable, so a portal push fails unless an admin allowlists the portal host.
  • Plugins: Agent Plugins 1.0 plugin.json. Hooks live in com.github.copilot/hooks/hooks.json, skills in skills/<name>/SKILL.md, MCP servers in mcp.json. Distribution is through a marketplace.json; the built-in marketplace is awesome-copilot.

Recipe mapping

Recipe Copilot event Behaviour
commit-guard preToolUse on the shell tool permissionDecision: "deny" + reason. Set timeoutSec above the recipe budget, because the 30 s default fails open
turn-review agentStop decision: "block" with findings, loop-guarded (#242)
dependency-watch etc. postToolUse Start in the background. Return additionalContext only when a result is ready
session-brief sessionStart → additionalContext
PR review Not a hook: the existing secfoo GitHub Action on pull_request Already reports through CI. Document it as the PR path for Copilot cloud agent PRs

Reporting from the cloud agent

The sandbox is ephemeral, so an outbox entry is lost when the session ends. Options, in order:

  1. Document that admins add the portal host to the Copilot firewall allowlist, and give the key to the agent as an Agents secret, installing secfoo in copilot-setup-steps.yml.
  2. When the portal is unreachable, have secfoo hook say so in the agent output. The PR then goes through the GitHub Action, which reports from CI.
  3. Optionally write the run summary into the PR description so nothing is silently lost.

Run IDs must line up so the portal can join the agent's run with the CI run (use trigger.session_ref).

Gotchas

  • Copilot reads .claude/settings.json, so a Claude Code recipe enabled at project scope also fires in Copilot. Host detection and de-duplication from secfoo hook + secfoo automations: one tested entrypoint for every AI tool, recipes enabled on the fly #242 must handle it. Decide whether secfoo automations enable --tool copilot should skip writing when the Claude file already covers it.
  • secfoo's own copilot adapter runs copilot … --allow-all-tools for nested reviews. Hooks may fire there, so the recursion guard is mandatory. Verify it with the real CLI (an adapter recording already exists in tests/fixtures/agents/copilot/).

Tasks

Done when

The recipes work in Copilot CLI and VS Code. Cloud-agent reporting works with an allowlisted portal, or the documented fallback via the Action applies. Double-firing with Claude configs is tested.

Activity

  1. added
    enhancement
    help wanted
    difficulty: medium
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: mediumenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions