scheduled-jobs
Skill0 starsChanged 16 days agoMITView on GitHub
Scheduled and background work for Node.js backends without a queue library — one plain script per job in src/jobs, run by cron (supercronic in a scheduler container), idempotent, batched, reusing module services, with clean connect/disconnect and exit codes. Use when adding cron jobs, nightly cleanups, reminders, digests, expiry sweeps, recurring records or backfills.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Happy-Technologies-LLC/happy-platform-skillstheir own version, first seen Nov 1, 2026
- KMaruthi2002/universal-llm-skillstheir own version, first seen Oct 25, 2026
- orangehrm/orangehrmtheir own version, first seen Oct 8, 2026
- w2ur/claude-code-setuptheir own version, first seen Sep 4, 2026
- aborroy/aiup-alfrescotheir own version, first seen Jun 22, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- orangehrm/orangehrm★ 1.2ksame name
- Happy-Technologies-LLC/happy-platform-skills★ 41same name
- aborroy/aiup-alfresco★ 14same name
- KMaruthi2002/universal-llm-skills★ 1same name
- w2ur/claude-code-setup★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- ai-integrationSkill
- api-docsSkill
- auth-sessionsSkill
- backend-conventionsSkill
- backend-reviewSkill
- create-backendSkill
- deploy-dockerSkill
- mongoose-mongodbSkill
- new-moduleSkill
- nextjs-api-routesSkill
- prisma-postgresSkill
- redis-cacheSkill
- security-hardeningSkill
- session-logSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Default to plain scripts. Add a queue library only when the user asks for one or the work is triggered per request and must survive …
- Very specific: line 79
Run the same image as the API in a scheduler container with supercronic (cron for containers, logs to stdout):
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Scheduled Jobs
Default to plain scripts. Add a queue library only when the user asks for one or the work is triggered per request and must survive restarts.
Layout
src/jobs/<verb>-<noun>.js expire-trials.js, send-weekly-reports.js
cron/prod.crontab
cron/staging.crontab
package.json scripts: "job:expire-trials": "node src/jobs/expire-trials.js"Script shape
import 'dotenv/config';
import { connectDatabases, disconnectDatabases, getWriteDB } from '../config/databases.js';
import { disconnectRedis } from '../config/redis.js';
import { logger } from '../shared/index.js';
import { expireTrialService } from '../modules/billing/services/billing.service.js';
const BATCH_SIZE = 200;
const run = async () => {
await connectDatabases();
const db = getWriteDB();
const now = new Date();
let processed = 0;
let cursor;
for (;;) {
const batch = await db.subscription.findMany({
where: { status: 'TRIAL', trialEndsAt: { lt: now }, isActive: true },
select: { id: true, orgId: true },
orderBy: { id: 'asc' },
take: BATCH_SIZE,
...(cursor ? { skip: 1, cursor: { id: cursor } } : {}),
});
if (batch.length === 0) {
break;
}
await Promise.all(batch.map((subscription) => expireTrialService(db, subscription)));
processed += batch.length;
cursor = batch.at(-1).id;
}
logger.info('Expired trials processed', { count: processed });
};
run()
.catch((error) => {
logger.error('expire-trials failed', { error: error.message, stack: error.stack });
process.exitCode = 1;
})
.finally(async () => {
await disconnectRedis();
await disconnectDatabases();
});Rules
- Idempotent. Running twice, or overlapping with the previous run, must not double-send or double-apply. Select only rows still in the "to do" state and transition them with a conditional update (
updateMany({ where: { id, status: 'TRIAL' } })), or record asentAt/lastRunKey. - Batched. Cursor-paginate large sets; never load the whole table. Concurrency inside a batch is bounded (
Promise.allover one batch, not over everything). - Reuse services. Business logic lives in module services so the API and the job behave identically. The job script only selects work and calls services.
- Same rules as requests: explicit
select,isActivefilters, no N+1, cache invalidation on writes. - Exit codes: set
process.exitCode = 1on failure so the scheduler and alerts see it; always disconnect infinally. - Time: compare in UTC; per-user local times (a report at 9am local) store the user's timezone and select by computed UTC window.
- Locking (multiple scheduler replicas): take a Redis lock
SET job:<name> <id> NX EX <seconds>at start and skip if held; or run exactly one scheduler container.
Scheduling
Run the same image as the API in a scheduler container with supercronic (cron for containers, logs to stdout):
*/15 * * * * node src/jobs/expire-trials.js
0 2 * * * node src/jobs/purge-expired-sessions.js
0 9 * * 1 node src/jobs/send-weekly-reports.jsOffset minutes (17 * * * *) so jobs do not all start at :00. Keep separate crontabs per environment.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

