← LeaderboardThe Skill Leaderboard

finite-batch-job

Turn a long list of identical items into a scheduled job that processes a quota per run, logs each run and switches itself off when the queue is empty.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: finite-batch-jobdescription: "Turn a long list of identical items into a scheduled job that processes a quota per run, logs each run and switches itself off when the queue is empty."category: productivityrisk: criticalsource: selfsource_type: selfdate_added: "2026-12-03"author: tonydzilicense: MITlicense_source: https://github.com/tonydzi/agent-plugins/blob/8f7fe524a56f32029987c43485208a4c67384c9a/LICENSE.mdtags: [batch, queue, scheduled-job, rate-limits, automation]

Finite Batch Job

Overview

A long list of identical items done in one heroic session usually dies halfway: the session runs out of context, the service enforces a documented quota, or the person has to babysit it for weeks. Small runs can finish the same work within the allowed quota. This skill first judges whether the work is really a batch, then builds a scheduled job that has an end: a stable-key queue, a fixed quota per run, a per-item retry cap, and a run log that detects both the finish and a stall.

The distinction from nearby skills: goal-loop and loop-library design prompt loops inside one agent session, resumable-implementation-contracts resumes multi-session coding work, and orchestrate-batch-refactor splits one large refactor into packets. None of them builds an unattended, rate-limited drip over hundreds of interchangeable items that disables its own scheduler entry when the queue is empty.

When to Use

  • The user has a long list of interchangeable items: videos, chats, files, pages, records.
  • The work keeps tripping over a live obstacle: published rate limits, a vendor quota, a night-only window, or the user's own time.
  • The user says things like "do all of them", "retroactively for everything", "about ten a day".
  • You notice yourself repeating the same mechanical step again and again in one session.
  • Do not use it for one hard thing (architecture, a long article, a negotiation); use a normal session or orchestrate-batch-refactor for a large refactor. Size alone decides nothing.

Prerequisites

  • A scheduler the user already controls (cron, launchd, systemd timers, Windows Task Scheduler, or an agent host's scheduled tasks).
  • A local writable folder outside any file-sync tool for the queue and run log (one SQLite file is enough).
  • The per-item work must already be runnable by hand. If each item sends data outward, spends money or deletes data, the user's explicit approval for that action is required before scheduling; this skill does not grant it.

How It Works

1. Establish the inputs: is this a batch job at all

Signs for (need at least 2, the first is required):

  1. A long list of same-shaped pieces. Piece 700 is processed exactly like piece 3.
  2. Each piece is mechanical: code or a narrow call does it, not judgment or conversation.
  3. The finite backlog has an explicit cutoff. A source that keeps growing needs a separate continuous intake job.
  4. The work stumbles over a live obstacle: a person's attention, documented vendor limits, night windows. This is the strongest sign, stronger than size.

Stop signs (any one means no batch job):

  • There is a deadline. A batch job is slow on purpose.
  • Pieces depend on each other. If piece 50 needs piece 49 in your head, it is deep work.
  • Each piece needs taste, judgment or talking to a person.
  • The list is shorter than about 20. One session finishes it.

Write the verdict in one explicit line: batch job (with the matched signs), endless job (no natural end, such as syncing new inbox items: a schedule without a quota and without self-shutdown), or not a batch job (naming the stop sign and the right alternative). An honest "no" is a success of this skill.

Then name the consumer in writing before the first command: who consumes the result, how you will know it is consumed (a metric), and where the final report goes. No answer means do not build it.

2. Perform the task

Build the queue once, one row per piece, with a stable key (video_id, chat_id, file path). A row number or anything recomputed on rebuild makes the job chew the same pieces forever.

CREATE TABLE items (key TEXT PRIMARY KEY, payload TEXT,
                    state TEXT DEFAULT 'todo',   -- todo | claimed | ok | fail | skip
                    attempts INTEGER DEFAULT 0,
                    claim_token TEXT, lease_until INTEGER, retry_after INTEGER);
CREATE TABLE runs  (ts TEXT, ok INTEGER, fail INTEGER, todo_left INTEGER);

Run several full cycles by hand all the way to the consumer and show the result to the user. Until the user approves, the scheduled entry stays disabled.

Pick a quota per run and compute out loud: pieces / (quota x runs per night) = days. If that is more than a couple of months, report the finish date under the allowed quota. Honor Retry-After within the approved schedule and pause on revoked access. Record the scheduler task name with the job so the job can disable that exact entry when it finishes.

Every run does exactly four moves:

take N unclaimed pieces -> do the work -> mark each piece ok | fail | skip -> record the run
  • Claim rows and assign a unique claim token and lease in one transaction. Count an attempt at claim time. Update an item only when its claim token still matches. Renew the lease during long work or let recovery reclaim it after expiry.
  • Retry transient failures below the cap after the recorded retry time. Mark a permanent failure or exhausted attempt as terminal. Keep an ambiguous external operation in review until you can reconcile it.
  • Pass a stable operation ID to services that support idempotency. If a crash can occur after an irreversible effect and before the queue update, reconcile the external outcome before retrying. Require a supported idempotency or reconciliation path before automating that effect.
  • Mark completion only when every item within the recorded cutoff is terminal, including rows previously claimed or delayed for retry. Record terminal failures and skips in the final report. Disable only this job's scheduler entry after recording completion. Track five successive runs with eligible work and zero progress as a stall, and pause when operator intervention is required.
  • The run script exits non-zero on anything unexpected and every wrapper propagates that code.

If the list keeps growing, one run can do two halves: harvest new items (endless half), then process a quota of the backlog (finite half). Tell the user that only the finite half switches itself off.

3. Verify the result

  • The verdict line exists and names the signs or the stop sign.
  • The consumer, the consumption metric and the final-report destination are written down.
  • A test asks "take N" twice and gets 2N distinct, previously unclaimed keys; it fails on a build that hands out the same piece twice.
  • Simulate a worker stopping after claim. Verify the backlog remains incomplete, a stale claim cannot finalize the item, and recovery observes the retry cap. Check idempotent retries after an ambiguous acknowledgement.
  • One full cycle was run by hand and the runs table shows it.
  • Progress is judged from the runs table and the consumer, not from the scheduler's exit code.
  • The finish date was computed and told to the user, and any older job doing the same work is disabled.

If any check could not be run, report it as unverified rather than done.

Examples

Illustrative, not a measured test:

User request: Transcribe all 2,241 videos in my watch-later export, the API documentation permits 30 calls an hour.
Inputs: the export file, a working one-video transcription command, a scheduler.
Expected result: verdict "batch job (signs 1, 2, 4)"; a SQLite queue keyed by video_id;
one hand-run cycle shown to the user; a nightly entry with four hourly runs of 25, forecasting about 23 days;
the entry disables itself when every item is terminal and sends a final report.

Limitations

  • It does not make irreversible pieces safe. Sending, paying or deleting per item still needs explicit user approval for that action.
  • It is wrong for deadline work, interdependent pieces or judgment-heavy pieces; the verdict step should say so.
  • A green scheduler exit code is not evidence of progress. Do not infer completion from it; read the runs table and the consumer.
  • Keeping the queue or run log in a synced folder breaks it: sync overwrites the file and the job reprocesses the same first pieces while its logs report success.

Safety and side effects

The skill creates a local SQLite file and one scheduler entry on the user's machine, and later disables that entry. It sends no data anywhere by itself; whatever the per-item work sends is the user's existing command and must already be authorized. Keep credentials out of the queue payload and the run log. Ask before enabling the schedule, and never batch an outward, paid or destructive action without the user's explicit approval for it.

Sources and related skills