Cron decision

From oimiragieo/agent-studio · View interactive version

Cron decision is an AI agent skill from the GitHub repository oimiragieo/agent-studio. Decision framework for agents to determine WHEN and WHETHER to use Claude Code's native cron scheduler (CronCreate/CronList/CronDelete) vs OS cron, GitHub Actions, or simple Task() delegation.

How to use this skill

Skill file

<!-- Agent: developer | Task: #task-23 | Session: 2026-03-15 -->

Cron Decision Skill

Official docs: <https://code.claude.com/docs/en/scheduled-tasks>

Purpose

Help agents decide when and whether to use Claude Code's native cron scheduler (CronCreate/CronList/CronDelete) versus alternatives like OS cron (crontab), GitHub Actions scheduled workflows, or simple one-shot Task() delegation.

Using the wrong scheduling mechanism leads to:


Quick Checklist (Run Before Any Scheduling Decision)

Answer these 5 questions in order. The FIRST "yes" that hits a stop condition determines your tool.

  1. Is the task a one-time operation?
  1. Must the task survive terminal/session close?
  1. Does the task require sub-15-minute precision or hard time guarantees?
  1. Is this a heartbeat loop or session-scoped health check?
  1. Is this triggered by an event rather than a clock?

Decision Matrix

| Scenario | Recommended Tool | Reason |

| ------------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------- |

| Periodic background monitoring during active session | CronCreate | Session-scoped is fine; this is CronCreate's primary use case |

| Agent ecosystem heartbeat (health checks, memory sizes) | CronCreate via heartbeat-orchestrator | Use dedicated orchestrator, not raw CronCreate |

| One-time task (now or delayed) | Task() or TaskCreate | Cron is for recurring work only |

| Nightly backup or data pipeline | OS cron (crontab -e) | Must survive terminal close |

| CI/CD pipeline trigger | GitHub Actions schedule: | Cloud-run, no terminal dependency |

| Data refresh every 4 hours during development | CronCreate | Session-scoped is acceptable for dev workflows |

| Production scheduled job | OS cron or GitHub Actions | Never rely on session-scoped for production |

| Event-driven reaction (file change, hook trigger) | Hook (PreToolUse/PostToolUse) | Time-based scheduler is wrong tool for events |

| User-requested one-off analysis | Task() | Single execution, no recurrence needed |

| Weekly report generation (must run unattended) | GitHub Actions | Unattended, cloud-run, persistent |

| Session index rebuild during development | CronCreate | Session-scoped is fine; fires while Claude is open |

| Reflection queue drain check | CronCreate via heartbeat-orchestrator | Part of heartbeat ecosystem |


Heartbeat Integration Note

If the recurring task is agent ecosystem monitoring (health checks, memory rotation, stuck task detection, reflection queue), do not use raw CronCreate directly.

Instead, delegate to heartbeat-orchestrator or invoke the /heartbeat-start command:

// CORRECT: Delegate heartbeat ecosystem to the dedicated orchestrator
// Router: spawn heartbeat-orchestrator agent
// OR user: /heartbeat-start

// WRONG: Manually wiring raw CronCreate for ecosystem health
CronCreate({
  schedule: '*/30 * * * *',
  task: 'Check agent health...',
});

The heartbeat-orchestrator manages:

Exception: Use raw CronCreate only for custom, non-ecosystem recurring tasks that are not part of the standard heartbeat loops.


CronCreate Constraints (Critical Before Using)

| Constraint | Detail |

| ---------------------- | -------------------------------------------------------------- |

| Session-scoped | Dies when terminal closes — no persistence across restarts |

| 3-day auto-expiry | Self-deletes silently after 3 days (reschedule before day 2.5) |

| Jitter | Fires up to 10% of period late (max 15 min) |

| No catch-up | Missed fires are NOT replayed |

| 50-task cap | Max 50 concurrent scheduled tasks per session |

| Fire-between-turns | Fires only when Claude is idle, not mid-response |

| No extended syntax | L, W, ?, MON-style names are NOT supported |


When to Use Each Tool

Use `CronCreate` when

Use OS cron (`crontab -e`) when

Use GitHub Actions `schedule:` when

Use `Task()` or `TaskCreate` when

Use a hook when


Quick Reference: CronCreate API

// Schedule a recurring task (standard 5-field cron expression)
CronCreate({ schedule: '*/30 * * * *', task: 'Heartbeat check prompt here' });

// List active cron tasks (verify what is registered)
CronList();

// Remove a scheduled task by ID
CronDelete({ id: 'abc12345' });

Common schedules:

| Expression | Meaning |

| -------------- | ------------------------------------- |

| */30 * * * * | Every 30 minutes |

| */5 * * * * | Every 5 minutes (minimum recommended) |

| 0 * * * * | Every hour on the hour |

| 0 2 * * * | Every day at 2am local time |

| 0 3 * * 0 | Every Sunday at 3am |


When to Invoke

Skill({ skill: 'cron-decision' });

Invoke before:

Do NOT invoke for:


Related Skills and Agents


Memory Protocol (MANDATORY)

Before starting:

Read .claude/context/memory/learnings.md for previous scheduling decisions.

After completing:

ASSUME INTERRUPTION: If it's not in memory, it didn't happen.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.