What you need: Claude Code installed (CLI, IDE extension, or desktop app). That is it. No API keys, no extra setup, no scripts.

Step 1 — Open Claude Code in a project

Open a terminal in any project folder and start Claude Code, or launch the desktop app. If you do not have a real project to test on, an empty folder works fine — loops do not need a codebase to run.

cd ~/your-project
claude

Step 2 — Pick a task worth repeating

Loops earn their keep on tasks you would otherwise type more than once. Good first candidates:

For this guide we will use a very simple example: check the current git status every minute and only report changes. Replace it with whatever fits your day.

Step 3 — Type your first /loop command

In the Claude Code prompt, type:

/loop 1m run git status. Only tell me if something is different from the last run.

Hit enter. Three things happen:

  1. Claude parses the interval (1m) and the task body.
  2. It runs the task immediately and reports the result.
  3. It schedules itself to wake up again in 1 minute.

Step 4 — Watch the first run

You will see Claude run git status via the Bash tool and print the working tree state. On a clean tree, the response is something like:

Working tree clean. Next check in 1 minute.

This is normal. Loops are most useful precisely when they are quiet — they only need to interrupt you when something changes.

Step 5 — Watch the scheduled re-run

After roughly a minute, Claude will wake up on its own. The interface shows a small "loop iteration" indicator and the task re-runs. If nothing has changed, Claude stays quiet. If you create a new file, edit something, or commit, Claude reports the diff:

Change detected:
  modified:   src/app.ts
Everything else clean. Next check in 1 minute.

Try editing a file in another terminal and watch the next iteration pick it up.

Step 6 — Try dynamic mode

Now let Claude pick its own pacing. Stop the current loop first (next step) and try:

/loop watch the dev server. Tell me if it crashes. Stop when it stays alive for 30 minutes straight.

No interval. Claude will decide how long to wait between checks based on what it observes — short waits when the server is bouncing, longer ones when it stabilizes. You will see Claude call ScheduleWakeup at the end of each iteration with a chosen delay and a reason.

Step 7 — Stop the loop

When you are done, end the loop with:

/loop stop

Or simply close the Claude Code session. Either way, the loop terminates cleanly and nothing runs in the background.

Common starter templates

Copy any of these, swap the details for your own project, and you have a useful loop:

Poll a long-running CI build

/loop 3m check the latest GitHub Actions run for branch feature/payments. Only ping me on success, failure, or a flaky retry.

Watch for new error log lines

/loop 5m tail the last 200 lines of /var/log/app.log. Report any new ERROR or FATAL entries you have not seen before.

Track open PRs that touch a critical file

/loop 30m list open PRs that modify src/payments/charge.ts. Report new ones, closed ones, or new review requests.

Re-run a flaky test

/loop 90s run npm test -- payments.spec.ts. Stop when it passes 5 times in a row.

Tips for your first week

  1. Start with longer intervals. 5-10 minutes is plenty for most things. Tighter intervals burn more tokens.
  2. Tell Claude when to stop. "Stop when X happens" produces cleaner loops than ones that run forever.
  3. Be specific about what counts as "new." "Only tell me about errors I have not seen before" is much better than "watch for errors."
  4. Use dynamic mode for unpredictable timing. Polling external services? Let Claude self-pace.
  5. Combine with skills. /loop 1h /code-review works, and so does /loop 15m /verify.
You are done. You now know how to start, run, observe, and stop a Claude Loop. Everything else on this site is depth and examples.

Where next?

Now go automate something

The best way to learn loops is to loop a real task you already do twice a day.

Browse Examples →