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
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's inside
- //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
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
- 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 to 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.
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 →