tenacity retry policy library

    1

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

    $10

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+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
    • 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 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.

    tenacity-retry-policy-library.pdf

    PDF · document

    Generated

    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

    Cluster near-identical retry decorators into shared, named policies.Generate env-tunable policy factories with documented worst-case timings.Find inconsistent retry settings for the same external dependency.Identify missing safety features like jitter, timeouts, and logging hooks.

    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.

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

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

    Listed14 days ago

    What's inside

    Frequently Asked Questions