Skip to content

Distribute agent hooks (session start, prompt pattern) from the pool, like skills #453

Closed

Description

@7schmiede

Problem

Some routines must run in every agent session, or whenever a prompt matches a pattern, no matter what the model decides. Two real cases:

  • A session-wide routine (here: a time-tracking skill that starts a timer at the start of every work session, served by a pool MCP upstream). A skill fires on the model's judgement only. On 2026-11-04 a session started with a long, step-by-step task prompt; the skill was listed but not loaded, and no timer ran. Two things added to it: the upstream was still connecting when the first prompt was read (its tools were not there yet, so the skill's condition "if the tools are there" was false), and its tools were deferred behind a tool search. The upstream's instructions (passed on by devstack mcp since 0.39.0) help, but they are still text the model weighs.
  • A per-repository routine: a repository ships a UserPromptSubmit hook (.claude/settings.json + a shell script) that recognises a ticket reference in the prompt (ABC-123, a tracker link, #123) and injects a short checklist into the context, once per session and ticket. It exists because a bare ticket URL as the whole message regularly did not trigger the matching skill. It works, but only for Claude Code, and only where the repository commits it.

Agent harnesses run hooks mechanically (Claude Code: SessionStart, UserPromptSubmit, ...; Codex and others have or are getting similar mechanisms). devstack already distributes skills from the pool into the agents' folders and registers its MCP server; hooks are the missing third piece.

Proposal

Let devstack distribute agent hooks the way it distributes skills:

  1. Source: a skill set may carry hooks, e.g. a hooks/ folder next to skills/<name>/ or a hooks section in the skill's frontmatter / a manifest: event (session-start, prompt-submit with an optional regex), a command or a static context text, a timeout.
    • A static text (additionalContext) covers most cases and needs no script on the member's machine.
  2. Install: the hub writes them into each enabled agent's configuration (Claude Code: hooks in ~/.claude/settings.json, or in the worktree's .claude/settings.local.json for metadata.repos-bound sets), marked as devstack's so it can update and remove them without touching the user's own hooks. Same accept/confirm setting as skills.
  3. Gate on an upstream: a hook may name the MCP upstream it belongs to and is only active while the member accepted that upstream (no timer reminder for someone not in the test).
  4. Visibility: the skills page / devstack pool skills status lists hooks with their source; devstack doctor reports a hook whose agent does not support the event.

Example (session-start reminder)

hooks:
  - event: session-start
    upstream: nuts-timetrack
    context: >
      Work session: load the skill nuts-work-session now, before the first task.
      If the nuts_timetrack tools are not listed yet, search for them (tool search);
      if they are still missing, tell the user that this session is not tracked.

Example (prompt pattern, per repository)

hooks:
  - event: prompt-submit
    match: '(^|\W)ABC-[0-9]+(\W|$)'
    once_per: [session, match]
    context_file: hooks/ticket-checklist.md

Open questions

  • Hooks run with the agent's rights; a command hook from the pool is code on every member's machine. Static context only for a first step?
  • once_per (session / match) needs state per session; keep it in the hub, or leave it to the command?
  • Which agents besides Claude Code can be served now; skip the rest with a doctor note?
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions