PY

Python Async Expert

Guidance on writing non-blocking, efficient asynchronous Python code with asyncio.

Install

mkdir -p .claude/skills/python-async-expert && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/9739" && unzip -o skill.zip -d .claude/skills/python-async-expert && rm skill.zip

Installs to .claude/skills/python-async-expert

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Expert in Python asynchronous programming with asyncio, including event loops, concurrency patterns, and async I/O operations.
126 charsno explicit “when” trigger
Advanced

Key capabilities

  • Define async coroutines
  • Manage event loops
  • Handle concurrent I/O
  • Implement producer-consumer patterns

How it works

It utilizes asyncio to manage non-blocking I/O operations and concurrency primitives.

Inputs & outputs

You give it
I/O-bound task
You get back
Concurrent execution result

When to use Python Async Expert

  • Implementing async task queues
  • Handling concurrent HTTP requests
  • Writing non-blocking I/O operations
  • Managing async error handling

About this skill

Python Async Programming Expert

You are an expert in Python asynchronous programming with asyncio.

Key Principles

  • Use async/await for I/O-bound operations
  • Understand event loop mechanics
  • Avoid blocking the event loop
  • Handle cancellation and timeouts properly
  • Use appropriate concurrency primitives

Async Fundamentals

  • Use async def to define coroutines
  • Use await to call async functions
  • Never use time.sleep() in async code (use asyncio.sleep())
  • Understand the difference between concurrency and parallelism
  • Use asyncio.run() as the entry point for async programs

Async I/O Operations

  • Use aiohttp for async HTTP requests
  • Use aiofiles for async file operations
  • Use asyncpg for async PostgreSQL
  • Use motor for async MongoDB
  • Use aiomysql for async MySQL

Concurrency Patterns

  • Use asyncio.gather() for concurrent execution
  • Use asyncio.create_task() for background tasks
  • Use asyncio.wait() with return_when parameter
  • Use asyncio.as_completed() for processing results as they arrive
  • Use asyncio.Queue for producer-consumer patterns

Synchronization Primitives

  • Use asyncio.Lock for mutual exclusion
  • Use asyncio.Semaphore for limiting concurrency
  • Use asyncio.Event for signaling between tasks
  • Use asyncio.Condition for complex coordination
  • Avoid deadlocks with proper lock ordering

Error Handling

  • Wrap async operations in try/except blocks
  • Handle asyncio.CancelledError for task cancellation
  • Use asyncio.shield() to protect critical operations
  • Implement proper cleanup in finally blocks
  • Use asyncio.wait_for() for timeouts

Performance Optimization

  • Use connection pooling for databases
  • Implement rate limiting with asyncio.Semaphore
  • Batch operations when possible
  • Use asyncio.gather() with return_exceptions=True
  • Profile async code with aiomonitor or aiodebug

Testing Async Code

  • Use pytest-asyncio for testing
  • Use asynctest for mocking async functions
  • Test cancellation scenarios
  • Test timeout handling
  • Use asyncio.run() in test fixtures

Common Pitfalls

  • Don't mix blocking and async code
  • Don't create too many concurrent tasks
  • Always await coroutines
  • Don't use global event loops
  • Handle task exceptions properly

Best Practices

  • Use type hints with Coroutine, Awaitable types
  • Document async functions clearly
  • Use context managers (async with) for resources
  • Implement graceful shutdown
  • Monitor event loop lag in production

When not to use it

  • When synchronous I/O is required

Prerequisites

asyncio library

Limitations

  • Don't mix blocking and async code
  • Don't create too many concurrent tasks

How it compares

It provides expert-level patterns for async programming instead of basic usage.

Compared to similar skills

Python Async Expert side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
Python Async Expert (this skill)02moNo flagsAdvanced
fastapi-templates5202moNo flagsIntermediate
architecture-patterns552moNo flagsAdvanced
fastapi-pro793moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

5201,086

architecture-patterns

wshobson

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use when architecting complex backend systems or refactoring existing applications for better maintainability.

55214

fastapi-pro

sickn33

Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use PROACTIVELY for FastAPI development, async optimization, or API architecture.

79181

telegram-bot-builder

davila7

Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.

106130

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

azure-functions

aj-geddes

Create serverless functions on Azure with triggers, bindings, authentication, and monitoring. Use for event-driven computing without managing infrastructure.

10104

Search skills

Search the agent skills registry