Claude Templates / B-tier · Situational
Infrastructure
The Scheduler Engine Playbook
One queue for every future-dated action: drips, reminders, scheduled sends.
SCHEDULER-ENGINE-PLAYBOOK.md · 14 sections · 2,469 words · 21 KB · markdown
By Moe Ameen, founder of BILT · Published · Updated
The Scheduler Engine Playbook builds one queue for every future-dated action an app takes, such as posts, emails, texts and reminders. Claude Code creates a scheduled_actions table with a state machine, a once-a-minute scheduler tick that fans out dispatch, an atomic claim so nothing fires twice, a reconciler that keeps the queue in sync, cancel and retry handling, timezone rules and an optional recurring expander.
Key takeaways
- One table for every scheduled action type.
- A once-a-minute tick dispatches due rows.
- Atomic claims and a database guard stop double fires.
- Recurring schedules like every Tuesday at 9am are optional.
A generic scheduled_actions table plus a tick worker, so you build the scheduling layer once instead of per feature. Covers claim-and-lock dispatch, cancellation, retry with an attempt ceiling, and timezone handling that doesn't drift across DST.
What does the Scheduler Engine Playbook build?
It builds the generic scheduling layer: table, state machine, tick cron, reconciler cron, database-level publish guard and the UI hooks for cancel, reschedule and retry.
A drip-sequence variant is included for email or SMS sequences.
When should you build a generic scheduler?
Build it the second time you need to schedule something, usually in weeks 3-4. The first time, a single-purpose queue is fine.
The Publishing Pipeline playbook covers social posting specifically; this one is the general version.
What do you need first?
You need Trigger.dev Workers, Supabase with a service-role key, the action types you'll schedule and the provider for each.
Decide where each workspace's timezone comes from before you write a single schedule.
What's inside
What does the playbook give you?
- //A generic scheduled_actions schema with a payload discriminator
- //A tick worker with claim-and-lock (no double-fire)
- //Cancel, reschedule, and retry semantics with an attempt ceiling
- //Timezone + DST handling for user-local scheduling
- //Backfill and catch-up behavior after downtime
When to use it
Weeks 3-4, the second time you need to schedule something.
Build these first
Straight from the file
What does the writing look like?
Reconciliation runs server-side every minute so it doesn't depend on a client tab being open. It (a) inserts missing rows for newly-approved items, (b) updates publish_at when the upstream wall time changes, (c) deletes orphan rows when the upstream item moves out of "scheduled" state.
Table of contents
Which sections does the file cover?
- 0. Use this spec
- 1. Architecture
- 2. Schema (generic scheduledactions)
- 3. Status state machine
- 4. Scheduler-tick cron (the fan-out)
- 5. Reconciler cron (queue ↔ source-of-truth sync)
- 6. Worker dispatch — atomic claim
- 7. DB-level publish guard (belt-and-braces)
- 8. Cancel / reschedule / retry
- 9. Timezones
- 10. Recurring schedules (bulk)
- 11. Drip-sequence variant
- 12. Common pitfalls
- 13. Kickoff prompt
How do you run it?
Drop SCHEDULER-ENGINE-PLAYBOOK.md into your repo, then tell Claude Code: “Read SCHEDULER-ENGINE-PLAYBOOK.md and implement it in this codebase.” It's written for an agent to execute end to end. Search the file for angle-bracket placeholders and swap in your own project names, domains, and keys before the first run.
Who is this for, and who should skip it?
Best for
- Apps with several kinds of scheduled actions
- Products where users pick send times in their own timezone
- Teams that have shipped a double-send bug before
Not ideal for
- Apps with one cron job and no user scheduling
- Teams using a hosted workflow scheduler
- Products without a worker runtime
- Builders who won't adapt paths: the file points to a reference app you won't have
What else do people ask?
Why does the Scheduler Engine Playbook use two crons instead of one?
The Scheduler Engine Playbook splits a tick that dispatches due rows from a reconciler that creates and cleans up rows based on upstream state, so one bug can't corrupt both jobs. Both run once a minute, and the file warns against running the tick faster.
How do reschedule and retry work?
In the Scheduler Engine Playbook, a reschedule is a cancel plus a new row, never an edit to publish_at, so you keep a record of what was planned versus what shipped. A retry is admin-only and moves a failed row back to queued with attempt_count raised, capped at 5, without inserting a new row.
How does it handle timezones and DST?
The Scheduler Engine Playbook stores publish_at in UTC and reads each workspace's IANA timezone from settings, converting local times with a resolveScheduledInstant function built on Intl.DateTimeFormat. It validates the timezone in a try/catch first, because one bad user-entered value crashes every row's conversion.
What bug does the reconciler's terminal-history gate prevent?
The Scheduler Engine Playbook's terminal-history gate stops the reconciler from re-inserting a row for a target that already published, failed or was cancelled. Without it the tick republishes the item minutes later, which is how the reference app shipped a carousel triple-publish bug.
Does it work without Trigger.dev or Supabase?
The Scheduler Engine Playbook is written for Supabase plus Trigger.dev, using schedules.task, tasks.trigger and Supabase query calls, with Postgres SQL for the tables, indexes and duplicate-publish trigger. It doesn't cover other worker runtimes, so those calls would need rewriting.
How do we know this?
This page is based on the playbook file itself, SCHEDULER-ENGINE-PLAYBOOK.md, which Moe Ameen wrote from the Kompozy codebase (called BKE in the file). We read the file on November 4, 2026; the facts here come from it, not from independent testing in other codebases.
More infrastructure playbooks
Email Infrastructure
Postmark, the SPF/DKIM/DMARC recipe, drip campaigns, and transactional vs marketing routing.
Read + download →A-tierTrigger.dev Workers
The three-file pattern for anything that can't finish inside an HTTP request.
Read + download →B-tierWebhook Receiver
Receiving third-party webhooks (and sending your own) without losing events.
Read + download →