Skip to content

Instantly share code, notes, and snippets.

@Strajk
Created March 7, 2026 09:33
Show Gist options
  • Select an option

  • Save Strajk/7bcece00b2ff0f5f501a0845ce009d27 to your computer and use it in GitHub Desktop.

Select an option

Save Strajk/7bcece00b2ff0f5f501a0845ce009d27 to your computer and use it in GitHub Desktop.
Claude Code /loop skill — schedule a recurring prompt on an interval (extracted from @anthropic-ai/claude-code@2.1.71)
name description argument-hint source-path source-package source-date adaptations
loop
Run a prompt or slash command on a recurring interval (e.g. /loop 5m /foo, defaults to 10m). Use when the user wants to set up a recurring task, poll for status, or run something repeatedly on an interval. Do NOT invoke for one-off tasks.
[interval] <prompt>
cli.js (line 8047, function Agz / qgz)
@anthropic-ai/claude-code@2.1.71
2026-03-07
- ${HU} (Claude Code internal schedule tool name) replaced with plain English description - ${H_6} (Claude Code internal cancel command) replaced with plain English description - ${Ze6} ("10m" default interval variable) inlined as literal 10m - ${A} (user input argument) replaced with $input to match batch skill convention

/loop — schedule a recurring prompt

Parse the input below into [interval] <prompt…> and schedule it as a recurring job.

Parsing (in priority order)

  1. Leading token: if the first whitespace-delimited token matches ^\d+[smhd]$ (e.g. 5m, 2h), that's the interval; the rest is the prompt.
  2. Trailing "every" clause: otherwise, if the input ends with every <N><unit> or every <N> <unit-word> (e.g. every 20m, every 5 minutes, every 2 hours), extract that as the interval and strip it from the prompt. Only match when what follows "every" is a time expression — check every PR has no interval.
  3. Default: otherwise, interval is 10m and the entire input is the prompt.

If the resulting prompt is empty, show usage /loop [interval] <prompt> and stop — do not schedule anything.

Examples:

  • 5m /babysit-prs → interval 5m, prompt /babysit-prs (rule 1)
  • check the deploy every 20m → interval 20m, prompt check the deploy (rule 2)
  • run tests every 5 minutes → interval 5m, prompt run tests (rule 2)
  • check the deploy → interval 10m, prompt check the deploy (rule 3)
  • check every PR → interval 10m, prompt check every PR (rule 3 — "every" not followed by time)
  • 5m → empty prompt → show usage

Interval → cron

Supported suffixes: s (seconds, rounded up to nearest minute, min 1), m (minutes), h (hours), d (days). Convert:

Interval pattern Cron expression Notes
Nm where N ≤ 59 */N * * * * every N minutes
Nm where N ≥ 60 0 */H * * * round to hours (H = N/60, must divide 24)
Nh where N ≤ 23 0 */N * * * every N hours
Nd 0 0 */N * * every N days at midnight local
Ns treat as ceil(N/60)m cron minimum granularity is 1 minute

If the interval doesn't cleanly divide its unit (e.g. 7m*/7 * * * * gives uneven gaps at :56→:00; 90m → 1.5h which cron can't express), pick the nearest clean interval and tell the user what you rounded to before scheduling.

Action

Schedule the job using the available scheduling tool or mechanism (e.g. schedule_task, cron entry, or equivalent) with:

  • cron: the expression from the table above
  • prompt: the parsed prompt from above, verbatim (slash commands are passed through unchanged)
  • recurring: true

Then confirm to the user: what's scheduled, the cron expression, the human-readable cadence, that recurring tasks auto-expire after 3 days, and that they can cancel sooner (include the job ID).

Input

$input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment