- 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 tools 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
- Generated the document
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.
tenacity-retry-policy-library.pdf
PDF · document
Example file from a real run - the skill writes it into your workspace.
Connects securely to your tools. The creator never sees your data.
What you get
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.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 14 days ago
- Passed all security checks, Safe to install