Twelve copies of the same article by morning
One morning I opened the article list and found the same title lined up 12 times. The article-writing bot on our Mac mini had repeated one job all night long. Even small scheduled tasks run by a non-developer team can fall into this more easily than you would expect.
Two causes
Reading the log line by line, the sequence went like this:
1. The bot generated the article and saved it successfully.
2. The last step, sending a Slack notification, hit a network error.
3. The bot treated the whole run as failed and started over from the beginning.
4. The completion marker was only written at the very end, so every restart began with no marker.
In short, retries had no cap, and the completion marker was written too late.
Two fixes
I asked Claude Code: 「Retry at most 3 times, write the completion marker right after the article is saved, and just log notification failures separately.」
The rules that ended up in place:
Max retries: 3
Retry interval: 10 minutes
Right after saving: write completion marker first
If all 3 fail: stop and post one line to Slack
Result
Over the next two weeks, no article was ever created twice. Notifications failed on two days, but the article was generated once and only the notification was retried.
Tips you can copy
• Always put a retry cap on scheduled jobs.
• Separate 「saving the result」 from 「sending the notice」 into different steps.
• Write the completion marker right after the core result exists, not at the end.
• When the cap is hit, do not stop silently. Tell a human in one line.
The gap between a bot working hard and a bot repeating itself is small. One cap line makes the difference.