- Home
- Skills
- APIs & Backend
- tenacity retry policy library
tenacity retry policy library
Centralize scattered Tenacity retry configurations into a documented, environment-tunable policy library.
$10
Works with the AI Agents you already use
tenacity retry policy library
Example session with this skill installed
Centralize the scattered Tenacity retry decorators in ./src and create a shared policy module with env-tunable defaults.
- Read your context and instructions
- Compiled the tenacity retry policy
I have analyzed the ./src directory and identified 12 inconsistent Tenacity retry configurations. I have generated a central policy module and a replacement map to standardize these call sites.
Centralized Retry Policy Audit
| Policy Name | Detection ID | Original Pattern | Call Sites | Worst Case |
|---|---|---|---|---|
http_idempotent | POL-1-a7b2 | 3 attempts, 1s wait | 5 | 7.5s |
db_transient | POL-2-f9e4 | 5 attempts, exp backoff | 3 | 42.0s |
startup_wait | POL-3-c1d0 | Infinite wait (unsafe) | 2 | 120.0s (capped) |
Generated Policy Module (retry_policies.py)
import logging
import os
from tenacity import (retry, stop_after_attempt, stop_after_delay,
wait_exponential_jitter, before_sleep_log)
_log = logging.getLogger("retry_policies")
def _int(name: str, default: int) -> int:
try:
return int(os.getenv(name, default))
except (ValueError, TypeError):
return default
def http_idempotent(**overrides):
"""
Standard policy for GET/HEAD/PUT.
Worst case: 5 attempts or 30s total duration.
"""
cfg = dict(
stop=stop_after_attempt(_int("RETRY_HTTP_ATTEMPTS", 5)) | stop_after_delay(30),
wait=wait_exponential_jitter(initial=0.5, max=8),
before_sleep=before_sleep_log(_log, logging.WARNING),
reraise=True,
)
cfg.update(overrides)
return retry(**cfg)
Call Site Replacement Map
src/api/client.py:42: Replace@retry(stop=stop_after_attempt(3))with@http_idempotent()src/db/session.py:88: Replace custom wait logic with@db_transient()src/services/gateway.py:12: Replace copy-pasted config with@http_idempotent(stop=stop_after_attempt(10))
Next steps
- Review
output/tenacity-retry-policy-library-report.mdfor full severity breakdown. - Move the generated
retry_policies.pyinto your common utilities directory. - Apply the replacements listed in the patches directory using the provided map.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Python codebases often suffer from scattered, copy-pasted @retry decorators with inconsistent jitter, timeouts, and attempt counts. This fragmentation makes it impossible to globally tune retry behavior or calculate worst-case service latency.
What it does
- Scans Python projects to identify near-duplicate or inconsistent Tenacity configurations across multiple files.
- Generates a central
retry_policies.pymodule with named factories likehttp_idempotentanddb_transient. - Calculates and documents worst-case wall-clock timings for every retry policy.
- Provides a replacement map linking specific lines of code to the new centralized policies.
- Supports environment-variable overrides for all retry parameters to enable runtime tuning.
Frameworks & tools
Python, Tenacity library, AST (for syntax validation).
Why this beats prompting it yourself
Manual cleanup of retries is tedious and prone to mathematical errors in backoff calculations. This skill automatically clusters identical configurations and ensures the new central module is syntactically valid via AST parsing while calculating precise worst-case scenarios that a general prompt might hallucinate.
Use cases
- Standardizing API retry logic across a microservices architecture.
- Removing magic numbers from distributed system decorators.
- Calculating total possible request duration for SLA monitoring.
- Implementing environment-specific retry aggressive-ness without code changes.
Known limitations
Read-only analysis; does not modify source files directly. Skips Python 2, non-UTF-8 files, and Jupyter notebooks by default. Maximum of 5,000 files per scan.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Read-only; doesn't edit source. Skips Python 2 and notebooks. Caps at 5,000 files. Requires Tenacity library in target project.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago
- Software
Python
Permissions
No special permissions declared or detected