.agents/skills/cron-scheduling/SKILL.md
Cron and scheduled task management. node-cron, cron expressions, Spring @Scheduled, APScheduler (Python), and distributed scheduling patterns. USE WHEN: user mentions "cron", "scheduled task", "cron job", "node-cron", "@Scheduled", "APScheduler", "periodic task", "crontab" DO NOT USE FOR: job queues with workers - use `job-queues`; one-off delayed tasks - use `job-queues`
npx skillsauth add d-subrahmanyam/deno-fresh-microservices cron-schedulingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
┌─────── minute (0-59)
│ ┌────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌──── month (1-12)
│ │ │ │ ┌─── day of week (0-7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *
| Expression | Schedule |
|------------|----------|
| 0 * * * * | Every hour |
| */15 * * * * | Every 15 minutes |
| 0 9 * * 1-5 | Weekdays at 9:00 AM |
| 0 0 1 * * | First day of month, midnight |
| 0 */6 * * * | Every 6 hours |
import cron from 'node-cron';
// Run every day at 2:00 AM
cron.schedule('0 2 * * *', async () => {
console.log('Running daily cleanup...');
await cleanupExpiredSessions();
}, {
timezone: 'America/New_York',
});
// Run every 5 minutes
cron.schedule('*/5 * * * *', async () => {
await syncExternalData();
});
import { Redlock } from 'redlock';
const redlock = new Redlock([redis]);
cron.schedule('0 * * * *', async () => {
let lock;
try {
lock = await redlock.acquire(['cron:hourly-report'], 60000);
await generateHourlyReport();
} catch (err) {
if (err instanceof Redlock.LockError) return; // Another instance has the lock
throw err;
} finally {
await lock?.release();
}
});
@Component
@EnableScheduling
public class ScheduledTasks {
@Scheduled(cron = "0 0 2 * * *") // Daily at 2 AM
public void dailyCleanup() {
sessionRepo.deleteExpired();
}
@Scheduled(fixedRate = 300000) // Every 5 minutes
public void syncData() {
externalService.sync();
}
@Scheduled(fixedDelay = 60000) // 60s after last completion
public void processQueue() {
queueService.processNext();
}
}
@Scheduled(cron = "0 */10 * * * *")
@SchedulerLock(name = "syncInventory", lockAtLeastFor = "5m", lockAtMostFor = "10m")
public void syncInventory() {
inventoryService.syncAll();
}
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger
scheduler = AsyncIOScheduler()
@scheduler.scheduled_job(CronTrigger(hour=2, minute=0))
async def daily_cleanup():
await cleanup_expired_sessions()
@scheduler.scheduled_job('interval', minutes=5)
async def sync_data():
await sync_external_data()
scheduler.start()
| Anti-Pattern | Fix | |--------------|-----| | Cron on multiple instances without locking | Use distributed lock (Redlock, ShedLock) | | Long-running cron blocks next run | Use job queue for heavy work | | No error handling in cron | Wrap in try-catch, log errors, alert | | Hardcoded schedule | Use environment variable or config | | No monitoring of cron execution | Log start/end times, track failures |
development
Guidelines for building high-performance APIs with Fastify and TypeScript, covering validation, Prisma integration, and testing best practices
development
FastAPI modern Python web framework. Covers routing, Pydantic models, dependency injection, and async support. Use when building Python APIs. USE WHEN: user mentions "fastapi", "pydantic", "async python api", "python rest api", asks about "dependency injection python", "python openapi", "python swagger", "async endpoints", "python api validation", "fastapi middleware" DO NOT USE FOR: Django apps - use `django` instead, Flask apps - use `flask` instead, synchronous Python APIs without type hints, GraphQL-only APIs
tools
FastAPI integration testing specialist. Covers synchronous TestClient, async httpx AsyncClient, dependency injection overrides, auth testing (JWT, OAuth2, API keys), WebSocket testing, file uploads, background tasks, middleware testing, and HTTP mocking with respx, responses, and pytest-httpserver. USE WHEN: user mentions "FastAPI test", "TestClient", "httpx async test", "dependency override test", "respx mock", asks about testing FastAPI endpoints, authentication in tests, or HTTP client mocking. DO NOT USE FOR: Django - use `pytest-django`; pytest internals - use `pytest`; Container infrastructure - use `testcontainers-python`
development
Expert in FastAPI Python development with best practices for APIs and async operations