Skip to content

Guide · Agent skill

How to use the Python Resilience Patterns agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The python-resilience skill is an agent skill: a packaged set of instructions that tells an AI coding agent how to follow a specific set of practices for a task. This one covers writing Python code that survives temporary failures, such as a network call that times out or a server that briefly returns an overload error. This guide explains what the skill changes, how to install it, how to trigger it, and what to watch for before you rely on its code.

Python Resilience Patternswshobson/agents · MIT

Quick start

  1. 1Download and unzip the skill. Download the ZIP from this page and unzip it so you have a python-resilience folder containing SKILL.md and references/details.md.
  2. 2Place the folder where your agent looks for skills. Move the folder to ~/.claude/skills/ for personal use, or to your project's .claude/skills/ folder for one project. Alternatively, upload it in the Claude apps under Settings → Capabilities → Skills.
  3. 3Install Python dependencies. In your project, install the tenacity and httpx libraries, which the skill's examples use.
  4. 4Ask for retry logic in plain language. Describe the external call, the errors you see and any time limit you need, for example asking for retries on 429 and 503 responses.
  5. 5Review which errors are retried. Check that the generated code retries only transient errors and does not retry bugs, authentication failures or most 4xx responses.
  6. 6Confirm timeouts and caps are set. Make sure every network call has a timeout and that attempts and total duration are both bounded.
  7. 7Test the failure path. Run the code against a service or stub that returns the errors you expect, and confirm retries stop at your limits.

What the skill makes the agent do

With the skill loaded, the agent treats failures as either transient or permanent. Transient failures, such as network timeouts or temporary service issues, are retried. Permanent failures, such as invalid credentials or bad requests, are not.

The skill asks the agent to apply four rules: retry only errors that might succeed on a second try, increase the wait between attempts with exponential backoff, add random jitter so many clients do not retry at the same moment, and cap both the number of attempts and the total duration. It also says to set a timeout on every network call.

  • Retry transient errors such as ConnectionError, TimeoutError and httpx timeouts.
  • Do not retry ValueError, TypeError, authentication errors, or HTTP 4xx errors other than 429.
  • Retry HTTP 429 and gateway errors 502, 503 and 504 when checking response status codes.
  • Bound retries with stop_after_attempt and stop_after_delay.

Install the skill from a ZIP file

Download the ZIP for this skill from this page and unzip it. The skill folder contains SKILL.md and a references folder with references/details.md. You can install it in one of two places: your personal skills folder at ~/.claude/skills/, or a project-level .claude/skills/ folder inside a specific project if you want it only for that project.

If you use the Claude apps instead, you can upload the skill under Settings → Capabilities → Skills.

  • Personal install: put the unzipped python-resilience folder in ~/.claude/skills/.
  • Project install: put the unzipped python-resilience folder in your project's .claude/skills/ folder.
  • Claude apps: upload the skill under Settings → Capabilities → Skills.

Trigger the skill with natural requests

You do not need a special command. The skill's description says it applies when you are adding retry logic, implementing timeouts, building fault-tolerant services, or handling transient failures, so ask for those things in plain language. Name the library or the situation if you want to be specific, for example that the code calls an external API or a microservice.

Be explicit about the kind of call. The skill is most useful when you say which service you call and which errors you have seen.

  • Add retry logic with exponential backoff to this function that calls the payments-free inventory API.
  • Wrap this httpx call so it retries on 429 and 503 responses, with a total time limit.
  • Make this microservice client fault tolerant to timeouts and connection errors.
  • Add timeouts to every network call in this module.

See what the generated code looks like

The skill's central example wraps a function in a tenacity decorator and uses httpx for the HTTP call. The retry rule, the wait policy and the stop rule are all set on the decorator, so the business logic stays in the function body. The example below is copied from the skill source.

A second pattern retries on the response itself. It checks whether the status code is 429, 502, 503 or 504 and retries only in that case. A third pattern logs each retry attempt so you can see retry rates in your logs.

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()

Know what the skill requires and what it does not do

The skill needs Python. Its examples use the tenacity library and the httpx HTTP client, so install those in your project if you follow the examples. The skill does not run scripts and does not make network requests on its own. It only shapes the code the agent writes, and you still run and test that code yourself.

The skill's examples are the only ones it gives for tenacity and httpx. If your project uses a different retry library, expect to adapt the advice.

  • Requires: Python, the tenacity library, and the httpx library.
  • Runs scripts: no.
  • Uses network: no.

Safety notes before you use the generated code

Automatic retries can duplicate effects. If a call creates a payment or sends a message, a retry after a timeout may do the action twice unless the call is idempotent. Check this before enabling retries on such calls. The skill's advice to retry transient errors is not a guarantee that a retried action is safe.

Retries also add load. The skill addresses this with backoff and jitter, but you should still set sensible attempt and duration caps, and log retries so high retry rates are visible.

  • Do not enable retries on non-idempotent actions such as payments or sending messages unless the calls are idempotent.
  • Always set a timeout on network calls.
  • Log retries so you notice systemic problems.

Tips for getting good results

Give the agent the error types you actually see, such as httpx.ReadTimeout or a 503 response. Specific errors lead to a tighter retry whitelist. Ask the agent to explain which errors it chose not to retry and why, so you can check its reasoning against your API's documentation.

The skill also suggests that for simpler cases you can consider built-in retry functionality or a lightweight custom implementation instead of tenacity. Use that option if you want fewer dependencies.

  • Name the exact exceptions or status codes your service returns.
  • Ask for a total time cap, not only an attempt count.
  • Ask the agent to add logging for each retry.

What people use it for

  • Retrying a call to an external API that sometimes returns HTTP 429 rate limit responses.
  • Adding timeouts and bounded retries to calls between internal microservices.
  • Retrying gateway errors 502, 503 and 504 from a flaky upstream service.
  • Logging retry attempts so a team can spot a service that keeps failing.

Frequently asked questions

How do I install the python-resilience skill?

Download the ZIP from this page and unzip it. Put the python-resilience folder in ~/.claude/skills/ for personal use, or in a project's .claude/skills/ folder. In the Claude apps you can upload it under Settings → Capabilities → Skills.

What do I need to use this skill?

You need Python. The examples use the tenacity library and the httpx HTTP client, so install those in your project. The skill does not run scripts and does not make network requests itself.

Is the python-resilience skill free?

The skill is published under the MIT licence. Check the licence file in the source repository for the full terms. This page does not state any price.

Which errors does the skill retry?

It retries transient errors such as connection errors, timeouts and HTTP 429, 502, 503 and 504 responses. It does not retry ValueError, TypeError, authentication errors or most 4xx client errors.

Can I use this skill with a retry library other than tenacity?

The skill's examples are built around tenacity, so you would need to adapt the advice to another library. The skill itself points to built-in retry functionality or a lightweight custom implementation as options for simpler cases.

Is it safe to retry payments or sending messages with this skill?

Be careful. Automatic retries can duplicate effects, so do not enable them on payments or message sending unless the calls are idempotent. The skill does not make non-idempotent actions safe to retry.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you write Python that calls external APIs or microservices and want careful, bounded retries with backoff, jitter and timeouts. Pick something else if you do not work in Python, if your actions must never repeat, or if your project is committed to a different retry library.

Download the skill