Migrate [PROJECT]'s background and scheduled jobs 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. If the folder you start in has no scheduled jobs, say so and ask; don't plan for the wrong repo. - Find where production actually stores its data, and prove it persists. Read row counts (counts only) in the database production is using now, and check whether the hosting integration gives each deployment its own database branch. (On Vercel, the Turso integration gave every deployment, production included, a fresh empty branch, so the site lost its state on every deploy.) If the live data doesn't persist, stop and tell me before anything else. - Check the settings that turn the jobs on or off in production (for example a feature flag that defaults to off). A job that skips every run can't be compared with anything; tell me what it would take to make it produce real output, such as a dry-run mode. 1. Plan first; change nothing yet. - List every job: cron functions (`crons` in vercel.json), GitHub Actions workflows that fetch or commit data, timers inside the app, scripts run by hand, and pages that fetch from slow sources when a visitor loads them. - For each: what it reads, what it writes (including emails or messages it sends), how often it runs, how long it runs, and what happens today when it fails. Read the host's logs for the last day of runs. - 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 and say which plan the number of schedules needs, and what the plan's log retention and alert destinations mean for this project. - Stop and show me the plan. 2. Build the new version beside the old one, not instead of it. Work in a separate git worktree or branch. - Give the new pipeline its own copy of the data: a database branch, a copy, or a separate schema. - Make three logins: read-only on live; full access to the copy only; and, for the switchover later, one that can change rows on live but not the schema. Write tokens straight into a gitignored .env file with quoted values; never print them. Prove the read-only login gets "permission denied" with a real INSERT inside a transaction you roll back. - Every task names the login it expects and checks it before doing anything: it tries a write and a CREATE TABLE (rolled back or dropped again) and refuses to run if the result doesn't match its role, if its login is missing, or if the copy's address is the live one. - Jobs that send email or messages: the copy pipeline must never send. Force dry mode in code, not in env, and prefer a "list only" mode that skips model calls too. - Reuse the existing job code: call it from tasks. Run Python with @trigger.dev/python (python.runScript plus pythonExtension). List every file the Python needs in `scripts` (config folders too, not just .py). - Data files a job commits to git move into a database table, served by an API route that falls back to the old file. Keep the old addresses working if anything else reads them. - Find code that runs CREATE or ALTER on every run (including a CLI entry point). Make it skip the setup when every table, column and index already exists, by reading the schema, so a rows-only login can start. Add a test that denies DDL and proves the job still starts. - Keep the Trigger.dev files out of the website's build (for Vercel, .vercelignore), and say how you'll prove that on a preview build. 3. Prove it locally before Trigger.dev is involved. - One script runs the same steps as the tasks against the copy: check logins, refresh the copy from live, run the job, compare. - The compare shows counts per section and per source, rows on one side only, and how fresh each side is. - Confirm nothing was sent and nothing changed on live, by reading the databases. Show me the comparison. 4. Set up Trigger.dev. - I create the account and project. Run `npx trigger.dev whoami` first, then ask me for the project ref. - Declarative schedules go live the moment you deploy. Say when each will first fire, and time the copy's runs so they don't collide with the old job (or run one minute before it, to predict it). - Use syncEnvVars for at most one non-secret address. Keep the full deploy log and tell me which variables were synced, by name. - For every other value, give me a table: name, what to put in it, Secret or not, and the narrowest kind of token (read-only database token, read-scaling warehouse token). I create tokens myself in a terminal and add them in the dashboard. Never upload a token from the shell. - Deploy with `npx trigger.dev deploy`. 5. Test it. - The CLI can't start a run, so ask me to click Test on each task (Tasks in the sidebar, or the Test page link the deploy prints). Include one task that should be refused for having no login, to prove the guard. - Verify each run by reading what it wrote in the database, and use `npx trigger.dev runs list` and `runs get ` for statuses and errors. Never read the CLI's stored token to call the API yourself. 6. Switch over only when I say so. - The new pipeline writes live with the 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. - The daily compare fails when live hasn't refreshed in 36 hours or drifts more than 5% from the old one. - Open a pull request and check the preview build; don't push to the main branch or merge unless I say so. - 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). Check the threshold after creating it: an alert drafted by "Ask Trigger" defaulted to "> 50 failed runs over 10 minutes", which never fires for jobs that run a few times a day. Make sure it has a channel. - New projects can't create a failed-deploy alert (the legacy "Deployment failure" alert is "Coming soon" to the new system). Say so, and suggest a CI notification if deploys run from CI. Throughout: - Never print or commit secrets, database addresses, account or project IDs. - 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.