async-await-patterns

async-await-patterns is a skill for Claude Code, Codex from axiomantic/spellbook. It costs 81 tokens per session (1,806 once invoked), scanned A, original, MIT.

A set of rules for handling asynchronous JavaScript or TypeScript operations with async and await. Asynchronous work includes tasks such as API calls, file access, timers, and database queries that finish later.

In plain words
What is it for?
It is for writing or fixing promise-based code, converting callbacks, handling parallel operations, and investigating missing await or race-condition problems.
Why use it?
It helps prevent missing results, unhandled errors, inconsistent promise styles, and unnecessary delays when several operations can run together.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It is for writing or fixing promise-based code, converting callbacks, handling parallel…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/axiomantic/spellbook/async-await-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add axiomantic/spellbook --skill async-await-patterns
Clone the repo
git clone --depth 1 https://github.com/axiomantic/spellbook

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for async-await-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/axiomantic/spellbook/async-await-patterns.svg)](https://agentmods.dev/skills/axiomantic/spellbook/async-await-patterns)
Your own site
<a href="https://agentmods.dev/skills/axiomantic/spellbook/async-await-patterns"><img src="https://agentmods.dev/badge/skills/axiomantic/spellbook/async-await-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 81 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,806 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00081 $0.01806
Opus 5 $0.00041 $0.00903
Sonnet 5 $0.00016 $0.00361
Haiku 4.5 $0.00008 $0.00181

Measured 3d ago against content hash f3f523939706, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

async-await-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/async-await-patterns/SKILL.md · 256 lines

How it starts

The opening of the file, as written. The whole thing — 256 lines — stays where its author put it; the contents beside it link to each section on GitHub.

<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

  1. Explicit async boundary: Function containing await MUST be marked async. Compiler enforces; no exceptions.
  2. Await ALL promises: Every promise-returning call requires await. Missing await = bug.
  3. Structured error handling: try-catch wraps async operations. Unhandled rejections crash applications.
  4. Pattern consistency: async/await XOR promise chains. Never mix in same function.
  5. Parallelism via combinators: Independent operations use Promise.all/allSettled. Sequential only when dependencies exist.

Required Reasoning

  1. Is this operation asynchronous? (API calls, file I/O, timers, database queries)
  2. Did I mark the containing function as async?
  3. Did I use await for every promise-returning operation?
  4. Did I add proper try-catch error handling?
  5. Did I avoid mixing async/await with .then()/.catch()?
  6. Can independent operations run in parallel with Promise.all?

Now write asynchronous code following this checklist.

Core Pattern

async function operationName(): Promise<ReturnType> {
  try {
    const result = await asyncOperation();
    return result;
  } catch (error) {
    throw error; // Handle or rethrow with context
  }
}

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

Read the full file on GitHub · 256 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 256 lines · 81 tokens per session scan A f3f523939706

Subscribe to this mod's changes

async-await-patterns is a skill published in the GitHub repository axiomantic/spellbook (10 stars, last pushed 3d ago), licensed MIT. It adds 81 tokens to every session and 1,806 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.