background-jobs

background-jobs is a skill for Claude Code, Codex from cass-2003/local-workflow-skill. It costs 175 tokens per session (3,676 once invoked), scanned A, original, MIT.

A guide to running slow or scheduled work outside a web request, using queues and worker processes. It covers tools and patterns for several programming languages.

In plain words
What is it for?
Use it when sending emails, generating PDFs, processing videos, calling external APIs, running scheduled jobs, or designing retries and dead-letter queues.
Why use it?
It helps keep requests responsive, handle bursts of work, retry failures, schedule tasks, and coordinate multi-step workflows.

Skill for Claude CodeCodex

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

Good fit Use it when sending emails, generating PDFs, processing videos, calling external APIs, running scheduled jobs, or designing retries and dead-letter queues.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cass-2003/local-workflow-skill/background-jobs
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 cass-2003/local-workflow-skill --skill background-jobs
Clone the repo
git clone --depth 1 https://github.com/cass-2003/local-workflow-skill

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 background-jobs

README.md
[![agentmods](https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/background-jobs/github.svg)](https://agentmods.dev/skills/cass-2003/local-workflow-skill/background-jobs)
Your own site
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/background-jobs"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/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 background-jobs

Your own site · 80×15
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/background-jobs"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/background-jobs.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 175 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,676 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.
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.00175 $0.03676
Opus 5 $0.00088 $0.01838
Sonnet 5 $0.00035 $0.00735
Haiku 4.5 $0.00017 $0.00368

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

Security

Grade A, and why

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 9d 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/backend-api/ours/background-jobs/SKILL.md · 413 lines

How it starts

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

Background Jobs Skill — 后台任务系统

何时使用

  • 把慢操作(发邮件 / 生成 PDF / 转码视频 / 调用第三方 API)从请求路径剥离
  • 定时任务(每天清理 / 每小时同步报表)
  • 工作流编排(订单 → 库存 → 支付 → 发货 多步事务)
  • 重试 / 失败处理 / 死信队列
  • 选择 Sidekiq vs Bull vs Celery vs Temporal

一、基本架构

[ HTTP 请求 ]
       │  enqueue (毫秒级返回)
       ▼
[ Queue ]  ← Redis / RabbitMQ / SQS / Kafka / Postgres
       │
       ▼
[ Worker(s) ]  ← 多实例并行消费
       │
       ▼
[ DB / Email / 3rd-party API ]

核心收益

  • 解耦:请求快返回(用户体验)
  • 削峰:突发流量入队,worker 按能力消费
  • 重试:失败自动重新尝试
  • 调度:未来某时执行

二、何时不要用 background job

  • ❌ 简单同步够快(< 100ms)
  • ❌ 用户期望立即看到结果(用 SSE / WS 反馈进度)
  • ❌ 无幂等设计(队列默认 at-least-once,会重复)
  • ❌ 只跑一次的小脚本(用 cron 直接跑)

三、跨语言库选型

语言 后端 卖点
Ruby Sidekiq Redis 业界标杆 / 简单 / 高性能
Ruby GoodJob / SolidQueue Postgres Rails 8 默认(无 Redis 依赖)
Python Celery Redis / RabbitMQ 老牌 / 配置复杂
Python RQ Redis 简单替代 Celery
Python Dramatiq / arq Redis 现代 / async
Node BullMQ Redis 业界标准 / TS 友好
Node Agenda MongoDB 时间调度强
Go asynq Redis Sidekiq 风格
Go River Postgres 无 Redis / 事务级一致
Java Quartz DB / 内存 老牌 / 调度强
多语言 Temporal / Cadence 自家集群 工作流 / Saga / 长事务
AWS SQS + Lambda / 全托管 / 无 worker 维护
GCP Cloud Tasks / Pub/Sub / 全托管

默认推荐

  • 简单任务:Sidekiq / BullMQ / asynq
  • 复杂工作流(多步骤 / 长时间 / 补偿):Temporal
  • 不想运维 Redis:River(Go)/ SolidQueue(Rails)

四、BullMQ 标准模式(Node.js)

import { Queue, Worker, QueueEvents } from 'bullmq'

const connection = { host: 'localhost', port: 6379 }

// 入队
const emailQueue = new Queue('email', { connection })
await emailQueue.add('welcome', {
  userId: '123',
  template: 'signup',
}, {
  jobId: `welcome-${userId}`,         // 幂等 key(重复 add 同 ID 不入队)
  attempts: 3,
  backoff: { type: 'exponential', delay: 1000 },
  removeOnComplete: { age: 3600, count: 1000 },
  removeOnFail: { age: 24 * 3600 },
})

// 延迟任务
await emailQueue.add('reminder', data, { delay: 60_000 })

// 定时任务(cron)
await emailQueue.add('daily-report', {}, {
  repeat: { pattern: '0 9 * * *', tz: 'Asia/Tokyo' },
})

// 优先级
await emailQueue.add('urgent', data, { priority: 1 })  // 越小越优先

// Worker
const worker = new Worker('email', async (job) => {
  switch (job.name) {
    case 'welcome': return sendWelcomeEmail(job.data)
    case 'reminder': return sendReminderEmail(job.data)
    case 'daily-report': return generateDailyReport()
  }
}, {
  connection,
  concurrency: 10,                    // 单 worker 并发数
  limiter: { max: 100, duration: 60_000 },  // 每分钟 100 个任务
})

worker.on('failed', (job, err) => {
  logger.error({ jobId: job?.id, err }, 'job failed')
})

// 优雅停机
process.on('SIGTERM', async () => {
  await worker.close()                // 等当前 job 处理完
  await emailQueue.close()
  process.exit(0)
})

Read the full file on GitHub · 413 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. 9d ago First seen · 413 lines · 175 tokens per session scan A 0d54354771de

Subscribe to this mod's changes

background-jobs is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 2mo ago), licensed MIT. It adds 175 tokens to every session and 3,676 once invoked, about $0.0009 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.

Related

Other skills, from other repositories

mem0-oss-to-platform

Plan and then execute a migration of a project from the mem0 open-source / self-hosted SDK (the local Memory class) to the mem0 Platform / hosted / managed SDK (the MemoryClient class). Use this whenever a developer wants to move, switch, or migrate their mem0 usage off OSS/self-hosted to the hosted API — e.g.…

mem0ai/mem0 · 273 tokens

agui-dotnet-protobuf

Use the protobuf wire transport (instead of the default Server-Sent Events) for an AG-UI connection with the AG-UI .NET SDK — a compact binary event stream negotiated via the Accept header. USE FOR: making an AGUIChatClient prefer protobuf by wiring an AGUIEventStreamHandler with ProtobufEventStreamFormatter (then…

ag-ui-protocol/ag-ui · 162 tokens

azure-mgmt-botservice-dotnet

Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings. Triggers: "Bot Service", "BotResource", "Azure Bot", "DirectLine channel", "Teams channel", "bot management .NET", "create bot".

microsoft/skills · 78 tokens

fastapi-router-py

Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.

microsoft/skills · 46 tokens

migrate-segw-to-rap

Reverse-engineer a SEGW-built OData V2 service (MPC/DPC/MPCEXT/DPCEXT) into a modern RAP V4 service — tables, CDS views (interface + projection), behavior definitions, draft entities, service definition + binding. Use when asked to "migrate this SEGW service to RAP", "convert OData V2 to V4 RAP", "modernize this…

arc-mcp/arc-1 · 106 tokens

telnyx-messaging-hosted-curl

Set up hosted SMS numbers, toll-free verification, and RCS messaging. Use when migrating numbers or enabling rich messaging features. This skill provides REST API (curl) examples.

team-telnyx/ai · 45 tokens