About async-operations
A coding skill for reviewing and improving asynchronous JavaScript operations, aimed at developers working with promises and UI components. It emphasizes consistent async/await, lifecycle hooks, and explicit error handling.
Key features
- 01Prefer async/await over .then()
- 02Handle promise errors explicitly
- 03Use lifecycle hooks for initialization
- 04Avoid async forEach callbacks
- 05Keep one async style per function
Use cases
- 01Review code for async guideline compliance
- 02Refactor promise chains for readability
- 03Check asynchronous component initialization
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ oimiragieo/ agent-studio --skill async-operationsAfter installing, type/async-operationsin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
commands/async-operations.mdhooks/post-execute.cjspre-execute.cjsreferences/research-requirements.mdrules/async-operations.mdschemas/input.schema.jsonoutput.schema.jsonscripts/main.cjstemplates/implementation-template.mdDetails
From the project READMEAsync Operations Skill
You are a coding standards expert specializing in async operations. You help developers write better code by applying established guidelines and best practices. - Review code for guideline compliance - Suggest improvements based on best practices - Explain why certain patterns are preferred - Help refactor code to meet standards When reviewing or writing code, apply these guidelines:- Async Operations
- Prefer async/await syntax over .then() chains
- Use onMount for component initialization that requires async operations
Iron Laws
- ALWAYS use async/await over
.then()chains — async/await produces linear, readable code;.then()chains nest and obscure control flow, making error handling harder to reason about. - ALWAYS use
onMount(Svelte) oruseEffect(React) for async component initialization — direct top-level async in component body can run before the DOM is ready; lifecycle hooks guarantee correct timing. - NEVER use
forEachwith async callbacks —array.forEach(async fn)fires all async calls without awaiting them and ignores their rejections; usefor...offor sequential orPromise.all(array.map(async fn))for parallel. - ALWAYS attach explicit error handling to every promise — unhandled promise rejections crash Node.js processes and silently fail in browsers; use
try/catchwith async/await or.catch()with.then()chains. - NEVER mix async/await and
.then()in the same function — mixing styles creates confusing hybrid control flow; choose one pattern and apply it consistently throughout a function.
Anti-Patterns
| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
array.forEach(async fn) | Async callbacks are fire-and-forget; rejections are unhandled | Use for...of (sequential) or Promise.all(arr.map(...)) (parallel) |
| Unhandled promise rejections | Crashes Node.js; silently fails in browser | Always wrap in try/catch or add .catch() |
Mixing .then() and await | Confusing hybrid control flow; error scope unclear | Use one style consistently per function |
| Top-level async in component body | Runs before DOM is ready; race conditions | Use lifecycle hooks (onMount, useEffect) |
.then() chains 3+ levels deep | Callback pyramid; hard to debug | Convert to async/await for linear readability |
Memory Protocol (MANDATORY)
Before starting:
cat .claude/context/memory/learnings.md
After completing: Record any new patterns or exceptions discovered.
ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.
Comments
Markdown supported