Skip to main content
rule CX Codex

async-dependencies — Claude Code rule: what it does, how to install

async-dependencies instructs Claude Code to execute partially dependent async tasks concurrently using better-all or native promise chains rather than blocking Promise.all calls.

MIT ★ 7,191 updated 2026-10-24

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/async-dependencies.md
Open on GitHub

What async-dependencies does

Standard Promise.all setups often block independent calls. For instance, fetching a user profile might wait for a system configuration to finish loading, even though it only requires user data. This rule guides Claude Code to identify partial dependencies and trigger tasks as early as possible.

Two approaches handle this pattern. The primary route relies on the better-all library, where tasks read sibling values through this.$.user. The alternative creates promises upfront and links them with .then() before invoking Promise.all. The rule notes a 2-10× improvement in execution time.

Without adding better-all to package.json, you must chain raw promises manually to avoid extra external dependencies.

What it helps with

  • eliminate idle wait times during sequential promise calls
  • trigger asynchronous tasks at the earliest possible moment
  • implement better-all calls in TypeScript projects
  • wire dependency graphs using native promises without extra packages

Example prompts for the agent

  • Optimize profile and config loading so independent calls run concurrently.
  • Refactor these asynchronous functions with better-all.
  • Implement early execution for dependent promises without extra packages.

How to install async-dependencies

Manually: put the files in place

.claude/rules/async-dependencies.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about async-dependencies

How to install async-dependencies in Claude Code?

Create the file .claude/rules/async-dependencies.md in your project root and save the rule content there.

What does async-dependencies do?

It guides Claude Code to optimize asynchronous TypeScript code by executing partially dependent operations in parallel.

Is the better-all package strictly required?

No, the rule also documents an alternative pattern that links native promises with .then() before passing them to Promise.all.

Source text

async-dependencies.md · MIT
---
title: Dependency-Based Parallelization
impact: CRITICAL
impactDescription: 2-10× improvement
tags: async, parallelization, dependencies, better-all
---

## Dependency-Based Parallelization

For operations with partial dependencies, use `better-all` to maximize parallelism. It automatically starts each task at the earliest possible moment.

**Incorrect (profile waits for config unnecessarily):**

```typescript
const [user, config] = await Promise.all([
  fetchUser(),
  fetchConfig()
])
const profile = await fetchProfile(user.id)
```

**Correct (config and profile run in parallel):**

```typescript
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)
  }
})
```

**Alternative without extra dependencies:**

We can also create all the promises first, and do `Promise.all()` at the end.

```typescript
const userPromise = fetchUser()
const profilePromise = userPromise.then(user => fetchProfile(user.id))

const [user, config, profile] = await Promise.all([
  userPromise,
  fetchConfig(),
  profilePromise
])
```

Reference: [https://github.com/shuding/better-all](https://github.com/shuding/better-all)

© tech-leads-club · MIT · tech-leads-club/agent-skills

Similar IDE rules

All IDE rules for Code review and refactoring →

From the same set130

The whole set →
rerender-memo-with-default-value rerender-memo-with-default-value — a rule that prevents memoization from breaking when React components have default values (functions, objects, arrays) in parameters. It instructs you to extract these defaults into module-level constants. CX Codex +1 ★ 7,191repo stars rendering-animate-svg-wrapper rendering-animate-svg-wrapper enforces wrapping svg elements in an outer div container for CSS animations. Enables GPU hardware acceleration across browsers. CX Codex +1 ★ 7,191repo stars rerender-derived-state-no-effect The rerender-derived-state-no-effect rule keeps derived values out of React state and avoids effects that mirror props. Use it when reviewing components for extra renders and state drift. CX Codex +1 ★ 7,191repo stars rerender-move-effect-to-event rerender-move-effect-to-event tells the agent to fire a side effect from the handler that caused it, not from useEffect watching a state flag. CX Codex +1 ★ 7,191repo stars server-cache-lru The server-cache-lru rule explains when React.cache() is too narrow and an LRU cache should share data between requests. Use it for sequential actions that reuse the same records. CX Codex +1 ★ 7,191repo stars advanced-event-handler-refs advanced-event-handler-refs guides Claude Code to keep event callbacks in refs or useEffectEvent, stopping React effects from re-subscribing on every render. CX Codex +1 ★ 7,191repo stars server-parallel-fetching The server-parallel-fetching rule shows how to compose React Server Components so independent data requests can run in parallel. Use it when one component waits on another component’s fetch. CX Codex +1 ★ 7,191repo stars _sections Defines eight performance optimization sections, ranks them by impact, and guides the agent in prioritizing code improvements. Install once, reference by ID when analyzing bottlenecks. CX Codex +1 ★ 7,191repo stars

Project sponsors

Companies that keep this analytics open