better-result-adopt

Migrate try/catch and Promise error handling to typed Result types in JavaScript and TypeScript codebases.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/sc30gsw/jikan-log --skill better-result-adopt-sc30gsw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-result-adopt
Source: https://github.com/sc30gsw/jikan-log/tree/main/.claude/skills/better-result-adopt
Command: npx skills add https://github.com/sc30gsw/jikan-log --skill better-result-adopt-sc30gsw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Many JavaScript and TypeScript codebases mix try/catch, thrown exceptions, and Promise rejections which lead to untyped, hard-to-reason-about error flows and brittle call chains; this Skill provides a clear migration path to typed Result-based error handling to improve reliability and composability.

Core Features & Use Cases

  • Boundary-first migration: Start at I/O boundaries such as API calls, database queries, and file operations to contain error handling changes and reduce blast radius.
  • Typed errors and matching: Define TaggedError classes for domain and infrastructure failures so error types are explicit and exhaustively matchable.
  • Async and Promise conversion: Replace async/await and Promise rejections with Result.tryPromise and Result.gen patterns to enable railway-oriented composition and safer propagation.
  • Use Case: Migrate a data access layer that currently throws errors into a Result-returning API so callers can compose operations and handle errors declaratively.

Quick Start

Migrate a target module by wrapping its I/O calls with Result.try or Result.tryPromise, create TaggedError classes for domain errors, and update caller signatures to propagate Result types.

Frequently Asked Questions about better-result-adopt

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

FAQPage Schema
How do I convert try/catch blocks to typed Result workflows in TypeScript?

Migrate async/await and Promise rejections to railway-oriented Result flows by replacing them with Result.tryPromise and Result.gen patterns. This enables safer propagation and declarative error handling instead of untyped Promise rejections.

What is the best way to handle database query errors with Result types?

Boundary-first migration starts error handling changes at I/O boundaries like API calls, database queries, and file operations to contain modifications and reduce blast radius. Wrap these calls with Result.try or Result.tryPromise first before updating internal logic.

Why should I use TaggedError classes for TypeScript error handling?

Function signatures should be updated to return Result<T, E> types, where E is a TaggedError class representing domain or infrastructure failures. This ensures callers must explicitly handle error cases during railway-oriented composition.

Does Result type migration work with existing async functions in JavaScript?

Result type migration works with existing async functions in JavaScript by converting async/await and Promise rejections into Result.tryPromise and Result.gen patterns. This allows you to compose operations and handle errors declaratively without throwing exceptions.