Move [PROJECT] onto Trigger.dev (v4 SDK): its background jobs, schedules, and any agent loop that waits on people or runs longer than a web request. Keep the live site working the whole time. 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 run in its own code block. 0. Look before you plan. Change nothing. - Confirm which repository and which deployed project I mean. If the folder has no jobs, schedules or agent loops, say so and ask; don't plan for the wrong repo. - Read the installed Trigger.dev docs and skills that ship in node_modules (and trigger.dev/docs/llms.txt) instead of remembering the API. Check the CLI version: `npx trigger.dev --version`. - Find where production keeps its data and prove it persists (row counts only). 1. Plan; change nothing yet. - List every piece of background work: cron functions (`crons` in vercel.json), GitHub Actions that fetch or commit data, polling loops and lease tables, queues, webhooks that do slow work inline, "durable" workflow or agent frameworks, and anything that waits for a human (approvals, one-time codes, replies). - For each one, give its Trigger.dev shape: a fixed schedule -> schedules.task({ cron }) a schedule users create -> schedules.create({ externalId, deduplicationKey }) per job "do this later, once" -> a delayed run (trigger with { delay }), cancelled with runs.cancel wait for a person -> wait.createToken + wait.forToken, completed by the task that receives the reply a sub-job whose result you need -> childTask.triggerAndWait one-at-a-time per user or conversation -> a queue with concurrencyLimit: 1 plus a concurrencyKey - Say what stays where it is. Trigger.dev runs tasks, not the website or the webhook endpoint; those stay on the web host and start tasks with tasks.trigger and an idempotency key from the event. - Read Trigger.dev's current pricing and limits, and say what this project needs. - Stop and show me the plan as a table: old piece -> new piece -> file. 2. Build it. - Work on a branch. Reuse the existing logic: move it into tasks, don't rewrite it. - Put the project ref in an environment variable, not in the source: project: process.env.TRIGGER_PROJECT_REF ?? "proj_your_project_ref" in trigger.config.ts, with the real value in a gitignored .env. Commit a .env.example with placeholders only. - When a run waits on a token: create the token and save its id BEFORE you send the question, so a fast reply can't arrive first. Clear it in a finally block. The task that receives replies checks wait.retrieveToken(id).status === "WAITING" before completing it, and treats anything else as stale. - If an AI SDK loop calls tools that wait, run tools one at a time (toolCallConcurrency: 1) so a run never has two waits open. - Add a test task that stands in for the real channel (SMS, Slack, email): it takes the same payload the webhook would and records replies in run metadata instead of sending them. Then the whole flow can be tested before the channel is connected. - Write unit tests for the parts that guard money, secrets and other people's data. 3. Provision. I make the accounts and click any terms; you do the rest from the CLI where you can. - Ask me which provider to use for each service, with your recommendation first. - Never ask me to paste a secret into chat. Have me put it in the gitignored .env file myself, then copy it into Trigger.dev without printing it: npx trigger.dev env set NAME "$VALUE" -e prod --secret (env set needs the value on the command line, and has no dev environment: dev reads .env). - Don't give me interactive shell commands (read -s, prompts) to run inside the agent app's command box: they hang. Give me a file to edit instead, or a command for a real terminal. - Tell me how to open hidden dotfiles if I need to edit one (open -e .env, or Cmd+Shift+. in Finder). 4. Deploy and test. - `npx trigger.dev whoami`, then `npx trigger.dev deploy --env prod`. Report the version it printed. - Start runs yourself: npx trigger.dev tasks trigger --env prod --payload '{...}' --wait - `runs get` shows status, not output or metadata, so check results where the task wrote them (the database, or metadata you can read some other way). Never read the CLI's stored token. - Run at least: the happy path, a path that waits for a human, a refused input (for example a sender who isn't allowed), and one real external call (browser, model, API). Give me duration and cost per run. - Deploy the web part separately and check each route returns what it should. A forged or expired link must fail. 5. Review before anyone else sees it. - Have a separate reviewer (a subagent with only the code) look for: SSRF in anything that fetches URLs, cross-user access by id, approvals that can be replayed or reused for a different amount, secrets in logs, screenshots or stored transcripts, and fail-open checks. Fix what it finds, add tests, redeploy, and run the tests from step 4 again. 6. Publish only when I say so, and keep deployment details out. - Before making a repo public, search the whole history (not just the working tree) for project refs, URLs of my deployments, team names, phone numbers, emails and keys. Check git notes and other refs too. - Commit with my GitHub noreply address, not a personal one. - If history has anything private, tell me and propose a fresh single-commit history. Don't force-push or change visibility without asking. - Add a LICENSE that keeps the original authors' copyright if the project is based on theirs. Throughout: - Never print or commit secrets, database addresses, account or project IDs, or my personal details. - Don't describe dashboard screens you haven't seen as fact; ask for a screenshot. - At every stop, say what you verified, what you didn't, and what still needs me.