api-design-principles
REST 및 GraphQL API 설계 원칙 가이드. 새로운 API 설계, API 스펙 리뷰, API 설계 표준 수립 시 활용. 트리거: "API 설계", "REST", "GraphQL", "엔드포인트 설계", "API…
Python asyncio 및 async/await 패턴 가이드. 비동기 API, 동시성 시스템, I/O 바운드 애플리케이션 구축 시 활용. 트리거: "asyncio", "async/await", "비동기 Python", "concurrent", "aiohttp", "비동기 패턴" 안티-트리거: "동기 Python", "JavaScript async", "Go goroutine", "멀티프로세싱만"
$ npx -y skills add jh941213/my-cc-harness --skill async-python-patterns --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/async-python-patternsContext preview
The summary Claude sees to decide when to auto-load this skill.
Python asyncio 및 async/await 패턴 가이드. 비동기 API, 동시성 시스템, I/O 바운드 애플리케이션 구축 시 활용. 트리거: "asyncio", "async/await", "비동기 Python", "concurrent", "aiohttp", "비동기 패턴" 안티-트리거: "동기 Python", "JavaScript async", "Go goroutine", "멀티프로세싱만"
name: async-python-patterns description: > Python asyncio 및 async/await 패턴 가이드. 비동기 API, 동시성 시스템, I/O 바운드 애플리케이션 구축 시 활용. 트리거: "asyncio", "async/await", "비동기 Python", "concurrent", "aiohttp", "비동기 패턴" 안티-트리거: "동기 Python", "JavaScript async", "Go goroutine", "멀티프로세싱만" user-invocable: false
Comprehensive guidance for implementing asynchronous Python applications using asyncio, concurrent programming patterns, and async/await for building high-performance, non-blocking systems.
The event loop is the heart of asyncio, managing and scheduling asynchronous tasks.
**Key characteristics:**
Functions defined with `async def` that can be paused and resumed.
**Syntax:**
async def my_coroutine():
result = await some_async_operation()
return resultScheduled coroutines that run concurrently on the event loop.
Low-level objects representing eventual results of async operations.
Resources that support `async with` for proper cleanup.
Objects that support `async for` for iterating over async data sources.
import asyncio
async def main():
print("Hello")
await asyncio.sleep(1)
print("World")
# Python 3.7+
asyncio.run(main())import asyncio
async def fetch_data(url: str) -> dict:
"""Fetch data from URL asynchronously."""
await asyncio.sleep(1) # Simulate I/O
return {"url": url, "data": "result"}
async def main():
result = await fetch_data("https://api.example.com")
print(result)
asyncio.run(main())import asyncio
from typing import List
async def fetch_user(user_id: int) -> dict:
"""Fetch user data."""
await asyncio.sleep(0.5)
return {"id": user_id, "name": f"User {user_id}"}
async def fetch_all_users(user_ids: List[int]) -> List[dict]:
"""Fetch multiple users concurrently."""
tasks = [fetch_user(uid) for uid in user_ids]
results = await asyncio.gather(*tasks)
return results
async def main():
user_ids = [1, 2, 3, 4, 5]
users = await fetch_all_users(user_ids)
print(f"Fetched {len(users)} users")
asyncio.run(main())import asyncio
async def background_task(name: str, delay: int):
"""Long-running background task."""
print(f"{name} started")
await asyncio.sleep(delay)
print(f"{name} completed")
return f"Result from {name}"
async def main():
# Create tasks
task1 = asyncio.create_task(background_task("Task 1", 2))
task2 = asyncio.create_task(background_task("Task 2", 1))
# Do other work
print("Main: doing other work")
await asyncio.sleep(0.5)
# Wait for tasks
result1 = await task1
result2 = await task2
print(f"Results: {result1}, {result2}")
asyncio.run(main())import asyncio
from typing import List, Optional
async def risky_operation(item_id: int) -> dict:
"""Operation that might fail."""
await asyncio.sleep(0.1)
if item_id % 3 == 0:
raise ValueError(f"Item {item_id} failed")
return {"id": item_id, "status": "success"}
async def safe_operation(item_id: int) -> Optional[dict]:
"""Wrapper with error handling."""
try:
return await risky_operation(item_id)
except ValueError as e:
print(f"Error: {e}")
return None
async def process_items(item_ids: List[int]):
"""Process multiple items with error handling."""
tasks = [safe_operation(iid) for iid in item_ids]
results = await asyncio.gather(*tasks, return_exceptions=True)
# Filter out failures
successful = [r for r in results if r is not None and not isinstance(r, Exception)]
failed = [r for r in results if isinstance(r, Exception)]
print(f"Success: {len(successful)}, Failed: {len(failed)}")
return successful
asyncio.run(process_items([1, 2, 3, 4, 5, 6]))import asyncio
async def slow_operation(delay: int) -> str:
"""Operation that takes time."""
await asyncio.sleep(delay)
return f"Completed after {delay}s"
async def with_timeout():
"""Execute operation with timeout."""
try:
result = await asyncio.wait_for(slow_operation(5), timeout=2.0)
print(result)
except asyncio.TimeoutError:
print("Operation timed out")
asyncio.run(with_timeout())import asyncio
from typing import Optional
class AsyncDatabaseConnection:
"""Async database connection context manager."""
def __init__(self, dsn: str):
self.dsn = dsn
self.connection: Optional[object] = None
async def __aenter__(self):
print("Opening connection")
await asyncio.sleep(0.1) # Simulate connection
self.connection = {"dsn": self.dsn, "connected": True}
return self.connection
async def __aexit__(self, exc_type, exc_val, exc_tb):
print("Closing connection")
await asyncio.sleep(0.1) # Simulate cleanup
self.connection = None
async def querREST 및 GraphQL API 설계 원칙 가이드. 새로운 API 설계, API 스펙 리뷰, API 설계 표준 수립 시 활용. 트리거: "API 설계", "REST", "GraphQL", "엔드포인트 설계", "API…
레포에서 실질적인 작업(구현·수정·배포·디버깅)을 시작할 때, 새 레포를 처음 파악할 때, 작업을 마치고 기억할 지식이 생겼을 때 사용. 작업 유형에 맞는 docs·메모리만 선택적으로 로드하는 라우팅 테이블을 운영한다
Ralph Loop 병렬 버전. 여러 에이전트가 worktree에서 동시에 PRD 항목을 처리한다. 트리거: "PRD 항목 병렬 구현", "병렬 구현", "autodev parallel", "워크트리 병렬 개발", "병렬 랄프"…
Ralph Loop 기반 자율 개발 루프. Stop Hook이 세션 종료를 가로채어 PRD 항목을 하나씩 완료하며 자동 커밋한다. 트리거: "autodev", "자율 개발", "밤새 돌려", "랄프 루프", "ralph loop",…
기능 추가·컴포넌트 생성·동작 변경 등 모든 창작 작업 전에 사용. 구현 전에 의도·요구사항·설계를 대화로 확정 (심층 인터뷰가 필요한 대규모 기능은 /spec 사용)