python-async
Skill4 starsChanged 8 months agoUnlicenseView on GitHub
Use when designing, debugging, or reviewing async Python — AnyIO, `asyncio`, or Trio code, task groups, cancellation, thread offloading, or async tests. Triggers on: `async def` code in the prompt, "CancelledError", an async hang or shutdown that never finishes, event-loop errors ("attached to a different loop", "asyncio.run() cannot be called"), "task group" / "cancel scope", pytest-asyncio or AnyIO test questions, or "uvloop". Pair the framework skill when lifecycle rules belong to Django, Litestar, or FastAPI.
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Use this skill for async-enabled Python libraries and applications.
- Distinctive: line 23
Default to AnyIO for portable logic: - Use AnyIO APIs for task groups, cancellation, streams, threads, and tests unless native backend …
- Distinctive: line 27
Shield only bounded cleanup: - Do not use shielding as a generic escape hatch from cancellation.
- Very specific: line 29
Do not nest runners: - Do not call asyncio.run() or similar inside a running or framework-owned loop.
- Distinctive: line 32
Portability claims require backend-aware tests: - Do not claim AnyIO portability if code or tests only run on one backend.
- Very specific: line 33
Benchmark before recommending
uvloop: - Treat it as runtime tuning, not a semantic fix. - Very specific: line 79
When thread crossings matter, name from_thread.run() and from_thread.run_sync() separately and state which callable shape each one expects.
- Distinctive: line 81
Call out the highest-risk footgun plainly.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Async Reference
Use this skill for async-enabled Python libraries and applications. Default to AnyIO APIs for portable logic, then surface backend-specific behavior only when raw asyncio, Trio, or uvloop details materially change the answer. Read only the reference files needed for the task.
Critical Rules
- Default to AnyIO for portable logic - Use AnyIO APIs for task groups, cancellation, streams, threads, and tests unless native backend semantics are required.
uvloopis not a third async model - It is anasyncioevent loop implementation and should be treated as an asyncio-only runtime option.- Prefer structured concurrency - Task groups or nurseries beat ad-hoc background task spawning for lifecycle safety.
- Re-raise cancellation after cleanup - Catch cancellation only to clean up or translate context; swallowing it is a bug.
- Shield only bounded cleanup - Do not use shielding as a generic escape hatch from cancellation.
- Do not recommend raw
asyncio.shield()for new portable code - It is too easy to orphan work or hide failures. - Do not nest runners - Do not call
asyncio.run()or similar inside a running or framework-owned loop. - Offload blocking work explicitly - Async syntax does not make blocking file I/O, logging, DNS, or CPU-heavy code safe.
- Treat worker threads as context copies, not extensions - Contextvars are copied into
to_thread.run_sync()and never merge back, and threads cannot be cancelled: long-running worker-thread code must pollfrom_thread.check_cancelled();abandon_on_cancel=Trueonly abandons the wait. - Portability claims require backend-aware tests - Do not claim AnyIO portability if code or tests only run on one backend.
- Benchmark before recommending
uvloop- Treat it as runtime tuning, not a semantic fix. - Prefer repo-local references before external source spelunking - When this skill's reference files already cover the question, answer from them first. Do not spelunk site-packages or unrelated local installs during normal runs unless the task explicitly requires source-level verification beyond the bundled references.
- Make the thread-bridge callable split explicit -
from_thread.run()is for async callables;from_thread.run_sync()is for loop-thread sync callbacks such as setting an AnyIOEvent. Do not collapse them into one interchangeable bucket.
When Not To Use This Skill
- Framework-owned lifecycle rules - Pair the relevant framework skill when startup, shutdown, request lifetimes, or background task ownership belong to Django, Litestar, FastAPI, Starlette, or another framework.
- Distributed task systems - Celery, RQ, Dramatiq, brokers, and cross-process workers are out of scope.
- Low-level event loop internals - Selector internals, custom loop implementations, and CPython internals are not owned here.
- Non-Python async models - gevent, eventlet, greenlets, and non-Python runtimes are out of scope.
- Kernel or network tuning - Production socket tuning, kernel backlog changes, and OS-level performance work are out of scope.
Reference Map
| File | Domain | Use For |
references/REFERENCE.md | Index | Cross-file routing and reading order |
references/decision-matrix.md | Routing | AnyIO vs native backend vs runtime choice |
references/structured-concurrency.md | Task lifecycle | Task groups, readiness handshakes, exception groups, ownership |
references/cancellation-timeouts.md | Cancellation | Cancel scopes, timeouts, shielding, cleanup, async generator finalization, backend differences |
references/streams-synchronization.md | Coordination | Memory object streams, backpressure, locks, events, capacity limits |
references/threads-boundaries.md | Boundaries | Thread offloading, thread/loop crossings, blocking portals, loop ownership |
references/testing.md | Testing | AnyIO pytest plugin, backend matrices, Trio test tools, uvloop test axis |
references/backend-asyncio.md | Backend specifics | Raw asyncio semantics, task/shield/queue/thread pitfalls |
references/backend-trio.md | Backend specifics | Checkpoints, cancel scopes, Trio thread rules, Trio testing tools |
references/backend-uvloop.md | Runtime tuning | What uvloop changes, where to enable it, when not to recommend it |
references/code-review-checklist.md | Review | Fast checklist for async correctness and portability risks |
Task Routing
- Unsure whether to answer in AnyIO or native backend terms ->
references/decision-matrix.md - Designing or reviewing task spawning / background work ->
references/structured-concurrency.md - Fixing hangs, shutdown bugs, timeouts, or cleanup issues ->
references/cancellation-timeouts.md - Choosing queues/channels/locks/semaphores or backpressure behavior ->
references/streams-synchronization.md - Crossing sync/async or thread/event-loop boundaries ->
references/threads-boundaries.md - Writing async tests or building backend matrices ->
references/testing.md - Raw
asynciocode or APIs in the prompt ->references/backend-asyncio.md - Raw Trio code or Trio-native semantics in the prompt ->
references/backend-trio.md uvloopenablement or performance discussion ->references/backend-uvloop.md- Code review of async correctness ->
references/code-review-checklist.md
Output Expectations
- Name the reference files used.
- State whether the answer is
AnyIO-portable,asyncio-specific,Trio-specific, orasyncio-runtime-specific. - Explain the main lifecycle or cancellation constraint, not just the API syntax.
- When thread crossings matter, name
from_thread.run()andfrom_thread.run_sync()separately and state which callable shape each one expects. - State the minimum verification step: tests, backend matrix, runtime smoke test, or benchmark.
- Call out the highest-risk footgun plainly.
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- owenlamont/skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository73 other files it gives its agents.
- agent/AGENTS.mdAGENTS.md
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- git-guardrails-claude-codeSkill
- setup-project-skillsSkill
- skill-creatorSkill
- websearchSkill
- writing-great-skillsSkill
- codebase-designSkill
- construction-craftSkill
- critical-partnerSkill
- data-intensiveSkill
- diagnosing-bugsSkill
- django-disciplineSkill
- docker-disciplineSkill
- documentation-lifecycleSkill
- domain-driven-designSkill
- enterprise-patternsSkill
- git-disciplineSkill
- legacy-codeSkill
- production-readinessSkill
- refactoring-passSkill
- resolving-merge-conflictsSkill
- tddSkill
- testing-workflowSkill
- ui-design-directionSkill
- webapp-testingSkill
- writing-for-agentsSkill
- django-allauthSkill
- djangoSkill
- dockerSkill
- drfSkill
- full-calendarSkill
- giteaSkill
- htmxSkill
- http-status-codesSkill
- hyperscriptSkill
- langchainSkill
- litestarSkill
- prestashopSkill
- prSkill
- pykeSkill
- tablerSkill
- cleanroom-rewriteSkill
- councilSkill
- court-jesterSkill
- domain-modelingSkill
- fix-prSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- humanifySkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- ponytail-auditSkill
- ponytail-debtSkill
- prototypeSkill
- qaSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

