loop
FreeNo executable scriptsNot checkedRun a prompt on a recurring interval using a blocking sleep loop. Use for polling CI, babysitting deploys, monitoring logs, periodic checks, or scheduled task…
by drn★ 23 GitHub starsAbout this skill
Loop
Run a prompt repeatedly at a fixed interval. The main thread stays alive by sleeping between executions, spawning a background agent each cycle to do the work.
Arguments
$ARGUMENTS- interval and prompt, or a management command (list, cancel)
Syntax:
/loop <interval> <prompt or /skill>
/loop list
/loop cancel <id>
/loop cancel all
Examples:
/loop 5m check if CI is green on this PR
/loop 20m /review-pr 1234
/loop 2h check for new Sentry errors in the payments service
/loop 30s tail the deploy logs and report status
/loop list
/loop cancel 2
Context
- Current branch: !
git branch --show-current 2>/dev/null | head -1 - Git status: !
git status --short 2>/dev/null | head -10 - Working directory: !
pwd
Instructions
Step 1: Parse the Arguments
Parse $ARGUMENTS to determine the action:
Management commands:
list- Show all active loops with their ID, interval, prompt, and execution count. If no loops are active, say so.cancel <id>- Mark the specified loop as cancelled. On the next sleep cycle, the loop will detect the cancellation and stop.cancel all- Mark all loops as cancelled.
New loop:
- Extract the interval token (first argument matching the pattern below)
- Everything after the interval is the prompt to execute
Interval parsing:
NsorNsec- N seconds (minimum 30 seconds, round up if less)NmorNmin- N minutesNhorNhr- N hoursNd- N days- No interval specified - default to 10 minutes
- Convert to seconds for the sleep command
If the prompt is empty after parsing, ask the user what they want to run.
Step 2: Confirm and Initialize
Present the loop configuration:
## Loop configured
**Interval:** {human-readable interval}
**Prompt:** {the prompt to execute}
**Loop ID:** {sequential integer, starting at 1}
Starting now. First execution is immediate. Use /loop list to check status or /loop cancel {id} to stop.
Initialize tracking state:
loop_id = {next sequential ID}
interval_seconds = {parsed interval in seconds}
prompt = {the prompt to execute}
execution_count = 0
max_executions = 500
cancelled = false
Step 3: Execute the First Iteration Immediately
Spawn a background agent to execute the prompt:
Agent(
prompt: "{prompt}\n\nThis is execution #{execution_count + 1} of a recurring loop (ID {loop_id}). Report your findings concisely.",
run_in_background: true,
description: "Loop {loop_id} run {execution_count + 1}"
)
Increment execution_count.
If the prompt starts with /, invoke it as a skill via the Skill tool inside the agent prompt instructions.
Step 4: Enter the Sleep Loop
This is the critical section that keeps the thread alive.
Loop:
Block the thread:
Bash("sleep {interval_seconds}")This keeps the lead thread alive in Conductor.
Check cancellation: If the loop has been marked cancelled (via a
/loop cancelcommand in another message, or by tracking state), output:Loop {loop_id} cancelled after {execution_count} executions.Stop looping and exit.
Check limits:
- If
execution_count >= max_executions, stop and report. - If the agent that ran the previous iteration reported a terminal condition (e.g., "CI is green", "deploy complete"), ask the user if they want to continue or stop.
- If
Spawn the next execution as a background agent (same as Step 3).
Output a heartbeat every 3rd execution:
Loop {loop_id}: execution #{execution_count} complete ({elapsed time} elapsed). Next in {interval}.Increment and repeat.
Step 5: Completion
When the loop ends (cancelled, max reached, or terminal condition), output:
## Loop {loop_id} finished
**Executions:** {count}
**Duration:** {total elapsed time}
**Reason:** {cancelled | max executions reached | terminal condition}
**Last result:** {brief summary of last execution output}
Failure Handling
| Failure | Action |
|---|---|
| Background agent fails to spawn | Retry once. If still fails, report error and continue to next iteration. |
| Prompt execution errors | Log the error in heartbeat output. Continue looping -- transient errors are expected for monitoring tasks. |
| Sleep interrupted | Re-enter the sleep for remaining time. |
| User sends a new message | The loop may pause. Resume on next turn. Note: in Conductor, user messages may interrupt the sleep loop. The loop resumes when control returns. |
Design Notes
This skill uses the same blocking-sleep pattern as /swarm to keep the main thread alive in Conductor. Unlike the built-in /loop (which uses CronCreate/CronDelete), this version:
- Dies when the workspace session ends (session-scoped)
- Runs the prompt via background agents so the lead can continue monitoring
- Tracks state in-memory rather than via cron infrastructure
- Works in any environment that supports the Agent and Bash tools
Install loop in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the loop skill do?
Run a prompt on a recurring interval using a blocking sleep loop. Use for polling CI, babysitting deploys, monitoring logs, periodic checks, or scheduled task execution.
How do I install the loop skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the loop skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
ci-review
The scan that the plugin's GitHub Action runs.
by Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
by GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
by GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
by GitHub