# Async safety

> Async safety is an open-source agent skill for developer tools. Stops React Native async code from failing silently, racing or leaking listeners. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/zakariaf/ReactNative-Skills/tree/main/skills/async-safety
- **Repository:** https://github.com/zakariaf/reactnative-skills
- **GitHub stars:** 16
- **License:** MIT
- **Skill name:** async-safety
- **Collection:** https://github.com/zakariaf/ReactNative-Skills
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill sets rules for promises, effects, cancellation, subscriptions and timers in an Expo or React Native app, so async results do not land after they are stale and rejections are not dropped. It covers wrapping promise-returning handlers, typing callbacks as void, cancelling effect work with an AbortController per run, latest-wins handling for overlapping reads, and releasing listeners and timers where they were created.

It bundles three small TypeScript helpers with tests: a latest-request tracker, a delayOrAbort pause and a withTimeout deadline that aborts the abandoned task. It also ships a zero-dependency Node checker that scans the code for the patterns the rules forbid, plus reference notes and example hooks that show the intended shapes.

The guidance expects a codebase using TypeScript, Jest and ESLint, and it defers server-state caching to a TanStack Query setup. Some checks are meant to be confirmed on an iOS simulator or Android emulator, since the cancellation and background behaviour differ on a device from what Jest reports.

## When your agent uses it

> Prevents silent async bugs: effect races, stale results, lost promises, leaked listeners and timers, AbortSignal gaps. Use when writing useEffect, setTimeout, listeners or cancellation. Not for query caching (networking-and-server-state).

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Runs JavaScript and TypeScript scripts](https://github.com/zakariaf/ReactNative-Skills/tree/HEAD/skills/async-safety)
- [Network calls found in its scripts](https://github.com/zakariaf/ReactNative-Skills/tree/HEAD/skills/async-safety)
- [License: MIT](https://github.com/zakariaf/ReactNative-Skills/tree/HEAD/skills/async-safety)

## Features

- **Promise ownership rules:** Ensures promise-returning functions are wrapped rather than passed by reference into event props.
- **Effect cancellation:** Aborts in-flight work in effect cleanups and checks signals before each state write.
- **Latest-wins requests:** Lets a newer read abort an older overlapping one while writes are never aborted.
- **Cancellation without errors:** Decides cancellation by checking the abort signal rather than error names.
- **Listener and timer release:** Keeps subscription handles and timer ids so they are removed in the matching cleanup.
- **Deadlines and retries:** Provides a timeout wrapper and abortable delays for bounded retry loops.
- **Static checker:** A dependency-free script that flags the forbidden async patterns in a project.

## Good for

- Fix a search screen where an older query result overwrites a newer one
- Stop a polling interval from running while a screen is covered
- Add a timeout to a native SDK call that can hang
- Remove a listener that leaks after a screen unmounts
- Replace a retry loop's sleep with one that stops when the screen leaves

## Install

### Claude Code

This skill ships in the `react-native` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add zakariaf/ReactNative-Skills
/plugin install react-native@react-native-skills
```

Or copy only this skill to `~/.claude/skills/async-safety`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/async-safety &&
cp -R "$tmp/skills/async-safety" ~/.claude/skills/async-safety &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/async-safety` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/async-safety` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/async-safety &&
cp -R "$tmp/skills/async-safety" ~/.agents/skills/async-safety &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/async-safety` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/async-safety` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/async-safety &&
cp -R "$tmp/skills/async-safety" ~/.cursor/skills/async-safety &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/async-safety` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/zakariaf/ReactNative-Skills.git --path skills/async-safety
```

Or copy the folder to `~/.gemini/skills/async-safety` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/async-safety`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/async-safety &&
cp -R "$tmp/skills/async-safety" ~/.copilot/skills/async-safety &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/async-safety` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/zakariaf/ReactNative-Skills.git
```

Then copy `ReactNative-Skills/skills/async-safety` into your agent's skills folder as `async-safety`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does Async safety handle server data fetching?

No. Server reads are meant to use useQuery from the networking skill; this skill covers async work that is not server state, such as SQLite reads and native SDK or OS calls.

### What does the checker script need?

It is a zero-dependency Node script run from the repository root, and it reports FAIL lines and a final RESULT line.

### Which clients does Async safety work with?

It follows the shared agent skills format and is not tied to a specific client in its content, so it applies to all supported clients.

### How do I install Async safety in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/async-safety to use it in all your projects, or to .claude/skills/async-safety in one project. Or install the react-native plugin, which includes it: /plugin marketplace add zakariaf/ReactNative-Skills, then /plugin install react-native@react-native-skills.

### Does Async safety run scripts?

Yes. It runs JavaScript and TypeScript scripts. Its scripts contain network calls. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Async safety?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Async safety?

The closest alternatives to Async safety are Error handling typed results, Accessibility as code, Vercel react native skills, Game session host and Architecture and boundaries.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Error handling typed results](https://ai-powered.com/skills/error-handling-typed-results): Error handling typed results is an open-source agent skill for developer tools.
- [Accessibility as code](https://ai-powered.com/skills/accessibility-as-code): Accessibility as code is an open-source agent skill for developer tools.
- [Vercel react native skills](https://ai-powered.com/skills/vercel-react-native-skills): Vercel react native skills is an open-source agent skill for cloud and infrastructure.
- [Game session host](https://ai-powered.com/skills/game-session-host): Game session host is an open-source agent skill for developer tools.
- [Architecture and boundaries](https://ai-powered.com/skills/architecture-and-boundaries): Architecture and boundaries is an open-source agent skill for developer tools.
- [React patterns](https://ai-powered.com/skills/react-patterns-tonyghiani): React patterns is an open-source agent skill for developer tools.
- [Expo data fetching](https://ai-powered.com/skills/expo-data-fetching-scaledockhq): Expo data fetching is an open-source agent skill for developer tools.
- [Background tasks](https://ai-powered.com/skills/background-tasks): Background tasks is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/async-safety
