adopt-better-result

Migrate TypeScript codebases to better-result error handling through audits and vertical slices.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Adopting explicit Result-based error handling across an existing TypeScript codebase is hard to do safely: failures hide in throws, sentinels, and unhandled rejections, and partial migrations leave inconsistent control flow. This Skill provides a structured, evidence-driven process to audit every failure path and migrate code one bounded vertical slice at a time.

Core Features & Use Cases

  • Repository-wide error audit: Inventories production areas, searches for failure mechanisms (throws, sentinels, rejections), traces end-to-end propagation paths, and produces an adoption report with a failure catalog and boundary map.
  • Failure taxonomy and tagged errors: Classifies each failure as recoverable (TaggedError), defect (Panic), or unknown, with guidance on structured context, messages, and exhaustive error matching.
  • Boundary and codec design: Decides where Result ends, defines wire contracts with Result.codec for HTTP, RPC, queues, and persistence boundaries.
  • Vertical-slice migration: Implements one named path from failure source to handling boundary, preserving behavior with characterization tests and composing async workflows with Result.gen.
  • Use Case: Ask for an audit of your Express API; the Skill catalogs every throw and sentinel, proposes tagged errors and codecs, recommends a first slice, then implements it with tests after your approval.

Quick Start

Ask the assistant to audit this repository's error handling and propose a better-result adoption plan.

Frequently Asked Questions about adopt-better-result

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

FAQPage Schema
How do I migrate a TypeScript codebase to Result-based error handling?

Start with a repository-wide audit that catalogs every throw, sentinel, and rejection, then migrate one vertical slice at a time from failure source to handling boundary. The Skill wraps throwing infrastructure with Result.try or Result.tryPromise and composes async paths with Result.gen.

What is the difference between TaggedError and Panic in better-result?

TaggedError represents a known recoverable failure that callers can handle, retry, or report, while Panic signals a defect such as a violated invariant or programmer mistake. The Skill classifies every discovered failure into one of these dispositions during the audit.

When should Result.codec be used at system boundaries?

Use Result.codec whenever a Result is serialized across HTTP, RPC, queues, workers, or persistence, or received from untrusted data. Each boundary gets named directional schemas that validate envelopes, expose safe public error fields, and reject malformed payloads.

Does the audit change production code before approval?

No. The audit branch only writes an adoption report to the repository's documentation location. Production code changes begin only after you explicitly approve one named vertical slice for implementation.

How are async workflows composed with better-result?

For Promise<Result> workflows with several fallible steps, prefer Result.gen with Result.await. Short pipelines can chain static combinators like Result.andThenAsync, and raw rejections inside callbacks are treated as defects that become Panic.