Cohub
中文Start a Space

Space hooks: run scripts on AI agent events

Space hooks let you run scripts on AI agent events in Cohub: a YAML file in .cohub/hooks/ runs a command, sends a prompt or calls an App Action when a turn finishes, files change, a Save is created or a webhook arrives.

Who
Builders who want checks and follow-ups to happen on their own after the agent or a teammate changes something.
When
You keep telling the agent "now run the tests" or "summarise what changed" after every turn.
Why
A hook is a file in the Space that reacts to Space events, so the rule travels with the project and runs as the Space owner without anyone watching.
Cohub home page showing an isolated cloud workspace where an agent keeps running tasks after you leave
Source: cohub.live
Terminal output of cohub spaces webhooks --help: list, url and trigger for hooks declared in .cohub/hooks
Source: www.npmjs.com/package/@neta-art/cohub-cli

One file per hook

Hooks live in .cohub/hooks/*.yml (or .yaml, .json). Each declares one event and exactly one action: run (a shell command), prompt (a message to a Chat) or uses (a published App Action).

# .cohub/hooks/review-after-save.yml
schema: cohub.space-hook.v1
on:
  event: checkpoint.created
prompt:
  text: summarize the new checkpoint and suggest next steps
  intent: followup

Events you can react to

Event Fires when Filters
space.fs.changed Workspace files change paths, ignore, kinds
session.turn.finalized An agent turn finishes Chat ids, sources (web, CLI, channel), labels
checkpoint.created A Save is created
app.version.published An App version goes live
task.updated A task run changes state
space.workspace.ready A restore or bootstrap finishes
webhook Something POSTs to the hook's URL Optional shared secret

Things to build with hooks

  • Run npm test when anything under src/** changes.
  • After every turn in Chats labelled Review, ask a reviewer Chat to check the diff.
  • When an App version is published, post release notes to a file.
  • Receive a webhook from another service and hand its JSON body to a script or an App Action. cohub spaces webhooks url <name> prints the URL to give that service.

Step by step, with a real run: a daily GitHub issues digest pairs a scheduled prompt with a space.fs.changed hook that posts each new digest file.

Good to know

  • Hooks run as the Space owner, who is also billed.
  • Each hook gets context in environment variables such as COHUB_HOOK_EVENT_TYPE, COHUB_HOOK_SESSION_ID and COHUB_HOOK_FS_PATHS.
  • Changes under .cohub/ never trigger file hooks, so a hook can't loop on itself.
  • The design is an MVP: no separate hook permissions or concurrency control yet, failures are recorded without automatic retries, and hook discovery assumes a cloud sandbox workspace.

Full schema

Full schema and environment variables: Space hooks in the repository. For time-based work, use scheduled prompts.

Reference in the docs

This page: Which Space events are worth a hook, and what to automate with one.

Sources

Published · Updated