agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when designing asynchronous job processing. Covers queue selection, idempotency, retry and backoff policy, scheduling, poison messages, and observability for work that happens outside the request.
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill background-jobs --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/background-jobsContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when designing asynchronous job processing. Covers queue selection, idempotency, retry and backoff policy, scheduling, poison messages, and observability for work that happens outside the request.
name: background-jobs description: Use when designing asynchronous job processing. Covers queue selection, idempotency, retry and backoff policy, scheduling, poison messages, and observability for work that happens outside the request. metadata: category: backend version: 1.0.0 tags: [jobs, queues, workers, retries, scheduling]
Move work out of the request path without losing it. A job system is a distributed system with a friendly interface; the failure modes are the same, and they are hidden until they are not.
1. **Make it idempotent first** — Before anything else. A job will run twice; design so that this is harmless. Key the side effect, not the invocation. 2. **Pass identifiers, not objects** — Enqueue `{"order_id": "..."}`, not a serialized order. By the time the job runs, the object may be stale. 3. **Set the retry policy per job** — A transient network failure deserves exponential backoff and ten attempts. A validation failure deserves zero retries and a DLQ. 4. **Isolate the queues** — A flood of low-priority image resizes must not delay password-reset emails. Separate queues, separate workers. 5. **Deduplicate scheduled work** — With multiple instances, every instance's scheduler fires. Use a lock keyed on the job name and window. 6. **Alert on age, not just depth** — A queue with 10 messages that are 3 hours old is a worse signal than a queue with 10,000 that are 5 seconds old.
**Idempotent handler with a natural key:**
@job(queue="billing", max_attempts=5, backoff="exponential", timeout=30)
def send_invoice(invoice_id: str) -> None:
invoice = Invoice.get(invoice_id)
# The natural idempotency key: an invoice is sent at most once.
if invoice.sent_at is not None:
logger.info("invoice_already_sent", extra={"invoice_id": invoice_id})
return
message_id = mailer.send(
to=invoice.customer_email,
template="invoice",
context=invoice.render_context(),
idempotency_key=f"invoice:{invoice_id}", # the provider dedupes too
)
invoice.update(sent_at=utcnow(), provider_message_id=message_id)Two protections, deliberately: the local check handles the common case, and the provider's idempotency key handles the crash between `send` and `update`.
**Enqueue after commit, not inside the transaction:**
with db.transaction():
order = Order.create(...)
db.after_commit(lambda: send_invoice.enqueue(order.invoice_id))A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Repo: nimadorostkar/Claude-Skills-collection
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what does not, structure, and…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory, structuring notes for retrieval, and…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should not be trusted to remember,…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling, versioning, testing, and…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive disclosure, and the difference between a…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base model, and measuring whether the…