async-operations
20
总安装量
17
周安装量
#17983
全站排名
安装命令
npx skills add https://github.com/oimiragieo/agent-studio --skill async-operations
Agent 安装分布
cursor
17
antigravity
17
github-copilot
17
gemini-cli
17
continue
16
kimi-cli
16
Skill 文档
Async Operations Skill
- 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.