http-retry-sessionlisted
Install: claude install-skill baronguyen001/ai-automation-skills
# HTTP Retry Session
Use this skill when a script makes outbound HTTP calls and a single transient failure (a 429, a 503, a dropped connection) should not crash the run - and a slow endpoint should never hang it forever. It wires a `requests.Session` with a `urllib3` `Retry` policy (backoff + status-forcelist + honored `Retry-After`) and a `TimeoutSession` subclass that applies a default connect/read timeout to every request unless overridden.
## When to invoke
- User says: "add retries to my requests", "handle 429s", "set a timeout on these calls", "the scraper hangs on a slow URL".
- Code in the conversation calls `requests.get`/`post` bare, with no retry policy and no timeout.
## When NOT to invoke
- A single fire-and-forget call where a failure should fail loudly and immediately.
- You need full async concurrency - reach for `httpx`/`aiohttp` with their own retry/timeout setup instead.
## Concrete example
User input:
```text
My API client randomly dies on 429s and once hung for ten minutes. Make it resilient.
```
Output:
```python
# Copy assets/session.py into your project, then:
from session import make_session
# BYO base URL via env or config; nothing target-specific is hardcoded.
session = make_session(total_retries=4, backoff_factor=0.5, timeout=(3.05, 30))
resp = session.get("https://api.example.com/v1/items", params={"page": 1})
resp.raise_for_status() # retries already exhausted 429/5xx by here
data = resp.json()
```
Every call now retries idemp