better-result-adopt

Migrate TypeScript error handling from try/catch to better-result Result patterns.

1.9k|41|Updated Jan 9, 2026
One-click install
npx skills add https://github.com/dmmulroy/better-result --skill better-result-adopt-dmmulroy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-result-adopt
Source: https://github.com/dmmulroy/better-result/tree/main/skills/adopt
Command: npx skills add https://github.com/dmmulroy/better-result --skill better-result-adopt-dmmulroy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps teams migrate existing error handling from try/catch blocks, Promise rejections, and thrown exceptions to typed Result-based patterns using better-result, reducing boilerplate and improving reliability.

Core Features & Use Cases

  • Guided migration approach: identify and convert error paths to Result.ok/err flows and TaggedError patterns.
  • Domain error definitions: leverage TaggedError classes to model domain failures with rich context.
  • Generator-based workflows: enable deterministic composition with Result.gen and Result.await across async boundaries.
  • Use Case: refactor a legacy module to adopt Result-based error handling across API calls and I/O.

Quick Start

To begin, run a guided migration on a target module by focusing on boundary operations and migrating inner logic progressively.

Frequently Asked Questions about better-result-adopt

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate TypeScript error handling from try/catch to typed Result patterns?

To migrate TypeScript error handling from try/catch to typed Result patterns, convert imperative checks into Result chains and use Result.try/tryPromise at I/O boundaries. This progressively replaces thrown exceptions with deterministic Result.ok/err flows.

What is a TaggedError in TypeScript domain logic?

A TaggedError in TypeScript domain logic is a class that models domain failures with rich context. It replaces generic thrown exceptions, enabling precise error handling and typed Result-based pattern matching across your codebase.

How does Result.gen handle async boundaries in TypeScript?

Result.gen handles async boundaries in TypeScript by enabling deterministic composition through generator-based workflows. You use Result.await within Result.gen to sequence asynchronous operations without nested try/catch blocks.

Do I need the better-result library to use TaggedError and Result.gen?

Yes, you need the better-result library and standard TypeScript tooling as prerequisites to use TaggedError and Result.gen. These provide the foundational Result.try/tryPromise and generator-based workflow capabilities.

What is the best way to refactor a legacy module to adopt Result-based error handling?

The best way to refactor a legacy module to adopt Result-based error handling is to run a guided migration targeting boundary operations first. Progressively migrate inner domain logic to Result chains and TaggedError definitions.

When should I not use typed Result patterns over try/catch in TypeScript?

You should not use typed Result patterns over try/catch when migrating deeply nested imperative logic that lacks clear I/O boundaries or domain logic. Result-based patterns work best at boundary operations and domain logic.