strict-async-await-usage
Installation
SKILL.md
Summary
Use async and await for all asynchronous operations. Do not use Promise chaining (.then(), .catch()) unless absolutely necessary (e.g., in a legacy library callback integration).
Rationale
- Readability:
async/awaitreads like synchronous code, making control flow (loops, conditionals) easier to follow. - Error Handling:
try/catchprovides a single, consistent mechanism for error handling that works for both sync and async errors. - Stack Traces: Modern JS engines often provide better stack traces for async functions than for Promise chains.
Guidance
- Convert Chains: Flatten
.then()chains into sequential lines. - Try/Catch: Wrap fallible async calls in
try/catchblocks. - Top-Level: Use Top-Level Await if the environment supports it, rather than an IIFE with
.then().