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.


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: followupEvents 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 testwhen anything undersrc/**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_IDandCOHUB_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.
- Core concepts: Tasks, the run records that hook runs show up as
- App development: App Actions, which a hook can call with uses
Related
- Build a daily GitHub issues digest with a scheduled prompt and a Space hook
To get a GitHub issues digest every morning in Cohub, schedule a prompt that runs a digest skill in a fixed Chat, and add a Space hook that posts each new digest file to a webhook as soon as it is written.
- Scheduled prompts: cron for AI agents
Scheduled prompts are cron for AI agents: a Cohub prompt sent to a Space after a delay, at an ISO time, or on a cron expression with a time zone, with each run recorded in a Chat.
- Set up AI agent scheduled tasks that run inside your Cohub Space while you are away
You schedule AI agent tasks in Cohub with a scheduled prompt: a message the Space sends to its agent once at a set time or on a cron schedule, with every run kept as a Chat.
- How one Cohub Space works as an AI agent workspace for indie developers
Cohub is an AI agent workspace for indie developers: each Space has a cloud sandbox the agent runs commands in, port previews, one-command publishing and prompts that run on a schedule.