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
.claude/rules/async-dependencies.mdWhat 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.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/async-dependencies.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/async-dependencies.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/async-dependencies.mdManually: put the files in place
.clinerules/async-dependencies.mdStep 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