fp-async
Practical async patterns using TaskEither - clean pipelines instead of try/catch hell, with real API examples
npx skills add sickn33/agentic-awesome-skills --skill fp-async --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Provides concrete guidance for using TaskEither to build asynchronous pipelines in TypeScript, replacing nested try/catch with composable operations. It demonstrates wrapping Promises, chaining async steps, parallel vs sequential execution, error recovery, and real API examples. The goal is to produce clean, context-rich error handling and reusable async patterns using fp-ts constructs.
How it works
- Introduces TaskEither as an async operation that yields either an Error or a value.
- Shows wrapping Promises safely with TE.tryCatch and converting thrown values to a standardized error type.
- Defines helpers (e.g., fetchJson) and demonstrates creating success and failure values via TE.right, TE.left, TE.fromNullable, and TE.fromPredicate.
- Demonstrates chaining with TE.chain and TE.map within pipe for readable async pipelines.
- Uses Do notation (TE.Do, TE.bind, TE.map) to accumulate values across steps.
- Compares sequential vs parallel execution, using sequenceT for parallelizable tasks and TE.traverseArray for batch parallelism.
- Covers error recovery: TE.orElse, conditional recovery, typed errors, and retry with exponential backoff.
- Includes default values patterns to either suppress errors or provide fallbacks, via TE.getOrElse and TE.orElse.
- Provides real API and database examples, including a complete fetch wrapper with a typed ApiError, and a Prisma example for wrapping Prisma operations in TaskEither.
When to use it
- When you need async error handling in TypeScript with TaskEither.
- When the task involves wrapping Promises, composing API calls, or replacing nested try/catch flows.
- When you want practical fp-ts async patterns instead of academic explanations.
What it can touch
- Files and code shown use modules from fp-ts: TE (TaskEither), E (Either), TE.tryCatch, TE.chain, TE.map, TE.Do, TE.bind, TE.traverseArray, TE.ApplyPar, TE.orElse, TE.left, TE.right, TE.fromNullable, TE.fromPredicate, TE.getOrElse, TE.map, TE.traverseArray, etc.
- Examples reference TypeScript types and API client patterns, including fetch, response handling, and custom error types (ApiError, DbError).
Caveats
- Risk: critical. Patterns assume usage of fp-ts libraries and TypeScript typing discipline.
- Some sections rely on specific fp-ts helpers (Do notation, ApplyPar, traverseArray) and may require compatible versions of fp-ts.
- Examples are illustrative and may need adaptation to a real project’s API surface and error taxonomy.
# Practical Async Patterns with fp-ts Stop writing nested try/catch blocks. Stop losing error context. Start building clean async pipelines that handle errors properly. **TaskEither is simply an async operation that tracks success or failure.** That's it. No fancy terminology needed. ## When to Use - You need async error handling in TypeScript with `TaskEither`. - The task involves wrapping Promises, composing API calls, or replacing nested `try/catch` flows. - You want practical fp-ts async patterns instead of academic explanations. ```typescript // TaskEither<Error, User> means: // "An async operation that either fails with Error or succeeds with User" ``` --- ## 1. Wrapping Promises Safely ### The Problem: Try/Catch Everywhere ```typescript // BEFORE: Try/catch hell async function getUserData(userId: string) { try { const response = await fetch(`/api/users/${userId}`) if (!response.ok) { throw new Error(`HTTP ${response.status}`) } const user = await response.json() try { const posts = await fetch(`/api/users/${userId}/posts`) if (!posts.ok) { throw new Error(`HTTP ${posts.status}`) } const postsData = await posts.json() return { user, posts: postsData } } catch (postsError) { /
- When to Use
- 1. Wrapping Promises Safely
- The Problem: Try/Catch Everywhere
- The Solution: Wrap Once, Handle Cleanly
- tryCatch Explained
- Creating Success and Failure Values
- 2. Chaining Async Operations
- The Problem: Callback Hell / Nested Awaits
- The Solution: Clean Pipelines with chain
- chain vs map
- Building Context with Do Notation
- 3. Parallel vs Sequential Execution
- When to Use Each
- Sequential Chaining
What does the fp-async skill do?
Practical async patterns using TaskEither - clean pipelines instead of try/catch hell, with real API examples
How do I install it?
Run `npx skills add sickn33/agentic-awesome-skills --skill fp-async --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From sickn33/agentic-awesome-skills, a repository with 44,414 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.