Windsurf prompt to add email notifications
Notifications become reliable when sending is decoupled from the request, which is the spine of this prompt: a swappable transport, file-based templates, and an outbox drained by a worker. Cascade greps for your signup and reset handlers inside Windsurf first, so the trigger points land in the code you actually have.
Last updated
Add email notifications to this codebase. Build an EmailService with a provider interface so transports swap cleanly, a console transport for development, and templates as files under emails/ with subject and body separated. Triggers: welcome on signup, password reset with a one-hour token link, and a weekly digest stub behind a feature flag. Sending happens off the request path: reuse the repo's job queue if one exists, otherwise an outbox table in {{database}} drained by a worker; ask me before adding {{addon}}. Handle missing addresses, unsubscribed users, and template render failures without crashing the caller. Before editing, have Cascade grep for the real signup and reset handlers so hooks land in the right functions, then run the test suite and list changed files.Customize it
Runs in your browser. Nothing you type here is sent anywhere.
Add email notifications to this codebase. Build an EmailService with a provider interface so transports swap cleanly, a console transport for development, and templates as files under emails/ with subject and body separated. Triggers: welcome on signup, password reset with a one-hour token link, and a weekly digest stub behind a feature flag. Sending happens off the request path: reuse the repo's job queue if one exists, otherwise an outbox table in PostgreSQL drained by a worker; ask me before adding input validation. Handle missing addresses, unsubscribed users, and template render failures without crashing the caller. Before editing, have Cascade grep for the real signup and reset handlers so hooks land in the right functions, then run the test suite and list changed files.
Same task in other tools
Questions about this prompt
Why the grep step before editing?
Signup logic hides in odd places: controllers, service objects, sometimes an auth library callback. Having Cascade locate the real handlers first prevents a welcome email wired to a route nobody calls.
How do I target a provider like SES or Postmark?
Name it in the prompt and keep the console transport for development. Cascade then implements the provider interface for that SDK behind the seam instead of scattering send calls through the codebase.
Emails occasionally send twice. What is happening?
The worker is picking up outbox rows a previous run already sent but failed to mark. Ask Cascade to make the drain step claim rows with an atomic update and to add a test that kills the worker mid-batch.