Python Resilience
Use when adding Python retry logic, timeouts, backoff, circuit breakers, rate limits, fallbacks, or fault-tolerant service calls.
Install
npx skills add sandbaseai/workbuddy-skill --skill python-resiliencegit clone --depth 1 https://github.com/sandbaseai/workbuddy-skill.git /tmp/workbuddy-skill
mkdir -p ~/.claude/skills
cp -r /tmp/workbuddy-skill/skills/python-resilience ~/.claude/skills/python-resiliencePersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Python Resilience Patterns
让依赖短暂失效时系统能受控地恢复,同时避免重试风暴、请求堆积、重复写入和静默数据错误。韧性设计必须先定义失败语义、总 deadline、幂等性、降级质量和恢复证据。
## 使用边界
- 开始前确认 Python/HTTP client 版本、依赖 SLO、错误契约、超时预算、流量、并发、重试成本、owner 和目标环境。
- 默认只读检查调用代码、错误/延迟指标、依赖契约和日志;在本地/预发布使用合成流量与受控故障注入。
- 不擅自修改生产重试/超时、熔断阈值、限流、队列、缓存、fallback、流量或写入;这些变更需要授权和回滚方案。
- 日志不得记录 token、请求 payload、个人信息或完整下游响应;重试上下文使用错误类别、尝试次数、依赖名和 correlation ID。
## 失败分类与 deadline
只重试有证据的暂时性失败:连接重置、DNS/网络瞬态、读超时、服务端 429/502/503/504(遵循 `Retry-After`)。不要重试参数错误、认证/授权失败、schema/代码 bug、资源不存在或不可幂等的副作用请求。区分依赖失败、调用方取消、超时、熔断打开和本地过载。
每次调用从请求级 deadline 分配连接、读、重试和处理预算;重试必须消耗同一个总预算,不能每次重新获得完整 timeout。为重试次数、总时间、响应体、队列和并发设置硬上限。
```python
import asyncio
import random
RETRYABLE_STATUS = {429, 502, 503, 504}
async def get_with_budget(client, url, *, deadline, max_attempts=3):
for attempt in range(max_attempts):
remaining = deadline - monotonic()
if remaining <= 0:
raise TimeoutError("deadline exhausted")
try:
response = await client.get(url, timeout=remaining)
if response.status_code not in RETRYABLE_STATUS:
response.raise_for_status()
return response
except (TimeoutError, ConnectionError):
if attempt + 1 == max_attempts:
raise
delay = min(2 ** attempt, 10) + random.uniform(0, 0.5)
await asyncio.sleep(min(delay, max(0, deadline - monotonic())))
raise RuntimeError("retry budget exhausted")
```
## 重试、jitter 与幂等Details
- Skill name
python-resilience- Repository
- sandbaseai/workbuddy-skill
- Path
skills/python-resilience/SKILL.md- License
- MIT
- Repo updated
- 8 September 2026
FAQ
What does the Python Resilience skill do?
Use when adding Python retry logic, timeouts, backoff, circuit breakers, rate limits, fallbacks, or fault-tolerant service calls.
How do I install the Python Resilience skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add sandbaseai/workbuddy-skill --skill python-resilience. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Python Resilience 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.
Refactoring
5Sagargupta16/claude-skills
Use when restructuring code without changing behavior -- extracting functions, renaming, moving files, reducing duplication, migrating between patterns (JS to TS, CJS to ESM), or addressing code smells. Covers safe refactoring workflows for any language.
Python Packaging
9sandbaseai/workbuddy-skill
Use when creating or reviewing distributable Python libraries/CLIs, pyproject metadata, wheels, source distributions, dependencies, or package releases.
Release Planner
9sandbaseai/workbuddy-skill
Use when planning a production release, phased rollout, migration sequence, canary, rollback, or measurable go/no-go decision.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.