← Claude Code Hub
Mar 31, 2026 · 3 min read ✦ Tip #035

Make Claude Code Watch Your Code While You Work

Use /loop to make Claude Code watch deploys, PRs, and logs on a recurring basis while you work. With full context, not like a blind cron.

TL;DR /loop 5m <prompt> runs a prompt on a recurring interval inside your active session. Unlike a cron with claude -p, each iteration has full access to your conversation context: files read, decisions made, changes in progress. It's a watchdog with a brain, not a blind script. And to place /loop inside the full picture of background mechanisms (Agent View, headless, Routines), the map with its decision table lays them all out.

You could set up a cron that runs claude -p "check deploy status" every 5 minutes. It works. But each execution starts from scratch — no memory of what happened before, no session context, no ability to act on what it finds.

/loop is different: it runs inside your open session. Claude knows which files you changed, what you were trying to do, and can compare with the previous iteration. If something changes, it can act immediately with all your tools.

The limitation: you need the session open. Close the terminal, and it's gone; just close the lid, and it freezes (what survives closing the laptop, case by case). Tasks also auto-expire after 7 days. For monitoring that survives a reboot, use headless mode with cron — or, if you want it running on Anthropic's infrastructure without your machine on, a Routine. Confused about which option fits — /loop, Desktop tasks, Cloud tasks, or system cron? See Stop Confusing /schedule, /loop, and Cron. For the full picture (including Monitor for events and Channels for external push), see the map of all 6 autonomous primitives. If what you want is Claude not stopping until a specific condition holds (instead of polling on a fixed interval), see /goal.

Result:

> /loop 5m check if the staging deploy at localhost:3000 is responding

Loop started (every 5m). Task ID: loop-a1b2c3
Next run: 12:05:00

# 12:05 — localhost:3000 returns 503. Deploy still in progress.
# 12:10 — localhost:3000 returns 200. Deploy complete. All health checks pass.

How to use it

1. Basic syntax

/loop [interval] <prompt>

Default interval is 10 minutes. Formats: 5m (minutes), 2h (hours), 1d (days).

2. Practical examples

# Watch a deploy
/loop 5m check if the staging deploy finished and tests pass

# Monitor PRs
/loop 15m check open PRs for new comments, summarize responses needed

# Detect merge conflicts
/loop 30m detect merge conflicts between current branch and main

# Scan logs for errors
/loop 5m scan app.log for FATAL/ERROR entries in the last 5 minutes

3. Best practices

  • Define alert conditions — you don't want noise on every iteration, only anomalies
  • Limit the scope — src/ instead of the entire project
  • Set termination rules — "stop after 3 consecutive passes"

/loop vs cron + claude -p

Aspect /loop cron + claude -p
Context Full session (files, history, decisions) None — each run is fresh
Can act Yes — edits, executes, uses tools Yes, but without prior context
Accumulates knowledge Yes — compares with previous iterations No
Persistence Only while session is open Survives reboots
Expiry 7 days automatically No limit
Concurrency Max 50 tasks per session No limit
Use case Watch while you work Real monitoring / scheduled tasks

Reference

Aspect Detail
Command /loop [interval] <prompt>
Default interval 10 minutes
Formats 5m, 2h, 1d
Max tasks 50 per session
Expiry 7 days
Persistence Does not survive terminal close
Type Bundled skill (ships with Claude Code)

Official docs: Skills — Bundled skills

Related: Computer use — when the terminal is not enough · Headless mode · The map of 4 ways to send Claude to background

Found this useful? See more of wmedia.es in your Google results.

Add wmedia.es as a preferred source on Google
FREE GUIDE

Approve less, but better.

Ten minutes in, you're hitting yes without reading. That's not review, that's prayer. A 10-page guide with the five levers in order of risk.

  • 1. Rules the first match wins
  • 2. Mode a dial, not a switch
  • 3. Auto mode a classifier approves for you
  • 4. Sandbox a fence the OS puts up
  • 5. Bypass only inside a container
Are you a professional Web developer?

You'll receive the guide by email · You join the Gravitas newsletter · Unsubscribe anytime

of 10
#

Wmedia · 10 pages
FREE GUIDE · 10 pages · 5 levers

Approve less, but better.

Ten minutes in, you're hitting yes without reading. That's not review, that's prayer. A 10-page guide with the five levers in order of risk.

Are you a professional Web developer? · Unsubscribe anytime
How I use AI

My Claude Code workflow.

The skills, agents and instructions I use as a professional Software Engineer. It's called Craft, and it's a plugin you can install.

See the skills

Tired of approving permissions without reading?