Move [PROJECT]'s background and scheduled work to Trigger.dev (v4 SDK), without risking the live site. Follow these steps in order, and stop where a step says to. I may be on my phone: put every question and its choices in your message as plain text, and give every command I should paste in its own code block. 0. Find the right project and the real live data. Change nothing. - Confirm which repository and which deployed project I mean. - Find where production stores its data, and prove it persists (read row counts only). Check whether the hosting integration gives each deployment its own database branch, and whether production, preview and local development share one database. Report both; if live data doesn't persist, stop and tell me. - Check the settings that turn jobs on or off in production. Say what it would take to make a job produce real output, such as a dry-run mode. - Run `npx trigger.dev@latest --help` and read the CLI docs that ship in node_modules/@trigger.dev/sdk/docs. Use what the installed version can do, not what you remember: recent versions can start a run (`tasks trigger --env prod --wait`) and manage variables (`env`). 1. Plan first; change nothing yet. - List every job: cron functions (`crons` in vercel.json), CI workflows that fetch or commit data, timers in the app, scripts run by hand, pages that fetch slow sources when a visitor loads them, and work done inside a request that the visitor doesn't need to wait for (sending notifications after a form is submitted). - For each: what it reads, what it writes (including emails or messages it sends), how often, how long it runs, and what happens today when it fails. Read the host's logs for the last day. - If there are no jobs, say so plainly and stop. Don't invent work to fit these steps. Suggest what would be worth running on Trigger.dev, and ask me. - Say which ones Trigger.dev should run and which stay where they are. Trigger.dev runs jobs, not the website. - Read Trigger.dev's current pricing. Say which plan the number of schedules needs, and what its log retention and alert destinations mean for this project. - Say which steps below don't fit this project, and why, instead of doing them anyway. - Stop and show me the plan. 2. Build the new version beside the old one, not instead of it. Work on a branch. - If there is an old pipeline, give the new one its own copy of the data (a database branch, a copy, or a separate schema). If the project shares one database across environments, say so and ask. - Give tasks their own database login with only the access they need (for example SELECT on one table and UPDATE on named columns). Write it straight into a gitignored .env file with quoted values; never print it. Prove each permission it shouldn't have (INSERT, DELETE, other columns, CREATE, ALTER) is refused, with real statements. - Every task checks its login before doing anything (the role name, and that CREATE TABLE is refused) and refuses to run with a missing or broader login. - Jobs that send email or messages: only production sends. Decide that in code from the run's environment, not from an env variable. Mark each channel as sent before sending the next, so a retry never sends twice. - Abort (no retry) only on setup problems that retrying can't fix: a missing login, no notifier configured. Rethrow database and network errors so the retry policy applies. - If a web request hands work to a task, the request must still succeed when Trigger.dev is unreachable. Add a scheduled sweep that picks up anything the hand-off missed, with an age limit, and make lost items visible: alert once per item, not on every run. - Treat every value from a public form as hostile: - URLs a task fetches: http(s) only, no IP literals, check every address the host resolves to (inside the connection's DNS lookup) and every redirect against private, loopback, link-local and metadata ranges. In Node, keep IPv4 and IPv6 ranges in separate BlockLists. - Text in notifications: one line per field, length-limited; escape &, < and > for Slack and send with mrkdwn off; never include secrets such as promo codes. - Logs and run output: outcomes and counts only, never submitted values. - Reuse existing job code; call it from tasks. Put shared logic in a module with no Trigger.dev imports so a local script can run it. Run Python with @trigger.dev/python (python.runScript plus pythonExtension). - Find code that runs CREATE or ALTER on every run, and make it skip setup when the schema already exists. - `trigger init` may put tasks in ./src/trigger and add an example task. Move the folder to match the project and delete the example. - Keep the Trigger.dev files out of the website build (for Vercel, .vercelignore). Trigger tasks from the website by id (`tasks.trigger("task-id", ...)`), with no import of the task file. Prove the site builds with those files removed. 3. Prove it locally before Trigger.dev is involved. - One script runs the same code as the tasks, as the same limited login, against the real data, with stand-in email and Slack servers. It covers: a dry run that sends nothing, a send that fails and its retry, a repeat run that is skipped, the login guard refusing the owner login, hostile input in every field, and the sweep's age limit. It removes its test rows. - Show me the output. Confirm nothing was sent and nothing changed on live, by reading the database. 4. Set up Trigger.dev. - I create the account and project. Run `npx trigger.dev whoami` first, then ask me for the project ref. Don't repeat the account details it prints. - Declarative schedules go live the moment you deploy. Don't deploy until the variables they need are set, and say when each will first fire. - Don't use the Vercel integration's variable sync if it would copy the database owner's address into Trigger.dev; if I want it, have me deselect database variables first. - Give me a table of every value: name, what to put in it, Secret or not, and the narrowest kind of token. I create tokens myself and add them in the dashboard. Never upload a token from the shell. - Open a pull request; check its preview build. Don't push to main or merge unless I say so. - Deploy with `npx trigger.dev deploy`. 5. Test it. - Start runs yourself with `npx trigger.dev tasks trigger --env prod --payload '...' --wait` if the installed CLI has it; otherwise ask me to click Test. Include one run that should be refused (no login) to prove the guard. - Verify each run by reading what it wrote in the database, and use `runs list` and `runs get `. Never read the CLI's stored token to call the API yourself. - Submit the real form once and follow it end to end: the row, the run, the email, the Slack message. 6. Switch over only when I say so (if there was an old pipeline). - The new pipeline writes live with a rows-only login. Prove it can change a row and can't CREATE or ALTER. - The old jobs keep running against a copy, with a login that can't write live. - A daily compare fails when live hasn't refreshed in 36 hours or drifts more than 5% from the old one. - Write down how to undo the switch. 7. Alerts. - Alerts are under Observability in the dashboard sidebar, per environment: pick Production first. - Create a runs alert that fires on any failed run (threshold > 0) and check the threshold after creating it. Make sure it has a channel. - New projects can't create a failed-deploy alert. Say so, and suggest a CI notification if deploys run from CI. Throughout: - Never print or commit secrets, database addresses, account or project IDs. - Review your own diff for security problems before the first push. If an automated reviewer flags each fix in turn, stop, choose the design on purpose, and tell me which finding you're not taking and why. - Don't describe dashboard screens you haven't seen as fact. If I can't find something, ask for a screenshot, and look for a CLI command that does the same thing. - At each stop, say what you verified and what you didn't.