Skip to content

How to Use Claude Code's /loop and /schedule Commands for Automated Workflows

Problem

I kept checking my PRs every few minutes to see if there were new review comments. I’d refresh GitHub, check Slack for CI updates, and manually clean up stale branches. This context-switching was killing my productivity.

Then I found out Claude Code has built-in automation commands that can do all this for me.

What I Learned

Claude Code has two slash commands for automation: /loop and /schedule. According to Boris Cherny (the creator of Claude Code), these are “two of the most powerful features” - yet most people don’t know about them.

Here’s what each command does:

Command overview
/loop → Runs a command at regular intervals (every 5m, 30m, 1h)
/schedule → Runs a command at a specific time (daily, weekly)

Both can run for up to a week without manual intervention.

How Boris Uses Them

In a recent Reddit thread, Boris shared his real setup:

CommandIntervalPurpose
/loop 5m /babysitEvery 5 minutesAuto-address code review comments
/loop 30m /slack-feedbackEvery 30 minutesPost PR updates to Slack
/loop 1h /pr-prunerEvery 1 hourClose stale PRs

This means his PRs get attention even when he’s focused on other work.

My First Attempt

I started with a simple babysit loop:

Claude Code command
/loop 5m /babysit

The output confirmed it was running:

Claude Code response
Started loop: /babysit will run every 5 minutes.
Use /loop stop /babysit to stop this automation.

I went back to coding. Five minutes later, I saw Claude had already addressed two minor review comments on my PR. This was working.

Adding More Automation

Next, I added the Slack feedback loop for my team:

Claude Code command
/loop 30m /slack-feedback

Now my team gets automatic updates about:

  • PR approvals
  • Build status changes
  • Review comment counts

I didn’t need to manually post anything.

What Went Wrong

I got too excited and added everything at once:

Claude Code commands (my mistake)
/loop 5m /babysit
/loop 5m /pr-pruner
/loop 10m /slack-feedback

The problem? /babysit and /pr-pruner sometimes conflicted. One would try to address comments while the other was closing the PR. Not good.

The Fix

I staggered the intervals:

Claude Code commands (fixed)
/loop 5m /babysit
/loop 30m /slack-feedback
/loop 1h /pr-pruner

This works because:

  • Babysit runs frequently (needs fast response)
  • Slack updates don’t need to be instant
  • PR cleanup is maintenance, runs hourly

Checking Active Loops

To see what’s running:

Claude Code command
/loop status

Output:

Claude Code response
Active loops:
- /babysit (every 5m, started 2h ago)
- /slack-feedback (every 30m, started 2h ago)
- /pr-pruner (every 1h, started 2h ago)

Stopping Automation

When I need manual control:

Claude Code command
/loop stop /babysit

Or to stop everything:

Claude Code command
/loop stop all

The Difference Between /loop and /schedule

I initially confused these two. Here’s the distinction:

Loop vs Schedule comparison
/loop 5m /babysit → Runs every 5 minutes (recurring)
/schedule daily /cleanup → Runs once per day (scheduled)

Use /loop for:

  • Active monitoring (PR babysitting)
  • Frequent updates (Slack notifications)
  • Background tasks (cleanup)

Use /schedule for:

  • Daily summaries
  • Weekly audits
  • One-time future tasks

Best Practices I Learned

1. Don’t set intervals too short

Bad example
/loop 1m /babysit # Too frequent, wastes resources

5 minutes is a good minimum for most tasks.

2. Don’t overlap conflicting commands

Bad example
/loop 5m /babysit
/loop 5m /pr-pruner # May conflict with babysit

Space them out appropriately.

3. Monitor the output

Automations can fail. I check the logs every few hours to make sure things are working.

Real-World Scenarios

Solo Developer:

Claude Code commands
/loop 10m /babysit # Check PRs every 10 minutes
/loop 1h /pr-pruner # Clean up hourly

Team Development:

Claude Code commands
/loop 5m /babysit # Fast response to reviews
/loop 30m /slack-feedback # Keep team informed
/loop 1h /pr-pruner # Repository hygiene

Release Day (intensive monitoring):

Claude Code commands
/loop 2m /babysit # Very frequent checks
/loop 15m /slack-feedback # Frequent updates
/loop stop /pr-pruner # Pause maintenance during release

Why This Matters

Before these commands, I spent about 30 minutes per day on PR housekeeping. Now I spend 2 minutes setting up automation at the start of the day, and everything runs itself.

The key insight: these aren’t just convenience features. They change how you work. You can focus on deep work while Claude handles the repetitive monitoring tasks.

Summary

In this post, I showed how to use Claude Code’s /loop and /schedule commands for automated workflows. The key points are:

  • /loop runs commands at intervals (5m, 30m, 1h)
  • /schedule runs commands at specific times (daily, weekly)
  • Both can run for up to a week
  • Use staggered intervals to avoid conflicts
  • Start with /loop 5m /babysit and add more as needed

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments