> nestjs-scheduling
Implement distributed cron jobs with Redis-based locking and BullMQ offloading in NestJS. Use when adding @Cron scheduled tasks, preventing duplicate runs across pods, or delegating heavy work to queue workers. (triggers: **/*.service.ts, @Cron, CronExpression, ScheduleModule)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/nestjs-scheduling?format=md"Task Scheduling & Jobs
Priority: P1 (OPERATIONAL)
Background job processing and scheduled task patterns.
Workflow: Add a Scheduled Task
- Register ScheduleModule — Import
ScheduleModule.forRoot()in AppModule. - Create cron handler — Decorate a service method with
@Cron(CronExpression.*). - Add distributed lock — Apply a Redis lock decorator to prevent multi-pod duplication.
- Offload heavy work — Push job IDs to BullMQ; let workers process them.
- Wrap in try/catch — Uncaught exceptions in cron handlers crash the entire Node process.
- Verify — Test with 2+ instances to confirm only one acquires the lock.
Problem & Solution
- Problem:
@Cron()runs on every instance. In K8s with 3 pods, your "Daily Report" runs 3 times. - Solution: Distributed Locking using Redis.
- Pattern: Using a decorator to wrap the cron method.
- Logic:
SET resource_name my_random_value NX PX 30000(Redis Atomic Set).
Cron Decorator Pattern
-
Implementation:
-
Tools: Use
nestjs-redlockor custom Redis wrapper viaredlocklibrary.
Cron-to-Queue Offload
Job Robustness
- Isolation: Never perform heavy processing inside the Cron handler.
- Pattern: Cron -> Push Job ID to Queue (BullMQ) -> Worker processes it.
- Why: Cron schedulers can get blocked by the Event Loop; Workers are scalable.
- Error Handling: Wrap ALL cron logic in
try/catch. Uncaught exceptions in a Cron job can crash the entire Node process.
Anti-Patterns
- No unguarded cron logic: Always wrap in
try/catch; uncaught exceptions crash the entire Node process. - No direct cron processing: Push to BullMQ queue; workers are scalable, cron handlers are not.
- No bare @Cron in multi-pod: Use distributed locking (redlock) to prevent duplicate concurrent runs.
> related_skills --same-repo
> common-store-changelog
Generate user-facing release notes for the Apple App Store and Google Play Store by collecting git history, triaging user-impacting changes, and drafting store-compliant changelogs. Enforces character limits (App Store ≤4000, Google Play ≤500), tone, and bullet format. Use when generating release notes, app store changelog, play store release, what's new, or version release notes for any mobile app. (triggers: generate changelog, app store notes, play store release, what's new, release notes, ve
> golang-tooling
Go developer toolchain — gopls LSP diagnostics, linting, formatting, and vet. Use when setting up Go tooling, running linters, or integrating gopls with Claude Code. (triggers: gopls, golangci-lint, golangci.yml, go vet, goimports, staticcheck, go tooling, go lint)
> common-ui-design
Design distinctive, production-grade frontend UI with bold aesthetic choices. Use when building web components, pages, interfaces, dashboards, or applications in any framework (React, Next.js, Angular, Vue, HTML/CSS). (triggers: build a page, create a component, design a dashboard, landing page, UI for, build a layout, make it look good, improve the design, build UI, create interface, design screen)
> common-owasp
OWASP Top 10 audit checklist for Web Applications (2021) and APIs (2023). Load during any security review, PR review, or codebase audit touching web, mobile backend, or API code. (triggers: security review, OWASP, broken access control, IDOR, BOLA, injection, broken auth, API review, authorization, access control)