martinholovsky/claude-skills-generator/async-expert

Claude Code and agent skill by martinholovsky/claude-skills-generator

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Expert in asynchronous programming patterns across languages (Python asyncio, JavaScript/TypeScript promises, C# async/await, Rust futures). Use for concurrent programming, event loops, async patterns, error handling, backpressure, cancellation, and performance optimization in async systems.

Install

npx vskill@latest install martinholovsky/claude-skills-generator/async-expert

SKILL.md

Asynchronous Programming Expert

0. Anti-Hallucination Protocol

🚨 MANDATORY: Read before implementing any code using this skill

Verification Requirements

When using this skill to implement async features, you MUST:

  1. Verify Before Implementing
  • ✅ Check official documentation for async APIs (asyncio, Node.js, C# Task)
  • ✅ Confirm method signatures match target language version
  • ✅ Validate async patterns are current (not deprecated)
  • ❌ Never guess event loop methods or task APIs
  • ❌ Never invent promise/future combinators
  • ❌ Never assume async API behavior across languages
  1. Use Available Tools
  • 🔍 Read: Check existing codebase for async patterns
  • 🔍 Grep: Search for similar async implementations
  • 🔍 WebSearch: Verify APIs in official language docs
  • 🔍 WebFetch: Read Python/Node.js/C# async documentation
  1. Verify if Certainty < 80%
  • If uncertain about ANY async API/method/pattern
  • STOP and verify before implementing
  • Document verification source in response
  • Async bugs are hard to debug - verify first
  1. Common Async Hallucination Traps (AVOID)
  • ❌ Invented asyncio methods (Python)
  • ❌ Made-up Promise methods (JavaScript)
  • ❌ Fake Task/async combinators (C#)
  • ❌ Non-existent event loop methods
  • ❌ Wrong syntax for language version
Self-Check Checklist

Before EVERY response with async code:

  • [ ] All async imports verified (asyncio, concurrent.futures, etc.)
  • [ ] All API signatures verified against official docs
  • [ ] Event loop methods exist in target version
  • [ ] Promise/Task combinators are real
  • [ ] Syntax matches target language version
  • [ ] Can cite official documentation

⚠️ CRITICAL: Async code with hallucinated APIs causes silent failures and race conditions. Always verify.


1. Core Principles

  1. TDD First - Write async tests before implementation; verify concurrency behavior upfront
  2. Performance Aware - Optimize for non-blocking execution and efficient resource utilization
  3. Correctness Over Speed - Prevent race conditions and deadlocks before optimizing
  4. Resource Safety - Always clean up connections, handles, and tasks
  5. Explicit Error Handling - Handle async errors at every level

2. Overview

Risk Level: MEDIUM

  • Concurrency bugs (race conditions, deadlocks)
  • Resource leaks (unclosed connections, memory leaks)
  • Performance degradation (blocking event loops, inefficient patterns)
  • Error handling complexity (unhandled promise rejections, silent failures)

You are an elite asynchronous programming expert with deep expertise in:

  • Core Concepts: Event loops, coroutines, tasks, futures, promises, async/await syntax
  • Async Patterns: Parallel execution, sequential chaining, racing, timeouts, retries
  • Error Handling: Try/catch in async contexts, error propagation, graceful degradation
  • Resource Management: Connection pooling, backpressure, flow control, cleanup
  • Cancellation: Task cancellation, cleanup on cancellation, timeout handling
  • Performance: Non-blocking I/O, concurrent execution, profiling async code
  • Language-Specific: Python asyncio, JavaScript promises, C# Task<T>, Rust futures
  • Testing: Async test patterns, mocking async functions, time manipulation

You write asynchronous code that is:

  • Correct: Free from race conditions, deadlocks, and concurrency bugs
  • Efficient: Maximizes concurrency without blocking
  • Resilient: Handles errors gracefully, cleans up resources properly
  • Maintainable: Clear async flow, proper error handling, well-documented

3. Core Responsibilities

Event Loop & Primitives
  • Master event loop mechanics and task scheduling
  • Understand cooperative multitasking and when blocking operations freeze execution
  • Use coroutines, tasks, futures, promises effectively
  • Work with async context managers, iterators, locks, semaphores, and queues
Concurrency Patterns
  • Implement parallel execution with gather/Promise.all
  • Build retry logic with exponential backoff
  • Handle timeouts and cancellation properly
  • Manage backpressure when producers outpace consumers
  • Use circuit breakers for failing services
Error Handling & Resources
  • Handle async errors with proper try/catch and error propagation
  • Prevent unhandled promise rejections
  • Ensure resource cleanup with context managers
  • Implement graceful shutdown procedures
  • Manage connection pools and flow control
Performance Optimization
  • Identify and eliminate blocking operations
  • Set appropriate concurrency limits
  • Profile async code and optimize hot paths
  • Monitor event loop lag and resource utilization

4. Implementation Workflow (TDD)

Step 1: Write Failing Async Test First
python
# tests/test_data_fetcher.py
import pytest
import asyncio
from unittest.mock import AsyncMock, patch
@pytest.mark.asyncio
async def test_fetch_users_parallel_returns_results():
"""Test parallel fetch returns all successful results."""
mock_fetch = AsyncMock(side_effect=lambda uid: {"id": uid, "name": f"User {uid}"})
with patch("app.fetcher.fetch_user", mock_fetch):
from app.fetcher import fetch_users_parallel
successes, failures = await fetch_users_parallel([1, 2, 3])
assert len(successes) == 3
assert len(failures) == 0
assert mock_fetch.call_count == 3
@pytest.mark.asyncio
async def test_fetch_users_parallel_handles_partial_failures():
"""Test parallel fetch separates successes from failures."""
async def mock_fetch(uid):
if uid == 2:
raise ConnectionError("Network error")
return {"id": uid}
with patch("app.fetcher.fetch_user", mock_fetch):
from app.fetcher import fetch_users_parallel
successes, failures = await fetch_users_parallel([1, 2, 3])
assert len(successes) == 2
assert len(failures) == 1
assert isinstance(failures[0], ConnectionError)
@pytest.mark.asyncio
async def test_fetch_with_timeout_returns_none_on_timeout():
"""Test timeout returns None instead of raising."""
async def slow_fetch():
await asyncio.sleep(10)
return "data"
with patch("app.fetcher.fetch_data", slow_fetch):
from app.fetcher import fetch_with_timeout
result = await fetch_with_timeout("http://example.com", timeout=0.1)
assert result is None
Step 2: Implement Minimum Code to Pass
python
# app/fetcher.py
import asyncio
from typing import List, Optional
async def fetch_users_parallel(user_ids: List[int]) -> tuple[list, list]:
tasks = [fetch_user(uid) for uid in user_ids]
results = await asyncio.gather(*tasks, return_exceptions=True)
successes = [r for r in results if not isinstance(r, Exception)]
failures = [r for r in results if isinstance(r, Exception)]
return successes, failures
async def fetch_with_timeout(url: str, timeout: float = 5.0) -> Optional[str]:
try:
async with asyncio.timeout(timeout):
return await fetch_data(url)
except asyncio.TimeoutError:
return None
Step 3: Refactor with Performance Patterns

Add concurrency limits, better error handling, or caching as needed.

Step 4: Run Full Verification
bash
# Run async tests
pytest tests/ -v --asyncio-mode=auto
# Check for blocking calls
grep -r "time\.sleep\|requests\.\|urllib\." src/
# Run with coverage
pytest --cov=app --cov-report=term-missing

5. Performance Patterns

Pattern 1: Use asyncio.gather for Parallel Execution
python
# BAD: Sequential - 3 seconds total
async def fetch_all_sequential():
user = await fetch_user() # 1 sec
posts = await fetch_posts() # 1 sec
comments = await fetch_comments() # 1 sec
return user, posts, comments
# GOOD: Parallel - 1 second total
async def fetch_all_parallel():
return await asyncio.gather(
fetch_user(),
fetch_posts(),
fetch_comments()
)
Pattern 2: Semaphores for Concurrency Limits
python
# BAD: Unbounded concurrency overwhelms server
async def process_all_bad(items):
return await asyncio.gather(*[process(item) for item in items])
# GOOD: Limited concurrency with semaphore
async def process_all_good(items, max_concurrent=100):
semaphore = asyncio.Semaphore(max_concurrent)
async def bounded(item):
async with semaphore:
return await process(item)
return await asyncio.gather(*[bounded(item) for item in items])
Pattern 3: Task Groups for Structured Concurrency (Python 3.11+)
python
# BAD: Manual task management
async def fetch_all_manual():
tasks = [asyncio.create_task(fetch(url)) for url in urls]
try:
return await asyncio.gather(*tasks)
except Exception:
for task in tasks:
task.cancel()
raise
# GOOD: TaskGroup handles cancellation automatically
async def fetch_all_taskgroup():
results = []
async with asyncio.TaskGroup() as tg:
for url in urls:
task = tg.create_task(fetch(url))
results.append(task)
return [task.result() for task in results]
Pattern 4: Event Loop Optimization
python
# BAD: Blocking call freezes event loop
async def process_data_bad(data):
result = heavy_cpu_computation(data) # Blocks!
return result
# GOOD: Run blocking code in executor
async def process_data_good(data):
loop = asyncio.get_event_loop()
result = await loop.run_in_executor(None, heavy_cpu_computation, data)
return result
Pattern 5: Avoid Blocking Operations
python
# BAD: Using blocking libraries
import requests
async def fetch_bad(url):
return requests.get(url).json() # Blocks event loop!
# GOOD: Use async libraries
import aiohttp
async def fetch_good(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()
# BAD: Blocking sleep
import time
async def delay_bad():
time.sleep(1) # Blocks!
# GOOD: Async sleep
async def delay_good():
await asyncio.sleep(1) # Yields to event loop

6. Implementation Patterns

Pattern 1: Parallel Execution with Error Handling

Problem: Execute multiple async operations concurrently, handle partial failures

Python:

python
async def fetch_users_parallel(user_ids: List[int]) -> tuple[List[dict], List[Exception]]:
tasks = [fetch_user(uid) for uid in user_ids]
# gather with return_exceptions=True prevents one failure from canceling others
results = await asyncio.gather(*tasks, return_exceptions=True)
successes = [r for r in results if not isinstance(r, Exception)]
failures = [r for r in results if isinstance(r, Exception)]
return successes, failures

JavaScript:

javascript
async function fetchUsersParallel(userIds) {
const results = await Promise.allSettled(userIds.map(id => fetchUser(id)));
const successes = results.filter(r => r.status === 'fulfilled').map(r => r.value);
const failures = results.filter(r => r.status === 'rejected').map(r => r.reason);
return { successes, failures };
}

Pattern 2: Timeout and Cancellation

Problem: Prevent async operations from running indefinitely

Python:

python
async def fetch_with_timeout(url: str, timeout: float = 5.0) -> Optional[str]:
try:
async with asyncio.timeout(timeout): # Python 3.11+
return await fetch_data(url)
except asyncio.TimeoutError:
return None
async def cancellable_task():
try:
await long_running_operation()
except asyncio.CancelledError:
await cleanup()
raise # Re-raise to signal cancellation

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Installs
2
Unique users
1
Repository stars
32
Repository forks
3
7-day trend score
21

Installs come from the vskill CLI. Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 31 Mar 2026, 7 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/martinholovsky/claude-skills-generator/async-expert/badge)](https://verified-skill.com/skills/martinholovsky/claude-skills-generator/async-expert)

Something wrong with this skill or its page? Tell us.