agentleFS
gabriellstgabriellst/codm/.claude/skills/scheduler/SKILL.md

scheduler

Skill4 starsChanged 2 months agoMITView on GitHub

A "remind me later" / scheduled notification is persist-when-scheduled + a deliver-due endpoint a periodic worker polls — never an in-process setTimeout, never delivering at request time. When a command carries a future scheduledAt, persist the work in a SCHEDULED state (a status enum + a nullable scheduledAt column), and do NOT fire the delivery/event yet. When scheduledAt is absent or already past, behave immediately (the existing path). The entity's create() decides: status = scheduledAt && scheduledAt > now ?…

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When a command carries a future scheduledAt, persist the work in a SCHEDULED state (a status enum + a nullable scheduledAt column), and do …

    line 8

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

scheduler — scheduled reminders / deferred notifications canon

A "remind me later" / scheduled notification is persist-when-scheduled + a deliver-due endpoint a periodic worker polls — never an in-process setTimeout, never delivering at request time.

Persist scheduled, don't deliver now (SCH-01)

When a command carries a future scheduledAt, persist the work in a SCHEDULED state (a status enum + a nullable scheduledAt column), and do NOT fire the delivery/event yet. When scheduledAt is absent or already past, behave immediately (the existing path). The entity's create() decides: status = scheduledAt && scheduledAt > now ? SCHEDULED : DELIVERED. Exemplar: NotificationDelivery + SendNotification (skips NotificationSentEvent when future).

A deliver-due use case is the seam (SCH-02)

A DeliverDue<X> use case loads rows that are due — findDue(now) = status = SCHEDULED AND scheduledAt <= now (indexed on scheduled_at) — marks each delivered (markDelivered() → save) and raises the same domain event the immediate path raises, so downstream handlers/projectors react identically. Expose it as a controller (POST /notifications/deliver-due).

The trigger is a thin periodic worker (SCH-03)

The periodic poller belongs in the Go workers (packages/api/go — "workers, indexers, schedulers"), calling the deliver-due endpoint on a cron/ticker. The worker holds NO business logic — it just pokes the seam. (Keep the cadence coarse; due-window precision is the scheduledAt <= now query, not the poll frequency.)

In THIS fork the trigger is a repeatable JOB, not a Go worker (SCH-03a)

packages/api/go here is the WhatsApp gateway, not a worker fleet — there is nothing on that side to hang a ticker on, and a cross-service hop would buy nothing. What this repo has instead is a durable scheduler in core: SqliteCommandQueue writes shared_scheduled_commands rows in the SAME SQLite file as the domain, polls them once a second, and honours opts.repeat.every by RE-ARMING the row after each run. BoundedContext.create({ jobs: [{ handler, repeat: { every } }] }) is the one-line registration — it resolves + binds the handler, registers it as a command handler, and upserts the repeatable row.

So: still a deliver-due use case (SCH-02), still no business logic in the trigger — the trigger is just jobs:. Exemplars: AutoArchiveCompletedIssues (hourly, issue/index.ts) and FireDueLoops (per minute, thread/index.ts).

A setInterval is never the answer here, and the reason is sharper than durability in the abstract: this daemon is a Tauri sidecar that dies every time the operator quits the desktop app.

A missed run is a DECISION, not an accident (SCH-04)

A poller that was asleep when the alarm rang comes back to a row that is due and stale. Firing it anyway is rarely right for anything a human sees: a 09:00 prompt delivered at 14:00 reads as broken, and after a weekend's downtime the whole backlog fires in sequence. Give the sweep a grace window, skip past it, and make "skipped" a DIFFERENT transition from "delivered" so the read model never reports a delivery that did not happen (Loop.skipRun vs Loop.markFired).

Anti-patterns

  • setTimeout/setInterval in the request handler to defer delivery — lost on restart, not durable.
  • Delivering at request time and ignoring scheduledAt (the stub this canon replaces).
  • Business logic in the scheduler worker instead of behind the deliver-due use case.
  • Polling without a scheduled_at index / a status filter (full-table scans every tick).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.