cron-job-test-author
БесплатноБез исполняемых скриптовНе проверенUse when cron jobs, Kubernetes CronJobs, BullMQ repeat jobs, Sidekiq schedules or any time-based job need tests: cron expression validation, DST and leap-day…
от testland★ 18 звёзд на GitHubОб этом скилле
cron-job-test-author
Overview
Cron jobs are universally underspecified. Most teams ship cron expressions, never test them, and discover bugs when DST or a leap day rolls around. This skill is a build-an-X workflow for authoring cron-job tests - a checklist + per-pattern test recipes, not a single tool.
When to use
- Authoring or reviewing tests for any time-scheduled job:
- Unix cron (crontab)
- Kubernetes CronJobs (
apiVersion: batch/v1) - BullMQ
repeatjobs (Step 6 ofbullmq-tests) - Sidekiq schedulers (sidekiq-cron, sidekiq-scheduler gems)
- APScheduler (Python)
- Quartz (Java)
- Hangfire (.NET)
How to use
- List every time-scheduled job in scope (crontab, Kubernetes CronJob, BullMQ repeat, Sidekiq, APScheduler, Quartz, Hangfire).
- Validate each cron expression with
croniter(or a language-native validator), parametrizing known-good and known-bad expressions (Step 1). - For any job near a DST transition or a leap day, compute next-run times
with
croniteragainstzoneinfoand assert them (Step 2). - Decide and test the missed-execution policy for downtime - Unix drop, k8s
startingDeadlineSeconds, BullMQ drop (Step 3). - Add overlap and stale-lock protection with a lock, and test both (Steps 4 - 5, references/lock-patterns.md).
- Assert timezone semantics explicitly via
croniter(..., tz=...)or k8s.spec.timeZone(Step 6). - Run the end-to-end recipe checklist per job and wire it into CI (Step 7).
Step 1 - Validate the cron expression
The 5-field standard:
┌─── minute (0-59)
│ ┌─── hour (0-23)
│ │ ┌─── day of month (1-31)
│ │ │ ┌─── month (1-12 or JAN-DEC)
│ │ │ │ ┌─── day of week (0-6 or SUN-SAT; 0 and 7 both = Sunday)
│ │ │ │ │
* * * * *
Six-field variants (Quartz, BullMQ pattern mode) prepend a seconds field.
Default: croniter (Python) - it both validates expressions and computes next-run times, which Steps 2 + 6 below depend on. Use a language-native validator when the test suite isn't Python: cron-validator (Node), CronExpression.isValidExpression() (Java/Quartz), or crontab.guru for ad-hoc human checks.
Test pattern:
from croniter import croniter
import pytest
@pytest.mark.parametrize("expr", [
"0 3 * * *", # daily 03:00
"0 0 1 * *", # monthly on the 1st
"*/15 * * * *", # every 15 min
"0 9 * * 1-5", # weekdays at 09:00
])
def test_cron_expression_is_valid(expr):
assert croniter.is_valid(expr)
Step 2 - DST + leap-day edge cases
The two highest-risk dates per year:
- Spring-forward DST: a window (typically 02:00 - 02:59 local) doesn't exist; jobs scheduled in this window may run zero or two times depending on cron implementation.
- Fall-back DST: a window (typically 01:00 - 01:59 local) occurs twice; jobs may run twice.
- Feb 29: jobs that schedule "monthly on the 29th" skip 11 months of the year.
Test pattern:
from croniter import croniter
from datetime import datetime
from zoneinfo import ZoneInfo
def test_daily_2am_handles_dst_spring_forward():
# 2026 spring-forward in US/Eastern: Mar 8, 2:00 AM EST → 3:00 AM EDT
base = datetime(2026, 3, 8, 1, 0, tzinfo=ZoneInfo("US/Eastern"))
next_run = croniter("0 2 * * *", base).get_next(datetime)
# croniter's behavior: skip the missing 02:00 hour, return 03:00 EDT
assert next_run.hour == 3
assert next_run.utcoffset().total_seconds() == -4 * 3600 # EDT
Recommendation: schedule cron jobs in UTC where possible to avoid DST entirely. If local time is required, document the DST-handling decision in the cron-job code.
Step 3 - Missed-execution detection
When the host / cluster is down at the scheduled time, what happens?
- Unix cron: misses are silently dropped. (Use
anacronfor catch-up.) - Kubernetes CronJobs:
.spec.startingDeadlineSecondscontrols how late a missed run may start (per Kubernetes CronJob spec). - BullMQ repeat: missed runs are silently dropped; the next scheduled iteration runs.
Test pattern (Kubernetes CronJob):
# CronJob with deadline
spec:
schedule: "0 3 * * *"
startingDeadlineSeconds: 300 # if not started within 5 min, skip
concurrencyPolicy: Forbid # don't overlap with previous run
# Test: simulate cluster downtime (drain nodes), then re-enable past 03:00 + 5min
# → CronJob controller should NOT trigger the missed run (past deadline)
# → CronJob controller SHOULD trigger if re-enabled past 03:00 but within deadline
For OSS test patterns, use kind (Kubernetes IN Docker) clusters in
CI to verify CronJob behavior.
Step 4 - Overlapping-run protection
If a long-running job overlaps its next scheduled run, both may execute in
parallel (Unix cron), a concurrency policy may block / replace the new run
(Kubernetes .spec.concurrencyPolicy), or workers may process repeat-jobs in
parallel (BullMQ). Guar
Установить cron-job-test-author в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл cron-job-test-author?
Use when cron jobs, Kubernetes CronJobs, BullMQ repeat jobs, Sidekiq schedules or any time-based job need tests: cron expression validation, DST and leap-day edge cases, catch-up after downtime, overlapping-run locks with stale-lock recovery, and time zones.
Как установить скилл cron-job-test-author?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cron-job-test-author запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic