better-result-adopt

Migrate promises, exceptions, and callbacks to better-result Result chains with TaggedError types.

Updated Dec 14, 2025
One-click install
npx skills add https://github.com/anrunt/portfolio-tracker --skill better-result-adopt-anrunt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-result-adopt
Source: https://github.com/anrunt/portfolio-tracker/tree/main/.opencode/skill/better-result-adopt
Command: npx skills add https://github.com/anrunt/portfolio-tracker --skill better-result-adopt-anrunt

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enables teams to migrate ad-hoc exception handling and Promise rejections to a consistent, typed Result-based approach using better-result, reducing runtime errors and improving debuggability.

Core Features & Use Cases

  • Guided migration: transform throw/catch and Promise.catch patterns into TaggedError definitions and Result chains.
  • Boundary-first strategy: start at IO boundaries (API calls, DB access) and refactor inward to ensure predictable error flow.
  • Practical templates: provide examples for TaggedError classes, Result.try/tryPromise usage, and return types like Result<T, E>.
  • Use Case: refactor a microservice to centralize domain errors and propagate errors as typed results, improving observability and type-safety.

Quick Start

Identify a boundary in your codebase, install better-result in your project, and follow the migration steps to convert a sample module.

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 a typed Result pattern in TypeScript?

A typed Result pattern replaces ad-hoc exceptions with Result chains and TaggedError domain errors. You migrate by wrapping IO boundaries using Result.try and tryPromise, transforming Promise rejections into predictable typed errors.

What is the best way to refactor Promise rejections into typed errors?

The best way to refactor Promise rejections is applying a boundary-first strategy. Start at IO boundaries like API calls and DB access, wrap them with Result.tryPromise, define TaggedError classes, and propagate errors inward as typed Result<T, E> return types.

How does railway oriented programming work with TypeScript error handling?

Railway oriented programming in TypeScript routes errors through dedicated channels using Result chains instead of exceptions. By defining TaggedError domain errors and returning Result<T, E> types, applications propagate failures predictably without interrupting standard execution flow.

When should I use TaggedError definitions over standard exceptions?

You should use TaggedError definitions over standard exceptions when you need centralized domain errors and improved debuggability. Defining TaggedError classes allows you to propagate failures as typed Result<T, E> objects, reducing unpredictable runtime errors across microservices.

Can I use better-result to refactor callbacks and exceptions in a microservice?

Yes, you can use better-result to refactor callbacks and exceptions in a microservice. It provides practical templates to centralize domain errors, transforming ad-hoc exception handling into typed Result chains to improve observability and type-safety.