skills/async-parallelization-patterns/SKILL.md
Async parallelization patterns — Promise.all, waterfall prevention, dependency-based parallelism, RSC component composition, deferred await. Use when optimizing async operations, API routes, or data fetching.
npx skillsauth add ihj04982/my-cursor-settings async-parallelization-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Run independent operations in parallel; sequence only when there are actual dependencies.
Bad (sequential, 3 round trips):
const user = await fetchUser();
const posts = await fetchPosts();
const comments = await fetchComments();
Good (parallel, 1 round trip):
const [user, posts, comments] = await Promise.all([
fetchUser(),
fetchPosts(),
fetchComments(),
]);
Start independent operations immediately, even before awaiting dependent ones.
Bad (config waits for auth, data waits for both):
export async function GET(request: Request) {
const session = await auth();
const config = await fetchConfig();
const data = await fetchData(session.user.id);
return Response.json({ data, config });
}
Good (auth and config start in parallel):
export async function GET(request: Request) {
const sessionPromise = auth();
const configPromise = fetchConfig();
const session = await sessionPromise;
const [config, data] = await Promise.all([
configPromise,
fetchData(session.user.id),
]);
return Response.json({ data, config });
}
For partial dependencies, use better-all or chain promises to maximize parallelism.
Using better-all:
import { all } from 'better-all';
const { user, config, profile } = await all({
async user() { return fetchUser(); },
async config() { return fetchConfig(); },
async profile() { return fetchProfile((await this.$.user).id); },
});
Without extra dependencies:
const userPromise = fetchUser();
const profilePromise = userPromise.then((user) => fetchProfile(user.id));
const [user, config, profile] = await Promise.all([
userPromise,
fetchConfig(),
profilePromise,
]);
Reference: better-all
RSC components execute sequentially within a tree. Restructure with composition to parallelize.
Bad (Sidebar waits for Header's fetch):
export default async function Page() {
const header = await fetchHeader();
return <div><div>{header}</div><Sidebar /></div>;
}
Good (both fetch simultaneously):
async function Header() {
const data = await fetchHeader();
return <div>{data}</div>;
}
async function Sidebar() {
const items = await fetchSidebarItems();
return <nav>{items.map(renderItem)}</nav>;
}
export default function Page() {
return <div><Header /><Sidebar /></div>;
}
Move await into branches where the value is actually used. Don't block paths that don't need the data.
Bad (blocks both branches):
async function handleRequest(userId: string, skipProcessing: boolean) {
const userData = await fetchUserData(userId);
if (skipProcessing) return { skipped: true };
return processUserData(userData);
}
Good (only blocks when needed):
async function handleRequest(userId: string, skipProcessing: boolean) {
if (skipProcessing) return { skipped: true };
const userData = await fetchUserData(userId);
return processUserData(userData);
}
Promise.allbetter-allawait deferred to the branch that actually uses the valuedevelopment
Conduct WCAG 2.2 accessibility audits with automated testing, manual verification, and remediation guidance. Use when auditing websites for accessibility, fixing WCAG violations, or implementing accessible design patterns.
research
Generate high-entropy research (자료조사) and ideas (아이디어) using Verbalized Sampling to avoid mode collapse and maximize creativity and novelty.
development
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
documentation
Sync documentation from source-of-truth (package.json, .env.example). Generates CONTRIB.md, RUNBOOK.md. Use when updating project docs or after adding scripts/env vars.