better-result-adopt — community better-result-adopt, better-result, community, ide skills, Claude Code, Cursor, Windsurf

v1.0.0
GitHub

About this Skill

Ideal for TypeScript-focused AI Agents seeking to enhance error handling with typed Result-based solutions. Lightweight Result type for TypeScript with generator-based composition.

dmmulroy dmmulroy
[0]
[0]
Updated: 3/5/2026

Agent Capability Analysis

The better-result-adopt skill by dmmulroy is an open-source community AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance.

Ideal Agent Persona

Ideal for TypeScript-focused AI Agents seeking to enhance error handling with typed Result-based solutions.

Core Value

Empowers agents to migrate existing error handling to typed Result-based error handling with better-result, utilizing generator-based composition and railway-oriented programming patterns, while replacing try/catch blocks and thrown exceptions with typed errors and leveraging Result.tryPromise for Promise-based code.

Capabilities Granted for better-result-adopt

Migrating try/catch blocks to Result types for improved error management
Converting Promise rejections to typed errors with Result.tryPromise
Introducing railway-oriented programming patterns for more robust code
Replacing thrown exceptions with typed errors for better code reliability
Adopting better-result in existing codebases for enhanced error handling

! Prerequisites & Limits

  • Requires TypeScript environment
  • Limited to projects utilizing better-result library
  • May require significant code refactoring for existing projects
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

better-result-adopt

Install better-result-adopt, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

better-result Adoption

Migrate existing error handling (try/catch, Promise rejections, thrown exceptions) to typed Result-based error handling with better-result.

When to Use

  • Adopting better-result in existing codebase
  • Converting try/catch blocks to Result types
  • Replacing thrown exceptions with typed errors
  • Migrating Promise-based code to Result.tryPromise
  • Introducing railway-oriented programming patterns

Migration Strategy

1. Start at Boundaries

Begin migration at I/O boundaries (API calls, DB queries, file ops) and work inward. Don't attempt full-codebase migration at once.

2. Identify Error Categories

Before migrating, categorize errors in target code:

CategoryExampleMigration Target
Domain errorsNotFound, ValidationTaggedError + Result.err
InfrastructureNetwork, DB connectionResult.tryPromise + TaggedError
Bugs/defectsnull deref, type errorLet throw (becomes Panic if in Result callback)

3. Migration Order

  1. Define TaggedError classes for domain errors
  2. Wrap throwing functions with Result.try/tryPromise
  3. Convert imperative error checks to Result chains
  4. Refactor callbacks to generator composition

Pattern Transformations

Try/Catch to Result.try

typescript
1// BEFORE 2function parseConfig(json: string): Config { 3 try { 4 return JSON.parse(json); 5 } catch (e) { 6 throw new ParseError(e); 7 } 8} 9 10// AFTER 11function parseConfig(json: string): Result<Config, ParseError> { 12 return Result.try({ 13 try: () => JSON.parse(json) as Config, 14 catch: (e) => new ParseError({ cause: e, message: `Parse failed: ${e}` }), 15 }); 16}

Async/Await to Result.tryPromise

typescript
1// BEFORE 2async function fetchUser(id: string): Promise<User> { 3 const res = await fetch(`/api/users/${id}`); 4 if (!res.ok) throw new ApiError(res.status); 5 return res.json(); 6} 7 8// AFTER 9async function fetchUser(id: string): Promise<Result<User, ApiError | UnhandledException>> { 10 return Result.tryPromise({ 11 try: async () => { 12 const res = await fetch(`/api/users/${id}`); 13 if (!res.ok) throw new ApiError({ status: res.status, message: `API ${res.status}` }); 14 return res.json() as Promise<User>; 15 }, 16 catch: (e) => (e instanceof ApiError ? e : new UnhandledException({ cause: e })), 17 }); 18}

Null Checks to Result

typescript
1// BEFORE 2function findUser(id: string): User | null { 3 return users.find((u) => u.id === id) ?? null; 4} 5// Caller must check: if (user === null) ... 6 7// AFTER 8function findUser(id: string): Result<User, NotFoundError> { 9 const user = users.find((u) => u.id === id); 10 return user 11 ? Result.ok(user) 12 : Result.err(new NotFoundError({ id, message: `User ${id} not found` })); 13} 14// Caller: yield* findUser(id) in Result.gen, or .match()

Callback Hell to Generator

typescript
1// BEFORE 2async function processOrder(orderId: string) { 3 try { 4 const order = await fetchOrder(orderId); 5 if (!order) throw new NotFoundError(orderId); 6 const validated = validateOrder(order); 7 if (!validated.ok) throw new ValidationError(validated.errors); 8 const result = await submitOrder(validated.data); 9 return result; 10 } catch (e) { 11 if (e instanceof NotFoundError) return { error: "not_found" }; 12 if (e instanceof ValidationError) return { error: "invalid" }; 13 throw e; 14 } 15} 16 17// AFTER 18async function processOrder(orderId: string): Promise<Result<OrderResult, OrderError>> { 19 return Result.gen(async function* () { 20 const order = yield* Result.await(fetchOrder(orderId)); 21 const validated = yield* validateOrder(order); 22 const result = yield* Result.await(submitOrder(validated)); 23 return Result.ok(result); 24 }); 25} 26// Error type is union of all yielded errors

Defining TaggedErrors

See references/tagged-errors.md for TaggedError patterns.

Workflow

  1. Check for source reference: Look for opensrc/ directory - if present, read the better-result source code for implementation details and patterns
  2. Audit: Find try/catch, Promise.catch, thrown errors in target module
  3. Define errors: Create TaggedError classes for domain errors
  4. Wrap boundaries: Use Result.try/tryPromise at I/O points
  5. Chain operations: Convert if/else error checks to .andThen or Result.gen
  6. Update signatures: Change return types to Result<T, E>
  7. Update callers: Propagate Result handling up call stack
  8. Test: Verify error paths with .match or type narrowing

Common Pitfalls

  • Over-wrapping: Don't wrap every function. Start at boundaries, propagate inward.
  • Losing error info: Always include cause/context in TaggedError constructors.
  • Mixing paradigms: Once a module returns Result, callers should too (or explicitly .unwrap).
  • Ignoring Panic: Callbacks that throw become Panic. Fix the bug, don't catch Panic.

References

  • TaggedError Patterns - Defining and matching typed errors
  • opensrc/ directory (if present) - Full better-result source code for deeper context

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is better-result-adopt?

Ideal for TypeScript-focused AI Agents seeking to enhance error handling with typed Result-based solutions. Lightweight Result type for TypeScript with generator-based composition.

How do I install better-result-adopt?

Run the command: npx killer-skills add dmmulroy/better-result. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for better-result-adopt?

Key use cases include: Migrating try/catch blocks to Result types for improved error management, Converting Promise rejections to typed errors with Result.tryPromise, Introducing railway-oriented programming patterns for more robust code, Replacing thrown exceptions with typed errors for better code reliability, Adopting better-result in existing codebases for enhanced error handling.

Which IDEs are compatible with better-result-adopt?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for better-result-adopt?

Requires TypeScript environment. Limited to projects utilizing better-result library. May require significant code refactoring for existing projects.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add dmmulroy/better-result. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use better-result-adopt immediately in the current project.

Related Skills

Looking for an alternative to better-result-adopt or another community skill for your workflow? Explore these related open-source skills.

View All

widget-generator

Logo of f
f

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

149.6k
0
AI

flags

Logo of vercel
vercel

flags is a Next.js feature management skill that enables developers to efficiently add or modify framework feature flags, streamlining React application development.

138.4k
0
Browser

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI