/claude-mods:python-async-opsfrom claude-mods
Provides Python asyncio patterns for concurrent I/O-bound programming, including gather, semaphore, TaskGroup, timeouts, and aiohttp usage.
Ships in claude-mods. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Asyncio patterns for concurrent Python programming.
| Use Async When | Use Sync When |
|---|---|
| I/O-bound operations (HTTP, DB, files) | CPU-bound computations |
| High concurrency (100s+ connections) | Simple scripts, one-off tasks |
| WebSocket/streaming connections | Small data processing |
| Microservices with network calls | Single sequential operations |
Decision tree:
import asyncio
# Coroutine (must be awaited)
async def fetch(url: str) -> str:
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.text()
# Entry point
async def main():
result = await fetch("https://example.com")
return result
asyncio.run(main())
async def fetch_all(urls: list[str]) -> list[str]:
"""Fetch multiple URLs concurrently."""
async with aiohttp.ClientSession() as session:
tasks = [fetch_one(session, url) for url in urls]
return await asyncio.gather(*tasks, return_exceptions=True)
async def fetch_with_limit(urls: list[str], limit: int = 10):
"""Limit concurrent requests."""
semaphore = asyncio.Semaphore(limit)
async def bounded_fetch(url):
async with semaphore:
return await fetch_one(url)
return await asyncio.gather(*[bounded_fetch(url) for url in urls])
async def process_items(items):
"""Structured concurrency with automatic cleanup."""
async with asyncio.TaskGroup() as tg:
for item in items:
tg.create_task(process_one(item))
# All tasks complete here, or exception raised
async def with_timeout():
try:
async with asyncio.timeout(5.0): # Python 3.11+
result = await slow_operation()
except asyncio.TimeoutError:
result = None
return result
# WRONG - blocks event loop
async def bad():
time.sleep(5) # Never use time.sleep!
requests.get(url) # Blocking I/O!
# CORRECT
async def good():
await asyncio.sleep(5)
async with aiohttp.ClientSession() as s:
await s.get(url)
# WRONG - orphaned task
async def bad():
asyncio.create_task(work()) # May be garbage collected!
# CORRECT - keep reference
async def good():
task = asyncio.create_task(work())
await task
| Pattern | Use Case |
|---|---|
gather(*tasks) | Multiple independent operations |
Semaphore(n) | Rate limiting, resource constraints |
TaskGroup() | Structured concurrency (3.11+) |
Queue() | Producer-consumer |
timeout(s) | Timeout wrapper (3.11+) |
Lock() | Shared mutable state |
from contextlib import asynccontextmanager
@asynccontextmanager
async def managed_connection():
conn = await create_connection()
try:
yield conn
finally:
await conn.close()
For detailed patterns, load:
./references/concurrency-patterns.md - Queue, Lock, producer-consumer./references/aiohttp-patterns.md - HTTP client/server patterns./references/mixing-sync-async.md - run_in_executor, thread pools./references/debugging-async.md - Debug mode, profiling, finding issues./references/production-patterns.md - Graceful shutdown, health checks, signal handling./references/error-handling.md - Retry with backoff, circuit breakers, partial failures./references/performance.md - uvloop, connection pooling, buffer sizing./scripts/find-blocking-calls.sh - Scan code for blocking calls in async functions./assets/async-project-template.py - Production-ready async app skeletonPrerequisites:
python-typing-ops - Type hints for async functionsRelated Skills:
python-fastapi-ops - Async web APIspython-observability-ops - Async logging and tracingpython-database-ops - Async database accessassets/async-project-template.py (opens in a new tab)references/aiohttp-patterns.md (opens in a new tab)references/concurrency-patterns.md (opens in a new tab)references/debugging-async.md (opens in a new tab)references/error-handling.md (opens in a new tab)references/mixing-sync-async.md (opens in a new tab)references/performance.md (opens in a new tab)references/production-patterns.md (opens in a new tab)scripts/find-blocking-calls.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub 0xdarkmatter/claude-mods --plugin claude-mods116 skills in this plugin
/a11y-opsWeb accessibility end to end: WCAG 2.2 AA, EAA and ADA Title II obligations, audits (axe, pa11y, keyboard, screen reader), the common failures, accessibility statements, and server-rendered Craft CMS/Twig sites (Formie, CKEditor, multi-site lang). Use when asked about a11y, WCAG, EAA, EN 301 549, Section 508, VPAT, NVDA/VoiceOver, focus, skip links, ARIA, landmarks, alt text, form labels or errors, contrast, target size, or 'is my site accessible'./adr-opsAuthor, index, and lint Architecture Decision Records — append-only memory that recovers the WHY behind a system's shape. Triggers on: adr, architecture decision record, decision log, record this decision, supersede an adr, why was this decided, adr template, next adr number./api-design-opsAPI design patterns for REST, gRPC, and GraphQL. Use for: api design, REST, gRPC, GraphQL, protobuf, schema design, api versioning, pagination, rate limiting, error format, OpenAPI, API authentication, JWT, OAuth2, API gateway, webhook, idempotency./astro-opsAstro framework patterns, rendering strategies, and deployment. Use for: astro, islands architecture, content collections, astro cloudflare, view transitions, partial hydration, astrojs, SSG, SSR, hybrid rendering, astro adapter./asus-router-opsASUS router config and hardening: Asuswrt-Merlin, security hardening, encrypted DNS (DoT/DoH), VPN (WireGuard/OpenVPN), guest networks, VLAN/IoT isolation, AiMesh, AiProtection. Triggers on: asus router, asuswrt, merlin, wireguard router, AiProtection, AiMesh, nvram, jffs, IoT isolation./atomiseAtom of Thoughts (AoT) reasoning - decompose complex problems into atomic units with confidence tracking and backtracking. For genuinely complex reasoning, not everyday questions. Triggers on: atomise, complex reasoning, decompose problem, structured thinking, verify hypothesis.Other plugins' skills for the same job