Add a typed event about a subject: naming, allowed properties (never free text), emitting it from the server or tracking it in the app, and subscribers that act on it.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ape Add Event?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/buffape-ape-add-event)
---
name: ape-add-event
description: "Add a typed event about a subject: naming, allowed properties (never free text), emitting it from the server or tracking it in the app, and subscribers that act on it."
---
# Add an event
1. Name it `object_action` in the past tense (`note_created`).
2. Declare it in the module's manifest with what it is about and typed props: `events: { note_created: { subject: 'note', props: { titled: 'boolean', mode: ['typed', 'tap'] } } }`. The subject is a noun of your module (its rows' type); props are IDs, numbers, booleans and enum values, never free text from people.
3. Record it on the server with `emit(ctx, 'note_created', { subject: { type: 'note', id: note.id }, props: { titled: true } })` from `@buffcore/modules/events`, in the transaction of the write it is about (`{ ...ctx, em }` inside `ctx.em.transactional`), so it commits with that write or not at all. In a client, use the SDK's tracker: `tracker.track('note_created', { titled: true })`.
4. To act on it, add a subscriber: a job with `on: 'note_created'` in `jobs`, whose payload is the event (`EventDelivery` from `@buffcore/modules/events`: `id`, `name`, `at`, `subject`, `props`). Each event queues one run per subscriber in its transaction. A job tries again when it fails, so make it safe to run twice: write through `ctx.em` (it commits with the job's done mark), and give `ctx.job.key` to an outside service as its idempotency key. The playground's `notes.ready` (`apps/playground/src/modules/notes/ready.ts`) is one.
5. The API rejects unknown names, invalid props and a subject of another type, and counts them; `emit` throws for them. Check in a test that your event is accepted, and run its subscriber with `drainJobs(app)` from `@buffcore/server/testing`.
6. Analytics counts a person as active by the events in `defineApp({ settings: { analytics: { activity: [...] } } })` (default `['app_opened']`): list the event that means "used the product" there (one your product declares, such as a session started).