python-resilience

python-resilience is a skill for Claude Code from Jartan-LLC/grimoire. It costs 25 tokens per session (1,318 once invoked), scanned B, a copy of python-resilience, MIT.

A set of Python patterns for handling temporary failures in network calls and other unreliable dependencies.

In plain words
What is it for?
It is for adding retries, increasing wait times between attempts, randomising those waits, setting timeouts, and stopping after a defined number of attempts or duration.
Why use it?
It prevents short-lived outages and timeouts from immediately breaking an application, while limiting retries so failures do not continue forever.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the pythonica plugin — 17 skills shipped together

Good fit It is for adding retries, increasing wait times between attempts, randomising those waits, setting timeouts, and stopping after a defined number of attempts or duration.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/jartan-llc/grimoire/python-resilience
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Jartan-LLC/grimoire --skill python-resilience
Clone the repo
git clone --depth 1 https://github.com/Jartan-LLC/grimoire

Made for: Claude Code.

Or install pythonica, the plugin that ships this one along with the rest of its 17 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for python-resilience

README.md
[![agentmods](https://agentmods.dev/badge/skills/jartan-llc/grimoire/python-resilience/github.svg)](https://agentmods.dev/skills/jartan-llc/grimoire/python-resilience)
Your own site
<a href="https://agentmods.dev/skills/jartan-llc/grimoire/python-resilience"><img src="https://agentmods.dev/badge/skills/jartan-llc/grimoire/python-resilience/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-resilience

Your own site · 80×15
<a href="https://agentmods.dev/skills/jartan-llc/grimoire/python-resilience"><img src="https://agentmods.dev/badge/skills/jartan-llc/grimoire/python-resilience.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,318 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 89% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.01318
Opus 5.5 $0.00010 $0.00527
Sonnet 5.5 $0.00005 $0.00264
Haiku 4.5 $0.00003 $0.00132

Measured 1mo ago against content hash e894f0a3e95f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

python-resilience scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Sends data to an external URLmediumData exfiltration

A POST to an outside endpoint may be telemetry or may be exfiltration; either way the mod talks to somewhere, and you should know where.

return httpx.post("https://api.example.com", json=request).json()
Origin

This is a copy

89% identical to python-resilience — 13 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

plugins/pythonica/skills/python-resilience/SKILL.md · 189 lines

How it starts

The opening of the file, as written. The whole thing — 189 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Resilience Patterns

Build fault-tolerant Python applications that gracefully handle transient failures, network issues, and service outages. Resilience patterns keep systems running when dependencies are unreliable.

Core Concepts

1. Transient vs Permanent Failures

Retry transient errors (network timeouts, temporary service issues). Don't retry permanent errors (invalid credentials, bad requests).

2. Exponential Backoff

Increase wait time between retries to avoid overwhelming recovering services.

3. Jitter

Add randomness to backoff to prevent thundering herd when many clients retry simultaneously.

4. Bounded Retries

Cap both attempt count and total duration to prevent infinite retry loops.

Quick Start

from tenacity import retry, stop_after_attempt, wait_exponential_jitter

@retry(
    stop=stop_after_attempt(3),
    wait=wait_exponential_jitter(initial=1, max=10),
)
def call_external_service(request: dict) -> dict:
    return httpx.post("https://api.example.com", json=request).json()

Fundamental Patterns

Pattern 1: Basic Retry with Tenacity

Use the tenacity library for production-grade retry logic. For simpler cases, consider built-in retry functionality or a lightweight custom implementation.

from tenacity import (
    retry,
    stop_after_attempt,
    stop_after_delay,
    wait_exponential_jitter,
    retry_if_exception_type,
)

TRANSIENT_ERRORS = (ConnectionError, TimeoutError, OSError)

@retry(
    retry=retry_if_exception_type(TRANSIENT_ERRORS),
    stop=stop_after_attempt(5) | stop_after_delay(60),
    wait=wait_exponential_jitter(initial=1, max=30),
)
def fetch_data(url: str) -> dict:
    """Fetch data with automatic retry on transient failures."""
    response = httpx.get(url, timeout=30)
    response.raise_for_status()
    return response.json()

Pattern 2: Retry Only Appropriate Errors

Whitelist specific transient exceptions. Never retry:

  • ValueError, TypeError - These are bugs, not transient issues
  • AuthenticationError - Invalid credentials won't become valid
  • HTTP 4xx errors (except 429) - Client errors are permanent

Read the full file on GitHub · 189 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 189 lines · 25 tokens per session scan B e894f0a3e95f

Subscribe to this mod's changes

python-resilience is a skill published in the GitHub repository Jartan-LLC/grimoire (2 stars, last pushed yesterday), licensed MIT. It adds 25 tokens to every session and 1,318 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it B with 1 finding (sends data to an external url). It is 89% identical to python-resilience, differing in 13 lines, and is treated as a copy.

Related

Other skills, from other repositories