# Loop

Schedule a prompt to fire on a fixed cadence (recurring loop).

- Repository: https://github.com/XiaomiMiMo/MiMo-Code (13741 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add XiaomiMiMo/MiMo-Code --skill loop -g -a claude-code -y`
Codex: `npx skills add XiaomiMiMo/MiMo-Code --skill loop -g -a codex -y`
Cursor: `npx skills add XiaomiMiMo/MiMo-Code --skill loop -g -a cursor -y`
Gemini CLI: `npx skills add XiaomiMiMo/MiMo-Code --skill loop -g -a gemini-cli -y`

## Description

Schedule a prompt to fire on a fixed cadence (recurring loop). Use when the user asks to "run X every N minutes/hours/days", "loop X", "babysit Y", "be proactive about Y every N", or invokes `/loop` directly. Parses `[interval] <prompt>`, picks a clean cron expression, registers the job via the `cron` tool, and executes the prompt once immediately so the user sees activity without waiting for the first cron tick.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# /loop, schedule a recurring prompt

This skill turns a free-form `[interval] <prompt>` line into a `cron` tool call and runs the prompt once right away.

## 1. Parse the input

The user's text is whatever appears after `/loop `. Apply the three rules below **in order** and stop at the first match.

1. **Leading interval token.** If the first whitespace-separated token matches the regex `^\d+[smhd]$` (case-insensitive), that token is the interval. Examples: `5m`, `2h`, `1d`, `30s`. The rest of the input is the prompt.

2. **Trailing `every <N><unit>` clause.** Otherwise, look for a clause at the end of the input of the form `every <N><unit>` or `every <N> <unit-word>` where `<unit>` is `s|m|h|d` and `<unit-word>` is `second(s)|minute(s)|hour(s)|day(s)`. Strip the clause; what's left is the prompt; the captured `<N><unit>` is the interval. Examples: `every 20m`, `every 5 minutes`, `every 2 hours`.

3. **Default.** No interval found → interval is `10m`, the whole input is the prompt.

If the input is empty, or is *only* an interval with no prompt body, reply with a one-line usage hint (`/loop [interval] <prompt>`) and stop. Do not schedule anything.

## 2. Special: empty prompt with autonomous opt-in

When the user types `/loop <interval>` (interval only) **and** the project has explicitly opted into autonomous-loop mode (a session-level flag the runtime sets), the prompt body is the sentinel `<<autonomous-loop>>`. The scheduler expands this sentinel at fire time into a self-directed tick instruction. If autonomous mode is not enabled, treat empty as the usage-hint case above.

## 3. Map interval → 5-field cron expression

The rest: https://github.com/XiaomiMiMo/MiMo-Code/blob/HEAD/packages/cli/src/skill/builtin/.bundle/loop/SKILL.md
