Skip to content

feat(pool): a skill carries hooks that give text to the agents (ADR-0094) - #454

Merged
7schmiede merged 1 commit into
mainfrom
feat/agent-hooks
Nov 4, 2026
Merged

7schmiede merged 1 commit into
mainfrom
feat/agent-hooks

Conversation

@7schmiede

Copy link
Copy Markdown
Member

Closes #453.

A pool's skill can carry hooks: a hooks.toml beside its SKILL.md names texts that Claude Code and Codex get in their context at a session's start or on a prompt that matches a pattern. This is for routines that must not depend on the model deciding to load a skill (a session timer, a ticket checklist).

Review card

The owner approved all six points in the conversation on 2026-11-05 ("accepted, so bauen").

# Category Point Beats Reversing costs
1 concept A hook lives in a file hooks.toml in its skill's folder and shares the skill's fate: packed, accepted, switched on and off (ADR-0077), bound to repositories (metadata.repos) and updated with it. A manifest per set; hooks as objects of their own beside the skills. Hooks at the set's level would come additively; taking them out of the skills breaks the sources.
2 concept The hub writes one entry per agent and event, devstack hook <event> --agent <id>; this dispatcher decides on each call which hooks apply (skill installed and on, cwd in a bound repository, upstream accepted, pattern matches, not given yet) and prints their texts. An entry per hook with its text in the agent's configuration; bound hooks in the working tree's .claude/settings.local.json. Medium: entries per hook would have to be written and tracked on every change.
3 trust A pool's hook only adds text to the context; no command of a pool runs on a member's machine. If wrong: a pushed text steers every agent in every session without the model loading a skill, but it passes the same gate as a skill (acceptance, updates). Command hooks from the pool. Command hooks could come later, additively, with an acceptance of their own per hook.
4 contract The format: [[hook]] with event (session-start or prompt-submit), match (a regex on the prompt, prompt-submit only), once (session or match), upstream (optional), context or context_file (a file in the skill's folder), at most 2000 characters a hook. YAML in the frontmatter (every agent reads it); the agents' own event names. The pool's format has users outside the maintainers: only additive changes from now on.
5 concept The agent switch of the Skills page applies; hooks go only to an agent with an adapter in [agent.hooks] (devstack's own section of agents.toml, like [agent.open]), first Claude Code and Codex; the Skills page and doctor say which agent switched on gets none. A list of agents of its own for hooks; all ten agents now. Low: another adapter is additive.
6 concept The dispatcher never holds up a prompt: it reads the hub's state from disk (no hub needs to run) and prints nothing on any error, which goes to the diagnostic log. Asking the hub over HTTP (it may be stopped); an error shown in the prompt. Low.

Decided on my own, not on the card (also listed in ADR-0094):

  • The entry calls devstack from PATH, not the binary's path. A path changes with an update, and Codex would then ask to trust the entry again.
  • The record of which texts a session was given is a file per agent and session in the hub's state, forgotten after 7 days. A session that starts again after clear or compact is given the texts again.
  • once defaults to match for a hook with a pattern, otherwise to session.
  • The file is TOML (hooks.toml), like devstack's other files. It allows at most 8 hooks per skill, rejects unknown keys (such as command), and a pattern may be at most 500 characters.
  • Other keys in the agent's file keep their order and text (they are read as raw JSON, via the new serde_json feature raw_value and indexmap). The user's own hooks stay. A file that is not JSON is left alone; the error shows on the Skills page only when an entry should go into it.

What changed

  • devstack-node::hooks: the format and its checks. pack reads the file when it fetches a set; a wrong file leaves the skill out, with the reason. SkillEntry.hooks (added field, read as 0 when missing) gives the number of hooks.
  • devstack-hub::agenthooks: writes the index (agent-hooks.json) and the entries in ~/.claude/settings.json and ~/.codex/hooks.json, and holds the dispatcher. poolskills::sync reads each wanted skill's hooks from the archive of the version the user agreed to. Upstreams::pool_accepted answers the upstream check.
  • devstack hook <event> --agent <id> (hidden): always exits 0.
  • agents.toml: [agent.hooks] for Claude Code and Codex; scripts/sync-agents.py keeps this section when the table is taken again.
  • devstack doctor: lists which agents get the hooks, the Codex /hooks trust step, agents switched on that get none, and warns when devstack is not on PATH.
  • Skills page: a hook pill per skill, the hooks in the skill's detail, no hooks on an agent switched on without an adapter; the mock hub has data for this.
  • Docs: ADR-0094, docs/pool.md (A skill's hooks), docs/dashboard-api.md, CHANGELOG.

Tests

  • cargo test for devstack-node, devstack-hub, devstack-skills and devstack: green.
  • cargo clippy --workspace --all-targets and cargo fmt --check: clean.
  • UI: npm run typecheck and vitest run: green.
  • New tests cover:
    • the format and its errors;
    • a wrong hooks.toml at the fetch;
    • entries going into a user's settings.json and out again, with the key order kept and nothing written when nothing changes;
    • the index reaching only agents that are switched on and have an adapter;
    • a waiting update keeping the old text;
    • a switched-off skill taking its entry with it;
    • the dispatcher: repository, upstream, once per session and per match, again after compaction, unreadable input.
  • Smoke test on Windows: devstack hook without an index takes about 40 ms, prints nothing and exits 0.

Not tested here: a real Claude Code or Codex session running the entry, and macOS (the CI covers it).

🤖 Generated with Claude Code

…094)

A `hooks.toml` beside a skill's SKILL.md names texts for the agent's
context at a session's start or on a prompt matching a pattern, once a
session or once per match, optionally only while a pool's upstream is
accepted. The coordinator checks the file at the fetch; the hook shares
its skill's acceptance, switch, repositories and updates. Each hub writes
one entry per event, `devstack hook <event> --agent <id>`, into the hook
configuration of Claude Code and Codex when switched on; the dispatcher
picks the texts from the hub's state on disk and never holds up a prompt.
No command of a pool runs on a member's machine. The Skills page and
`devstack doctor` show the hooks and the agents that get none.

Refs #453

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@7schmiede
7schmiede merged commit d8ab8ae into main Nov 4, 2026
@7schmiede
7schmiede deleted the feat/agent-hooks branch November 4, 2026 23:40
@7schmiede 7schmiede mentioned this pull request Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant