PTENES
MODULE 4.6 · BUILD

🛠️ Build: publish a scheduled automation

It’s time to actually do what the previous modules explained: write the task, test it safely, add the keys, publish it, and schedule a fixed time—so one of your automations runs on its own in the cloud every day, even with your laptop turned off.

6
Topics
45
Minutes
Intermediate
Level
Practical
Type
0 of 60%
1

🎯 What you’ll build

Let’s publish a simple but real automation: every day at 8 a.m., it fetches some information (for example, a news summary, the day’s weather, or pending requests from a system) and notifies you — by email or message. The goal here isn’t the automation itself; it’s the entire publishing process, which applies to any automation you build in the future.

You won’t write code by hand. Claude Code writes it; you read what it proposes (remember plan mode, module 4.5?), approve, test, and publish. Your job is to guide and review — just as a manager approves an employee’s work before it goes out the door.

1

Write the task

Ask Claude Code, in Portuguese, what the automation should do.

2

Test in dev

Run in a test environment (module 4.3), with no risk to production.

3

Configure secrets and publish

Keys in the dashboard (module 4.4) and deploy so the platform can actually run.

4

Schedule and verify

Set a fixed time and confirm in the dashboard that it ran on its own.

💡 Main Concept

These 4 steps are the same pipeline from module 4.2 (code → repository → cloud), but now you’re doing the work yourself. Once you’ve done it once, every future automation follows the same path.

2

✍️ Write the task with Claude Code

New here? Trigger.dev it’s the execution platform this course uses: you (or rather, the agent) write the task’s code, deliver it to the platform through a repository, and it takes care of running it at the right time, with retries and a built-in queue (module 4.5). You don’t need to know how Trigger.dev works under the hood—you just need to know how to request the right task and read what it returns.

Open a terminal in your project folder (module 0.3) and use plan mode before asking it to do the actual task—that way, you can review the design (search separately from writing, as in module 4.5) before the code is written.

Objective: ask Claude Code to create a scheduled task that retrieves a simple piece of data and notifies you by email, following the best practices from the previous modules.

Quero uma automação agendada usando Trigger.dev, escrita em TypeScript.
Ela deve:
1. Rodar todo dia às 08:00 (horário de ).
2. Buscar  — essa etapa não grava nada, só lê.
3. Se a busca der certo, montar um e-mail resumido e enviar para
    — essa é uma etapa separada
   da busca, como aprendi no módulo 4.5.
4. Usar retentativa automática (3 tentativas) só na etapa de busca,
   já que repetir a busca é seguro.

Antes de escrever o código, me mostre o plano das tasks separadas e onde
ficam as variáveis de ambiente (chaves de API) que vou precisar cadastrar.

How to verify: Claude Code should respond with a plan listing at least 2 tasks (search and send), the names of the required environment variables (without actual values), and the schedule in a time format. Only after that should you approve writing the code.

🔍 Inside

  • TypeScript: the language this task’s code is written in. You don’t need to learn it — the agent writes it, you read the plan in Portuguese, and approve it.
  • Repository (git): is where the code is stored and versioned — the "shelf" where Trigger.dev gets the task to run (more in module 4.2).
3

🧪 Test in dev before changing production

New here? Dev (from "development") is the test environment — a copy of the automation that runs separately from the real version that users (or you yourself, day to day) rely on, called production. That's the subject of module 4.3: two "worlds" so you can break things without worry in the test one.

After Claude Code finishes writing the task, run it locally in Trigger.dev's development mode, which runs the task right away without waiting for the scheduled time—so you can see the result (or the error) in seconds, not the next day.

Objective: run the task manually in development mode to confirm it works before actually publishing it.

# dentro da pasta do projeto, com o CLI do Trigger.dev instalado
npx trigger.dev@latest dev

# noutro terminal, dispare a task manualmente (sem esperar o cron)
npx trigger.dev@latest test 

How to verify: in the terminal where you ran it dev, you should see a sequence of lines showing the task starting, fetching the data, and finishing successfully (usually in green). If you see red, that’s an error—go back to Claude Code, paste the error message, and ask it to investigate before continuing.

✓ Correct testing routine

  • ✓Ran it in dev and read the entire log before continuing
  • ✓Tested at least 2x to see if the result is consistent
  • ✓Only moved on to deployment after seeing “success” in the test

✗ Skipping the test

  • ✗Went straight to deploy “because the code looks right”
  • ✗Only discovers the error after the scheduled task has already run in production
  • ✗Needs to investigate with real users who are already affected
4

🔐 Add secrets in the dashboard

New here? One environment variable is a secret value (an API key, a password) that the automation uses but is never written into the code—as module 4.4 explained, the local file with these values is never uploaded to the repository. Instead, you enter them manually in the platform’s dashboard.

Notice that you enter the keys twice: once in the dev environment (just for testing) and once in production—they’re separate boxes. This prevents a test key (less powerful and cheaper) from being used accidentally in the real environment.

.env local never gets pushed to git you copy by hand Panel — DEV test keys Panel — PRODUCTION real keys Task runs in dev testing without risk Task runs in production for real users

Caption: the local file never goes to the repository; you enter the same key names, with different values, directly in the dev and production dashboards — each environment has its own isolated set.

⚠️ Attention

Never paste a real API key into a conversation with the agent and ask it to “save it in an example file” or something similar — always use placeholders (SUA_CHAVE_AQUI) in any text, prompt, or documentation. The actual keys should only be entered manually in the platform’s dashboard.

5

🚀 Deploy and scheduling

New here? Deploy is the act of publishing: taking code you've already tested in dev and putting it into production, where it runs for real and is available 24 hours a day. Cron it’s the standard way to write “what time to repeat”— a compact format like “every day at 8 a.m.” translated into symbols, but Claude Code writes it for you based on what you ask for in Portuguese.

Deploy takes the code from your repository to the platform, which then runs it on its own on the defined schedule —without your laptop needing to be on (the topic of module 4.1).

Objective: publish the tested task to production, after you’ve already added the production secrets in the dashboard.

# confirma que está na branch principal e tudo commitado
git status

# envia o código pro repositório remoto (GitHub)
git push origin main

# publica a versão de produção na plataforma
npx trigger.dev@latest deploy --env production

How to verify: The deploy command finishes by displaying a success message with the name of the published task. Then, open the platform dashboard (trigger.dev, on your project tab) and confirm that the task appears listed as “active” with the correct schedule (e.g., “every day at 08:00”).

💡 Practical Tip

If the deploy command asks you to log in or provide a token, that’s normal the first time—Claude Code will guide you through it. Once it’s configured, future deploys only require the command above.

6

👀 Verify that it actually ran

A published deploy isn’t the end—it’s the start of a check-in routine. The next day (or a few hours later, depending on the scheduled time), go back to the dashboard (also called dashboard — the screen where the platform shows everything that ran) and confirm the run appeared with a success status.

This habit of checking — without needing to understand the code behind it — is exactly what the next module, the last in this track, is about: reading the execution dashboard and, when something fails, finding the reason by reading the log, not the code.

✓ Properly published

  • ✓Tested in dev, published to production, and came back the next day to check
  • ✓Found the run in the dashboard with a success status
  • ✓Received the expected email (or notification) at the right time

✗ "I published it and forgot about it"

  • ✗Deployed it and never opened the dashboard again
  • ✗Only realizes it stopped working when you notice the alert is missing, weeks later
  • ✗Doesn’t know where to look when something goes wrong

🎯 Main Concept

  • •Task written by the agent → tested in dev → secrets added → deployed → scheduled.
  • •Publishing isn’t the end: it’s the start of the habit of checking the dashboard.

Quick check (optional): Why test the task in dev before publishing to production?

✅ Module Summary

✓
Task with the agent: you give instructions in Portuguese, and Claude Code writes the code.
✓
Dev before production: testing in a separate environment avoids risk to real users.
✓
Secrets in the dashboard: keys registered manually, separated by environment, never in the repository.
✓
Deploy + scheduling: the automation starts running on its own, 24 hours a day, at the scheduled time.

Next module:

4.7 — Observability: reading the executions dashboard and finding the error in the log