better-result-adopt

Migrate try/catch and Promise error handling to typed Result patterns with better-result.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/sutin1234/tanstack-start-agent-skills --skill better-result-adopt-sutin1234
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-result-adopt
Source: https://github.com/sutin1234/tanstack-start-agent-skills/tree/main/.agents/skills/better-result-adopt
Command: npx skills add https://github.com/sutin1234/tanstack-start-agent-skills --skill better-result-adopt-sutin1234

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Migrates codebases from try/catch or Promise-based error handling to typed Result-based patterns using better-result, reducing untyped errors and improving reliability.

Core Features & Use Cases

  • Guidance to shift error handling at boundaries (IO, API, DB) to Result.try/tryPromise.
  • Define TaggedError types and union error handling for safer, composable error flows.
  • Refactor callers and integrate with existing code to enable railway-oriented programming.

Quick Start

Begin by identifying I/O boundaries and replace existing try/catch blocks with Result.try or Result.tryPromise.

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 error handling to typed Result patterns in TypeScript?

Migrate error handling to typed Result patterns by replacing try/catch blocks and Promise rejections at I/O, API, and database boundaries with Result.try and Result.tryPromise, enabling consistent error typing and railway-style workflows.

What is a TaggedError class and how does it improve TypeScript error handling?

A TaggedError class is a custom typed error definition used in Result-based patterns to create safer, composable error flows. Defining TaggedError types enables union error handling and consistent error propagation across modules.

How do I refactor callers to propagate Result values instead of catching thrown errors?

Refactor callers to propagate Result values by removing try/catch blocks and handling the returned Result object directly. This shift enables railway-oriented programming where successful and failed states flow through typed operations without untyped exceptions.

When should I use Result.tryPromise instead of Result.try for boundary migrations?

Use Result.tryPromise when migrating asynchronous Promise-based boundaries like API or database calls, and use Result.try for synchronous operations. Both wrap existing error handling to return typed Result values instead of throwing untyped errors.

What is the best way to handle database and API error handling in TypeScript without try/catch?

The best way to handle database and API errors without try/catch is wrapping those I/O boundaries with Result.tryPromise, defining TaggedError classes for specific failures, and refactoring callers to process the resulting typed Result values.