clean-python-async
Installation
SKILL.md
Clean Async Python
Async code should make ordering, ownership, and failure behavior explicit. Race-prone behavior deserves small units and direct tests.
A1: Isolate Async Workflows
Keep orchestration separate from pure transformation. Parse, validate, map, and calculate in synchronous helpers when possible; let async functions coordinate I/O.
async def import_users(file: AsyncUserFile, repository: UserRepository) -> None:
rows = await file.read_rows()
users = [parse_user_row(row) for row in rows]
await repository.save_many(users)
A2: Make Ordering Explicit
Use sequential await when order matters and asyncio.gather or TaskGroup when operations are independent. Do not create coroutines without awaiting or scheduling them.