Skip to content

Async Python Patterns

Write concurrent, non-blocking Python using asyncio, gather, tasks, timeouts and error handling.

Repository
wshobson/agents
Stars
42,095
Licence
MIT
Files
2 files

What it does

Once installed, the agent knows established patterns for asynchronous Python: when asyncio is the right tool versus threads, multiprocessing or plain sync code, and how to write coroutines, run tasks concurrently with gather(), handle errors and timeouts, and avoid common mistakes like forgetting await or blocking the event loop. It mainly guides the agent's code writing; it does not run anything on its own. Deeper examples are in a reference file that the agent reads when needed.

Great for

  • Python developers building async web APIs with FastAPI, aiohttp or Sanic
  • Engineers moving an I/O-heavy script from sync to asyncio
  • Anyone who wants an agent to write concurrent fetching or background task code with proper cancellation and timeout handling

Skip it if

  • CPU-heavy number crunching, where the skill itself recommends multiprocessing or thread pools instead of asyncio
  • Simple scripts with few connections, where the skill itself notes sync code is simpler and easier to debug
  • Non-Python projects, since the examples are all Python

Try asking

  • “Rewrite this function that fetches 200 URLs one by one so it runs them concurrently with asyncio”
  • “Add a 5-second timeout and error handling to these async database calls”
  • “Show me how to create background tasks with asyncio.create_task and cancel them cleanly”
  • “Review my async code for blocking calls like time.sleep inside coroutines”
Step-by-step guide: how to use Async Python PatternsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 2 original files, the MIT licence and an attribution note.

    async-python-patterns.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip async-python-patterns.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip async-python-patterns.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Name your framework and Python version in the request so the agent picks compatible patterns.
  • Ask the agent to explain why it chose async over threads or multiprocessing for your workload.
  • Always run the generated code and tests yourself, since the examples are illustrative and not production-hardened.

What's inside

  • references/details.md
  • SKILL.md

Redistributed unmodified from wshobson/agents under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.