tenacity retry policy library

    1

    Centralize scattered Tenacity retry configurations into a documented, environment-tunable policy library.

    $10

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    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 NameDetection IDOriginal PatternCall SitesWorst Case
    http_idempotentPOL-1-a7b23 attempts, 1s wait57.5s
    db_transientPOL-2-f9e45 attempts, exp backoff342.0s
    startup_waitPOL-3-c1d0Infinite wait (unsafe)2120.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

    1. Review output/tenacity-retry-policy-library-report.md for full severity breakdown.
    2. Move the generated retry_policies.py into your common utilities directory.
    3. 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.py module with named factories like http_idempotent and db_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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Listed2 months ago
    Updated1 month ago

    What's inside

    Frequently Asked Questions

    The library scans your Python codebase using AST (Abstract Syntax Tree) analysis to locate scattered Tenacity decorators, identifies inconsistent retry patterns, and consolidates them into a single, tunable configuration module.

    The skill supports all modern Python 3.x environments and is designed to work with any AI agent that can execute Python scripts or perform static code analysis.

    You will receive the core analysis engine, a policy generation template, and a replacement map that helps you link your current code to the newly centralized policies.

    By centralizing decorators, you can use environment variables to adjust retry intensity (like max attempts or wait times) across your entire application without redeploying code.

    Yes, for every policy generated, the library calculates the maximum possible wall-clock time a request could take, helping you set accurate timeouts and SLAs.

    To maintain code safety, the tool provides a detailed replacement map and a new policy module rather than editing your source files directly, allowing you to review changes before implementation.

    New in APIs & Backend