Triggers
By the Syncfusion DevTutorials team · Last updated
Goal loops vs cadence loops, hooks and CI. Watch a goal loop miss the failures that arrive tomorrow, then turn it into a daily triage loop that stays quiet on empty days.
What Starts a Loop
So far, every loop started when you pressed Run. That is still you, starting the work.
This lesson is about triggers that start a loop without you.
Some loops should come back on a schedule. Some should wake up on an event.
There are three kinds of trigger:
- A goal. Run once, until a check passes.
- A schedule. Run again and again, at fixed times.
- An event. Run the moment something happens.
Simple lesson: pick the trigger that matches how your work arrives.
A Real-World Example
Think about keeping a kitchen clean.
After a party, you clean until the kitchen is spotless. Then you stop.
On normal days, you check the kitchen every evening at 8. If there are dishes, you wash them. If not, you do nothing and say nothing.
And when the smoke alarm goes off, you run to the kitchen right away.
Map this to loops:
- Clean until spotless = a goal loop.
- Check every evening = a schedule.
- Do nothing and say nothing = a quiet report.
- The smoke alarm = an event trigger.
A goal loop misses tomorrow's failures
Click the button. The lab fast-forwards 5 simulated days.
- Day 1: the loop fixes #14. Its goal is met, so it stops.
- Day 3: #19 arrives. Nothing starts the loop.
- Day 5: #2 arrives. It waits too.
About the 5 days
- In the lab, a day takes about a second. The clock jumps ahead.
- Every run is the same each time, so your loop can be checked.
- Real loops wait for real days.
Simple lesson: the goal loop did its job, then stopped for good. The work kept coming.
What You Will Learn
In this lesson, you will learn:
- Why a goal loop misses work that arrives later.
- How to write a schedule in the loop file.
- Why a schedule must be longer than one run.
- Why empty runs should stay quiet.
- How events, such as a failing CI build or a hook, start a loop.
- Which trigger fits which job.
Goal Loops Stop for Good
A goal loop is right for a fixed list. "Fix these 5 tickets" has a finish line.
But some work never ends. CI fails on Monday, again on Wednesday, again on Friday.
Watch a goal loop over those 5 days:
Step through all three frames.
- Frame 1: day 1. The loop fixes #14 and stops.
- Frame 2: day 3. A new failure arrives. Nothing runs.
- Frame 3: day 5. Two failures are still waiting.
Five days of new CI failures. The goal loop ran on day 1 only. The daily loop caught each failure on its day.
Simple lesson: a finish line is wrong for work that keeps arriving.
Schedules
Writing a Schedule
Schedule = a rule that starts the loop again at fixed times.
In the lab's loop file, a schedule takes the place of the goal under trigger::
trigger:
schedule: "every day at 09:00"
The lab can read schedules like these:
"every day at 09:00"or"daily""every 30 minutes"or"every 2 hours""hourly"or"weekly"
Each run ends when its work is done. Then the schedule starts the next run.
Stay Quiet on Empty Days
A daily loop often finds nothing. On those days, it should say nothing.
Quiet report = the loop posts a message only when it found something. In the lab, you write report: only-when-found.
Why it matters:
- A message every day that says "nothing found" teaches people to skip the loop's messages.
- Then they miss the day it finds something real.
A daily loop that never stays quiet
Click the button and look at the empty days. The loop still posts a message on each one.
Quiet does not mean no record.
- The run still happens, and it is still saved.
- You can check later that it ran.
- It just does not post to your team.
The Schedule Must Be Longer Than One Run
Say one run takes 10 minutes, and the loop starts every 5 minutes.
A new run starts while the last one is still working. Both may pick the same ticket. Both may edit the same file.
Step through all three frames.
- Frame 1: the loop linter warns before anything runs.
- Frame 2: run 2 starts while run 1 is still working on #2.
- Frame 3: with a daily schedule, each run ends long before the next.
A simple rule: pick a schedule at least twice as long as your slowest run.
Simple lesson: a schedule brings the loop back. Leave room between runs, and keep empty runs quiet.
Event Triggers
Waking Up When Something Happens
A schedule checks at fixed times, even when there is nothing to do.
Event trigger = a rule that starts the loop the moment something happens.
Common events:
- a CI build fails
- an issue is opened with a certain label
- an agent session ends
Now compare all three triggers on the same 5 days:
- Frame 1: the goal loop misses two failures. The daily loop catches all three.
- Frame 2: a quiet report removes the "nothing found" messages.
- Frame 3: an event trigger runs only on the days CI failed.
Hooks
Hook = a small script that a tool runs at a set moment. For example, a Stop hook runs when the agent says it is finished.
You can build a small goal loop with a Stop hook:
- The agent says "done". The Stop hook runs.
- The hook runs the tests.
- If they fail, the hook says "not done yet", and the agent keeps working.
- If they pass, the hook lets the agent stop.
The hook acts as the verifier and the stop rule at the same moment.
Important: a hook that blocks "stop" needs a limit too.
- If the tests can never pass, the hook keeps the agent working forever.
- Count the blocks.
- After a few, let the agent stop and ask a person.
Triggers in Each Tool
Real tools use their own names for the same three triggers.
A few facts worth knowing:
- In Claude Code,
/loopruns only while your session is open. For loops that run without you, use scheduled tasks, Routines or GitHub Actions. - Codex has scheduled tasks in the Codex app. Its docs do not cover event triggers yet, so use a schedule or CI.
- Cursor Automations run on a schedule or on events, such as GitHub or Slack.
In this lab, event: "when CI fails" stands in for all of these.
Simple lesson: use an event when speed matters. Use a schedule when once a day is enough.
Your Daily Loop
Lab Exercise: Turn It into a Daily Triage Loop
This loop runs once. Make it run every day, and keep empty days quiet.
Turn it into a daily triage loop
Click the button to open the loop file in the lab.
- Under
trigger:, replace thegoal:line withschedule: "every day at 09:00". - Add
report: only-when-foundat the top level. - Press Check my loop.
The check fast-forwards 5 days, 3 times. Each time, the failures arrive on different days.
Your loop passes when:
- every CI failure is triaged on the day it arrives
- empty days stay quiet
- no run starts before the last one finished
Simple lesson: a daily triage loop is a schedule plus a quiet report.
TL;DR
Trigger = what starts the loop:
- a goal
- a schedule
- an event
- Goal loop = runs once. It misses work that arrives later.
- Schedule = starts the loop again at fixed times, such as every day at 09:00.
- Safe schedule = longer than your slowest run. Twice as long is a good rule.
- Quiet report = post only when something was found:
report: only-when-found. - Event trigger = starts the loop the moment something happens, such as a failing build.
- Hook = a small script a tool runs at a set moment. It needs a limit too.
Common mistakes
| Mistake | Wrong idea | Correct idea | What goes wrong |
|---|---|---|---|
| A goal loop for daily work | "It fixed everything, so we are done." | New work needs a schedule or an event. | Tomorrow's failures wait. |
| A schedule that is too short | "More often is better." | The schedule must be longer than one run. | Runs pile up and touch the same files. |
| A noisy report | "Always tell the team the result." | Stay quiet on empty days. | People stop reading the loop's messages. |
| A goal and a schedule together | "Both can't hurt." | Pick one trigger per loop. | Nobody knows when the loop is meant to stop. |
| A hook with no limit | "Block stop until the tests pass." | Count the blocks and ask a person after a few. | A flaky test keeps the agent working forever. |
Check Your Understanding
Exercises
Press Check when you are ready. Use Show Hint if you get stuck.
What to Remember
- A trigger starts a loop: a goal, a schedule or an event.
- A goal loop stops for good. It misses work that arrives later.
- A schedule brings the loop back. Make it longer than your slowest run.
- Keep empty runs quiet with
report: only-when-found. - An event wakes the loop the moment something happens.
- Hooks and events need a limit too.
Further Reading
- Loop Engineering with Claude Code, by Classmethod: a small loop built on a Stop hook.
- Cursor Cloud Agents and Automations, on developertoolkit.ai: schedules and event triggers in Cursor.
- Loop Engineering Emerges, on ADTmag: why teams put agents on repeat.
Next: Skills Inside the Loop. You move long, pasted instructions into a skill, so each turn reads less.