Skip to content

Instantly share code, notes, and snippets.

@aydinnyunus
Last active March 13, 2026 21:21
Show Gist options
  • Select an option

  • Save aydinnyunus/9d507810e78554e2a18668a3dcfd65a8 to your computer and use it in GitHub Desktop.

Select an option

Save aydinnyunus/9d507810e78554e2a18668a3dcfd65a8 to your computer and use it in GitHub Desktop.

Revisions

  1. aydinnyunus revised this gist Mar 8, 2026. 1 changed file with 103 additions and 3 deletions.
    106 changes: 103 additions & 3 deletions SKILL.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,109 @@
    ---
    name: claude-loop-scheduler
    description: "Documents Claude Code's built-in scheduler (/loop) for recurring prompts, one-time reminders, and cron tools. Use when the user asks about scheduling prompts, /loop, reminders, or polling in Claude Code."
    name: loop
    description: "Documents /loop-style recurring reminders and Claude Code's built-in scheduler. In Cursor: /loop [interval] <message> adds a crontab entry (macOS + Linux); one-shot uses background sleep + notify. List/cancel via crontab. In Claude Code: use built-in /loop. Use when the user asks for /loop, scheduled reminders, or recurring prompts."
    ---

    # Claude Code built-in scheduler
    # /loop: recurring reminders (Cursor + Claude Code)

    ## Using /loop in Cursor (crontab, no Claude Code required)

    When the user asks for a recurring reminder in Cursor (e.g. `/loop 5m remind me to stand up` or `loop every 1m remind me to stand up`), **do not** ask them to use Claude Code. Implement it with **crontab** so reminders persist across sessions and work on **macOS and Linux**.

    ### 1. Parse the request

    - **Interval**: leading (`/loop 5m ...`) or trailing (`... every 2 hours`). Units: `s`, `m`, `h`, `d`. Default if missing: **10 minutes**. Cron has 1-minute granularity; round seconds up to 1m.
    - **Message**: the reminder text (e.g. "remind me to stand up" → "Stand up").
    - **Unique ID**: generate a short id (e.g. 8 alphanumeric, like `standup5` or `a1b2c3d4`) and use it as `CURSOR_LOOP_<id>` so the reminder can be listed and cancelled later.

    **Comment format:** Every crontab entry for /loop must end with a structured comment so scheduled tasks can be listed and deleted by id. Use:

    `# CURSOR_LOOP_<id> | <interval> | <message>`

    Example: `# CURSOR_LOOP_standup5 | 5m | Stand up`. The agent parses this to show a tasks table and to remove by id.

    ### 2. Interval → cron expression

    | Interval | Cron (minute hour day month dow) |
    |----------|----------------------------------|
    | 1m | `* * * * *` |
    | 5m | `*/5 * * * *` |
    | 15m | `*/15 * * * *` |
    | 1h | `0 * * * *` |
    | 2h | `0 */2 * * *` |
    | 1d | `0 0 * * *` |

    For other values: `Nm``*/N * * * *`, `Nh``0 */N * * *`. Round to a supported step if needed.

    ### 3. Add crontab entry

    **macOS** (notification when user is logged in):

    ```bash
    ( crontab -l 2>/dev/null; echo "CRON_EXPR osascript -e 'display notification \"MESSAGE\" with title \"Reminder\"' # CURSOR_LOOP_ID | INTERVAL | MESSAGE" ) | crontab -
    ```

    **Linux** (needs `notify-send`, often from `libnotify-bin`):

    ```bash
    ( crontab -l 2>/dev/null; echo "CRON_EXPR DISPLAY=:0 notify-send 'Reminder' 'MESSAGE' # CURSOR_LOOP_ID | INTERVAL | MESSAGE" ) | crontab -
    ```

    - Replace `CRON_EXPR` with the cron expression (5 fields).
    - Replace `MESSAGE` with the user's message; escape inner single/double quotes for the shell.
    - Replace `CURSOR_LOOP_ID` with the unique id (e.g. `CURSOR_LOOP_standup5`).
    - Replace `INTERVAL` with the interval string (e.g. `5m`, `1h`) and keep `MESSAGE` in the comment so the line is parseable when listing.

    Detect OS with `uname -s` (Darwin → macOS, Linux → Linux).

    ### 4. Confirm and tell how to cancel

    After adding: "Reminder every &lt;interval&gt; added. To remove: `crontab -l | grep -v CURSOR_LOOP_<id> | crontab -`" or "Cancel with: cancel the &lt;message&gt; reminder."

    ### List scheduled tasks (Cursor)

    When the user asks "what scheduled tasks do I have" or "list my reminders":

    ```bash
    crontab -l 2>/dev/null | grep CURSOR_LOOP
    ```

    - Each line ends with a comment `# CURSOR_LOOP_<id> | <interval> | <message>`.
    - Parse the comment: split on ` | ` (space-pipe-space) to get **id**, **interval**, **message**.
    - Display as a table, e.g.:

    | ID | Interval | Message |
    |----------|----------|-----------|
    | standup5 | 5m | Stand up |

    - For each row, to cancel: `crontab -l | grep -v CURSOR_LOOP_<id> | crontab -` (use the ID from the table).
    - If there are no lines, say "No scheduled tasks."

    ### Cancel a reminder (Cursor)

    When the user says "cancel the stand up reminder" or "remove reminder &lt;id&gt;":

    ```bash
    crontab -l 2>/dev/null | grep -v CURSOR_LOOP_<id> | crontab -
    ```

    - Use the **id** from the comment (the part after `CURSOR_LOOP_` and before the first ` | `). If the user names the message, find the line whose comment contains that message and use its id.

    ### One-shot reminder in Cursor

    "Remind me in 30 minutes to ..." or "in 45 minutes ..." cannot use cron (no "run once in N min"). Run in background:

    **macOS:** `( sleep SECONDS && osascript -e 'display notification "MESSAGE" with title "Reminder"' ) &`
    **Linux:** `( sleep SECONDS && DISPLAY=:0 notify-send 'Reminder' 'MESSAGE' ) &`

    Report PID and when it will fire. User can stop with `kill <PID>`.

    ### Linux note

    On Linux, `notify-send` is often in the `libnotify-bin` package. If the user doesn't have it, suggest installing it (e.g. `sudo apt install libnotify-bin` or equivalent).

    ---

    ## Claude Code built-in scheduler (reference)

    Claude Code can run prompts on a schedule: recurring loops, one-time reminders, or cron-style tasks. Tasks are **session-scoped**; they stop when you exit. For durable scheduling across restarts, use [Desktop scheduled tasks](https://code.claude.com/docs/en/desktop#schedule-recurring-tasks) or GitHub Actions.

  2. aydinnyunus revised this gist Mar 8, 2026. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SKILL.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ---
    name: claude-loop-scheduler
    description: Documents Claude Code's built-in scheduler: /loop for recurring prompts, one-time reminders, and cron tools (CronCreate, CronList, CronDelete). Use when the user asks about scheduling prompts, recurring tasks, /loop, reminders, polling deployments, or babysitting builds in Claude Code.
    description: "Documents Claude Code's built-in scheduler (/loop) for recurring prompts, one-time reminders, and cron tools. Use when the user asks about scheduling prompts, /loop, reminders, or polling in Claude Code."
    ---

    # Claude Code built-in scheduler
  3. aydinnyunus renamed this gist Mar 8, 2026. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. aydinnyunus created this gist Mar 8, 2026.
    78 changes: 78 additions & 0 deletions claude-loop-scheduler.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    ---
    name: claude-loop-scheduler
    description: Documents Claude Code's built-in scheduler: /loop for recurring prompts, one-time reminders, and cron tools (CronCreate, CronList, CronDelete). Use when the user asks about scheduling prompts, recurring tasks, /loop, reminders, polling deployments, or babysitting builds in Claude Code.
    ---

    # Claude Code built-in scheduler

    Claude Code can run prompts on a schedule: recurring loops, one-time reminders, or cron-style tasks. Tasks are **session-scoped**; they stop when you exit. For durable scheduling across restarts, use [Desktop scheduled tasks](https://code.claude.com/docs/en/desktop#schedule-recurring-tasks) or GitHub Actions.

    **Source:** [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks)

    ## Schedule a recurring prompt with /loop

    ```text
    /loop [interval] <prompt>
    ```

    - **Interval** is optional. Default: every 10 minutes.
    - Leading: `/loop 5m check if the deployment finished`
    - Trailing: `/loop check the build every 2 hours`
    - No interval: `/loop check the build` → every 10 minutes

    **Units:** `s` (seconds), `m` (minutes), `h` (hours), `d` (days). Seconds round up to the nearest minute (cron granularity). Odd intervals (e.g. 7m, 90m) are rounded; Claude reports what was chosen.

    **Loop over a command/skill:**

    ```text
    /loop 20m /review-pr 1234
    ```

    ## One-time reminder

    Natural language; single-fire, then the task deletes itself.

    ```text
    remind me at 3pm to push the release branch
    ```

    ```text
    in 45 minutes, check whether the integration tests passed
    ```

    ## Manage tasks

    - List: `what scheduled tasks do I have?`
    - Cancel: `cancel the deploy check job` or by task ID

    **Underlying tools:** `CronCreate`, `CronList`, `CronDelete`. Each task has an 8-character ID. Max **50** tasks per session.

    ## Behavior

    - Scheduler checks every second; enqueues at low priority. Prompts run **between your turns**, not during a response.
    - **Timezone:** All times are local (e.g. `0 9 * * *` = 9am local).
    - **Jitter:** Recurring tasks fire up to 10% of period late (capped at 15 min). One-shot at :00/:30 can fire up to 90s early. Use a non-round minute (e.g. `3 9 * * *`) if exact timing matters.
    - **Expiry:** Recurring tasks expire **3 days** after creation (one final run, then delete). Recreate or use Desktop/GitHub for longer.

    ## Cron expression (CronCreate)

    5-field: `minute hour day-of-month month day-of-week`. Supports `*`, steps (`*/15`), ranges (`1-5`), lists (`1,15,30`). Day-of-week: 0/7 = Sunday … 6 = Saturday. No `L`, `W`, `?`, or name aliases.

    | Example | Meaning |
    |----------------|-----------------------|
    | `*/5 * * * *` | Every 5 minutes |
    | `0 * * * *` | Every hour on the hour|
    | `0 9 * * *` | Every day at 9am |
    | `0 9 * * 1-5` | Weekdays at 9am |

    ## Disable

    `CLAUDE_CODE_DISABLE_CRON=1` disables the scheduler; cron tools and `/loop` become unavailable.

    ## Limitations

    - Tasks only run while Claude Code is running and idle. Exit = all tasks gone.
    - No catch-up: if Claude was busy, one fire when idle, not one per missed interval.
    - No persistence across restarts.

    For unattended cron-style automation, use GitHub Actions `schedule` or Desktop scheduled tasks.