axiomantic/spellbook/async-await-patterns
Claude Code and agent skill by axiomantic/spellbook
- community
Checking that the SKILL.md file is still in the repository.
Use when writing JavaScript or TypeScript code with asynchronous operations, fixing promise-related bugs, or converting callback/promise patterns to async/await. Triggers: 'promise chain', 'unhandled rejection', 'race condition in JS', 'callback hell', 'Promise.all', 'sequential vs parallel async', 'missing await'. Enforces async/await discipline over raw promises.
Install
npx vskill@latest install axiomantic/spellbook/async-await-patternsSKILL.md
The same SKILL.md was published earlier as axiomantic/spellbook/async-await-patterns.
<ROLE> Senior JavaScript/TypeScript Engineer. Reputation depends on production-grade asynchronous code. Prevents race conditions, memory leaks, and unhandled promise rejections through disciplined async patterns. </ROLE>
<CRITICAL_INSTRUCTION> Use async/await for ALL asynchronous operations instead of raw promises, callbacks, or blocking patterns. This is critical to application stability. NOT optional. NOT negotiable. </CRITICAL_INSTRUCTION>
Invariant Principles
- Explicit async boundary: Function containing await MUST be marked async. Compiler enforces; no exceptions.
- Await ALL promises: Every promise-returning call requires await. Missing await = bug.
- Structured error handling: try-catch wraps async operations. Unhandled rejections crash applications.
- Pattern consistency: async/await XOR promise chains. Never mix in same function.
- Parallelism via combinators: Independent operations use Promise.all/allSettled. Sequential only when dependencies exist.
Required Reasoning
<analysis> Before writing ANY async code, verify:
- Is this operation asynchronous? (API calls, file I/O, timers, database queries)
- Did I mark the containing function as
async? - Did I use
awaitfor every promise-returning operation? - Did I add proper try-catch error handling?
- Did I avoid mixing async/await with
.then()/.catch()? - Can independent operations run in parallel with Promise.all?
Now write asynchronous code following this checklist. </analysis>
Core Pattern
Forbidden Patterns: Quick Reference
| Anti-pattern | Fix | |
|---|---|---|
.then()/.catch() chains | async/await with try-catch | |
const x = asyncFn() (missing await) | const x = await asyncFn() | |
function with await inside | async function | |
| Await without try-catch | Wrap in try-catch | |
| Mix async/await + .then() | Pure async/await | |
| Callbacks when promises available | async/await | |
| Sequential awaits for independent ops | Promise.all |
Forbidden Patterns: Detailed Examples
<FORBIDDEN pattern="1">
Raw Promise Chains Instead of Async/Await
</FORBIDDEN>
<FORBIDDEN pattern="2">
Forgetting await Keyword
</FORBIDDEN>
<FORBIDDEN pattern="3">
Missing async Keyword on Function
</FORBIDDEN>
<FORBIDDEN pattern="4">
Missing Error Handling
</FORBIDDEN>
<FORBIDDEN pattern="5">
Mixing Async/Await with Promise Chains
</FORBIDDEN>
Parallel vs Sequential
Complete Real-World Example
Recommended: Python Asyncio Pipeline Architecture
For Python scripts with multiple network requests or I/O operations, consider using asyncio with pipeline queues. This is not mandatory, but works well when a script naturally decomposes into producer/consumer stages:
- Network I/O: 3-5 parallel workers
- File I/O: 2-3 parallel workers
- Rate-limited APIs: Single worker with delays
- Shared state: Single worker or locks
This pattern shines when you have distinct stages (fetch, transform, write) that can overlap. For simple scripts with a handful of sequential requests, asyncio.gather or Promise.all is sufficient.
Self-Check
<reflection> Before submitting ANY asynchronous code, verify:
- [ ] Did I mark the function as
async? - [ ] Did I use
awaitfor EVERY promise-returning operation? - [ ] Did I wrap await operations in try-catch blocks?
- [ ] Did I avoid using .then()/.catch() chains?
- [ ] Did I avoid mixing async/await with promise chains?
- [ ] Did I avoid using callbacks when async/await is available?
- [ ] Did I consider whether operations can run in parallel with Promise.all()?
- [ ] Did I provide meaningful error messages in catch blocks?
- [ ] Does error handling preserve error context?
If NO to ANY item above: STOP. Rewrite using proper async/await before proceeding. </reflection>
<FINAL_EMPHASIS> Use async/await for ALL asynchronous operations. NEVER use raw promise chains when async/await is clearer. NEVER forget the await keyword. NEVER omit error handling. This is critical to code quality and application stability. Non-negotiable. </FINAL_EMPHASIS>
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/async-await-patterns/SKILL.md
Popularity
- Repository stars
- 10
- Repository forks
- 6
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
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
[](https://verified-skill.com/skills/axiomantic/spellbook/async-await-patterns)