python-resilience

python-resilience is a skill for Claude Code, Codex 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 CodeCodex

Part of the pythonica plugin — 17 skills shipped together

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.

agentmods
npx agentmods add skills/jartan-llc/grimoire/python-resilience
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, Codex.

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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
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 $0.00025 $0.01318
Opus 5 $0.00013 $0.00659
Sonnet 5 $0.00005 $0.00264
Haiku 4.5 $0.00003 $0.00132

Measured 4d ago against content hash e894f0a3e95f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 4d 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 — 15 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. 4d 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 16d ago), licensed MIT. It adds 25 tokens to every session and 1,318 once invoked, about $0.0001 per session on Opus 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 15 lines, and is treated as a copy.

Related

Other skills, from other repositories

psy-ana-coder

Generate, modify, or debug reproducible R or Python analysis code from a completed analysis config YAML or concrete existing script. Use for data import/cleaning, statistical models, assumption checks, effect sizes, sensitivity analyses, publication figures, reports, session information, and analysis-script runtime…

soupandpsy/amazing-psycoder-skills · 94 tokens

nmr-analyze-simulate

Interpret NMR spectra, assign and verify a ChemDraw target structure inside MestReNova, and generate provenance-marked synthetic 1D NMR raw data. Use when Codex needs to inspect NMR images, peak tables, processed spectra, or Bruker/Varian/Agilent FID directories; import CDX/CDXML with measured 1D 1H or 13C data; write…

cyx1874cyx/mnova-mcp · 147 tokens

fused-widgets

Authoring and previewing JSON-UI widgets as the response of running a project — the py-UDF-computes → json-widget-visualizes pattern, the {{ref}}/$param data grammar, how resolution runs through the compute backend, and the CLI surfaces (widget open, parley, deployed URL) that put a rendered widget in front of a…

fusedio/skills · 97 tokens

fused-execute

Best practices for running code through fused's executecode tool. Use when writing or reviewing any mcpopenfusedexecutecode call — covers how to structure user code, choose a data library, handle results, and write outputs to the file store. For security scanning, spec checks, and testing see fused-verify. If this is…

fusedio/skills · 112 tokens

fused-feedback

Show the human a real browser UI — to ask a question, get an approval/decision, or review a plan — built from Fused's JSON-UI primitives and opened with fused widget open (one-shot — inline --config or a .json file) or the parley (widget push/widget watch, standing). Use in Claude Code whenever a structured choice…

fusedio/skills · 157 tokens

fused-integrations

Reference for using Fused's built-in integration connections inside UDFs. Covers data sources (Snowflake, BigQuery, GCS, S3, Airtable, Notion, Google Drive), compute/inference providers (Modal, Hugging Face, Baseten, Daytona, ComfyOrg, Slack), and LLM providers (Anthropic, OpenAI) — the fused.api connect helpers…

fusedio/skills · 126 tokens