Python Background Jobs
Use when moving long-running work out of request handlers, designing Python task queues/workers, or handling asynchronous jobs and events.
Install
npx skills add sandbaseai/workbuddy-skill --skill python-background-jobsgit clone --depth 1 https://github.com/sandbaseai/workbuddy-skill.git /tmp/workbuddy-skill
mkdir -p ~/.claude/skills
cp -r /tmp/workbuddy-skill/skills/python-background-jobs ~/.claude/skills/python-background-jobsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Python Background Jobs & Task Queues
把耗时、易失败或可异步的工作从请求生命周期中解耦。可靠的后台任务不是简单调用 `.delay()`:必须定义持久状态、投递语义、幂等性、重试预算、取消、死信、可观测性和副作用边界。
## 使用边界
- 开始前确认 Python/queue/worker 版本、任务 owner、输入输出 schema、租户边界、SLA、保留周期、并发、成本和目标环境。
- 默认只读检查队列、job store、worker 配置、代码、指标和日志;在本地/预发布使用合成数据与受控故障。
- 不擅自向生产队列 enqueue/replay/purge、修改 worker 并发、重放死信、变更保留或执行副作用任务;这些操作需要授权和回滚方案。
- payload、job metadata 和错误日志不得含 token、完整用户输入、个人数据或支付信息;任务日志保存脱敏摘要与 correlation ID。
## 任务契约与状态机
每个任务声明稳定 `task_type`、schema/version、owner、最大运行时间、资源类别、幂等键、可重试错误、输出保留和取消语义。API 对长任务只持久化最小输入并返回不可猜测的 job ID;状态接口只允许授权租户读取。
状态至少包括 `pending → running → succeeded/failed`,并明确 `cancel_requested`、`retrying`、`dead_letter` 和过期状态。状态转换使用条件更新/版本号防止两个 worker 同时“成功”;状态存储和消息投递采用 outbox、事务或可证明的一致性策略。
```python
from dataclasses import dataclass
from enum import StrEnum
class JobStatus(StrEnum):
PENDING = "pending"
RUNNING = "running"
SUCCEEDED = "succeeded"
FAILED = "failed"
DEAD_LETTER = "dead_letter"
@dataclass(frozen=True)
class JobRequest:
job_id: str
schema_version: int
idempotency_key: str
async def submit_export(request, tenant_id):
job = await jobs.create_if_absent(
tenant_id=tenant_id, request=request.safe_fields(),
idempotency_key=request.idempotency_key,
)
await outbox.publish_once("export.v1", job.id, tenant_id)
return {"job_id": job.id, "status": job.status, "poll_url": f"/jobs/{job.id}"}
```
## 投递、幂等与副作用Details
- Skill name
python-background-jobs- Repository
- sandbaseai/workbuddy-skill
- Path
skills/python-background-jobs/SKILL.md- License
- MIT
- Repo updated
- 8 September 2026
FAQ
What does the Python Background Jobs skill do?
Use when moving long-running work out of request handlers, designing Python task queues/workers, or handling asynchronous jobs and events.
How do I install the Python Background Jobs skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add sandbaseai/workbuddy-skill --skill python-background-jobs. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Python Background Jobs popular?
It lives in sandbaseai/workbuddy-skill, which has 9 GitHub stars and 3 forks.
Related skills
Access Control Security Best Practices
9sandbaseai/workbuddy-skill
Design, review, implement, and verify least-privilege access controls across users, services, tenants, resources, and administrative workflows.
Accessibility Review
9sandbaseai/workbuddy-skill
Use when reviewing a web interface or interaction for semantic, keyboard, focus, screen-reader, ARIA, and contrast accessibility risks.
Acquire Codebase Knowledge
9sandbaseai/workbuddy-skill
Use when the user asks to map, document, or onboard into an existing codebase and needs evidence-backed architecture, structure, conventions, integrations, testing, and concerns documentation.
Python Observability
9sandbaseai/workbuddy-skill
Use when instrumenting Python services with structured logs, metrics, traces, correlation IDs, dashboards, or production diagnostics.
Product Roadmap
9sandbaseai/workbuddy-skill
Use when creating or revising a product or program roadmap that must connect outcomes, evidence, dependencies, capacity, and uncertainty; distinguish direction and sequencing from an execution plan or fixed promise.
Python Packaging
9sandbaseai/workbuddy-skill
Use when creating or reviewing distributable Python libraries/CLIs, pyproject metadata, wheels, source distributions, dependencies, or package releases.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.