loom-background-jobs

loom-background-jobs is a skill for Claude Code, Codex from cosmix/loom. It costs 26 tokens per session (5,504 once invoked), scanned A, original, MIT.

Guidance for running work outside a web request, such as queued tasks, scheduled jobs, and worker processes. It covers retries, crashes, duplicate delivery, and delaying work until a worker can process it.

In plain words
What is it for?
Use it for email or data-processing queues, scheduled tasks, imports, machine-learning jobs, worker pools, and failed-job handling. It is not guidance for event-streaming or event-sourced systems.
Why use it?
It helps avoid lost jobs, repeated side effects, and requests that fail because they take too long. The central rule is to make job handlers safe to retry and confirm success only after the work is stored safely.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for email or data-processing queues, scheduled tasks, imports, machine-learning jobs, worker pools, and failed-job handling. It is not guidance for event-streaming or event-sourced systems.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cosmix/loom/loom-background-jobs
View source ↗ cosmix/loom
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cosmix/loom --skill loom-background-jobs
Clone the repo
git clone --depth 1 https://github.com/cosmix/loom

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for loom-background-jobs

README.md
[![agentmods](https://agentmods.dev/badge/skills/cosmix/loom/loom-background-jobs/github.svg)](https://agentmods.dev/skills/cosmix/loom/loom-background-jobs)
Your own site
<a href="https://agentmods.dev/skills/cosmix/loom/loom-background-jobs"><img src="https://agentmods.dev/badge/skills/cosmix/loom/loom-background-jobs/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for loom-background-jobs

Your own site · 80×15
<a href="https://agentmods.dev/skills/cosmix/loom/loom-background-jobs"><img src="https://agentmods.dev/badge/skills/cosmix/loom/loom-background-jobs.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,504 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00026 $0.05504
Opus 5 $0.00013 $0.02752
Sonnet 5 $0.00005 $0.01101
Haiku 4.5 $0.00003 $0.00550

Measured 7d ago against content hash c2bbf9bf84a9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

loom-background-jobs scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/loom-background-jobs/SKILL.md · 348 lines

How it starts

The opening of the file, as written. The whole thing — 348 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Background Jobs

Overview

Reliable async task execution: enqueue work, process it in workers decoupled from the request cycle, and survive crashes/retries without corrupting state. This file covers job queues, retries/backoff, DLQs, scheduling, worker pools, and delivery guarantees.

For pub/sub, event sourcing, CQRS, sagas, and streaming brokers (Kafka/Pulsar), see loom-event-driven — don't reimplement those here.

The two invariants everything hangs off

  1. At-least-once is the default. Design every handler to be idempotent. Redis-backed queues (Sidekiq, BullMQ, Celery+Redis), SQS standard, and a queue retrying after a crash can deliver work more than once. FIFO producer deduplication does not make a consumer's external side effect exactly once. The achievable goal is exactly-once effect = durable idempotency at the sink plus retry-safe handling.
  2. Ack after success, never before. The job must stay owned by the worker until the side effect is durably committed. Ack-then-process = at-most-once = silent data loss on crash. Process-then-ack = at-least-once = duplicates you dedup away. Always choose the latter.

Idempotency: the non-negotiable pattern

Derive a stable key from the job's business identity (not a random UUID per enqueue), and make the durable sink reject duplicates. A separate “done” flag cannot atomically cover an external side effect and a crash.

def handle(job):
    key = job["idempotency_key"]          # e.g. f"receipt:{order_id}"
    # One transaction: UNIQUE(key) makes duplicate deliveries a successful no-op.
    with db.transaction():
        inserted = db.execute(
            "INSERT INTO receipts (idempotency_key, order_id) VALUES (?, ?) "
            "ON CONFLICT (idempotency_key) DO NOTHING",
            [key, job["order_id"]],
        ).rowcount == 1
        if inserted:
            db.execute(
                "INSERT INTO outbox (idempotency_key, kind, aggregate_id) "
                "VALUES (?, 'send-receipt', ?)",
                [key, job["order_id"]],
            )
    # The outbox makes the intent durable; the email sender must deduplicate by key too.

Read the full file on GitHub · 348 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago Changed · -22 tokens per session c2bbf9bf84a9
  2. 11d ago First seen · 348 lines · 48 tokens per session scan A 6b24640e13fd

Subscribe to this mod's changes

loom-background-jobs is a skill published in the GitHub repository cosmix/loom (54 stars, last pushed today), licensed MIT. It adds 26 tokens to every session and 5,504 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.