Agent skill

Better Result Adopt

by nikivdev in nikivdev/ts

Migrate codebase from try/catch or Promise-based error handling to better-result.

MITAuto-check passedDevelopment

Install Better Result Adopt

skills CLI
$ npx skills add nikivdev/ts --skill better-result-adopt -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install nikivdev/ts better-result-adopt --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/nikivdev/ts.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.codex/skills/better-result-adopt .claude/skills/better-result-adopt && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
better-result-adopt
GitHub stars
820
Token cost
~1.4k tokens
SKILL.md length
320 words
Files
2 (incl. references)
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Migrate codebase from try/catch or Promise-based error handling to better-result.

  • Works in 3 steps: Start at Boundaries → Identify Error Categories → Migration Order
  • Adopting Result types
  • SKILL.md covers When to Use, Migration Strategy, Pattern Transformations and Defining TaggedErrors, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Better Result Adopt is an agent skill from nikivdev/ts. Migrate codebase from try/catch or Promise-based error handling to better-result. Use when adopting Result types, converting thrown exceptions to typed errors, or refactoring existing error handling to railway-oriented programming.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/tagged-errors.md`).

It sits in Development, covering Refactoring and Error handling. The licence is MIT.

When your agent uses it

  • Adopting Result types
  • Converting thrown exceptions to typed errors
  • Refactoring existing error handling to railway-oriented programming

Example prompts

  • “/better-result-adopt”

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Start at Boundaries
  2. Identify Error Categories
  3. Migration Order

What it can do on your machine

Read from SKILL.md and the folder at commit 7649214. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Better Result Adopt loads about 1.4k tokens when it runs, and up to ~2.4k if it reads all its reference files. Until then it costs about 63 tokens; SKILL.md has 320 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~63
When it runs · the whole SKILL.md, loaded when a task matches
~1.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from nikivdev/ts at commit 7649214, republished under its MIT licence (© nikivdev). 320 words, ~1,355 tokens.

Download SKILL.mdSave it as .claude/skills/better-result-adopt/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
better-result-adopt
description
Migrate codebase from try/catch or Promise-based error handling to better-result. Use when adopting Result types, converting thrown exceptions to typed errors, or refactoring existing error handling to railway-oriented programming.

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
// BEFORE
function parseConfig(json: string): Config {
  try {
    return JSON.parse(json);
  } catch (e) {
    throw new ParseError(e);
  }
}

// AFTER
function parseConfig(json: string): Result<Config, ParseError> {
  return Result.try({
    try: () => JSON.parse(json) as Config,
    catch: (e) => new ParseError({ cause: e, message: `Parse failed: ${e}` })
  });
}
Async/Await to Result.tryPromise
typescript
// BEFORE
async function fetchUser(id: string): Promise<User> {
  const res = await fetch(`/api/users/${id}`);
  if (!res.ok) throw new ApiError(res.status);
  return res.json();
}

// AFTER
async function fetchUser(id: string): Promise<Result<User, ApiError | UnhandledException>> {
  return Result.tryPromise({
    try: async () => {
      const res = await fetch(`/api/users/${id}`);
      if (!res.ok) throw new ApiError({ status: res.status, message: `API ${res.status}` });
      return res.json() as Promise<User>;
    },
    catch: (e) => e instanceof ApiError ? e : new UnhandledException({ cause: e })
  });
}
Null Checks to Result
typescript
// BEFORE
function findUser(id: string): User | null {
  return users.find(u => u.id === id) ?? null;
}
// Caller must check: if (user === null) ...

// AFTER
function findUser(id: string): Result<User, NotFoundError> {
  const user = users.find(u => u.id === id);
  return user ? Result.ok(user) : Result.err(new NotFoundError({ id, message: `User ${id} not found` }));
}
// Caller: yield* findUser(id) in Result.gen, or .match()
Callback Hell to Generator
typescript
// BEFORE
async function processOrder(orderId: string) {
  try {
    const order = await fetchOrder(orderId);
    if (!order) throw new NotFoundError(orderId);
    const validated = validateOrder(order);
    if (!validated.ok) throw new ValidationError(validated.errors);
    const result = await submitOrder(validated.data);
    return result;
  } catch (e) {
    if (e instanceof NotFoundError) return { error: "not_found" };
    if (e instanceof ValidationError) return { error: "invalid" };
    throw e;
  }
}

// AFTER
async function processOrder(orderId: string): Promise<Result<OrderResult, OrderError>> {
  return Result.gen(async function* () {
    const order = yield* Result.await(fetchOrder(orderId));
    const validated = yield* validateOrder(order);
    const result = yield* Result.await(submitOrder(validated));
    return Result.ok(result);
  });
}
// 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

© nikivdev, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in .codex/skills/better-result-adopt of nikivdev/ts.

  • SKILL.md
  • references/tagged-errors.md

Open the folder on GitHubat commit 7649214

Compare with similar skills

Better Result Adopt next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Better Result Adopt compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Better Result Adopt this skillnikivdev/ts820—~1.4kAutomated safety check: PassMIT
Rust Best Practicesfarm-fe/farm5.6k3 repos~1.1kAutomated safety check: PassMIT
Rust SkillsJMBeresford/retrom2.1k1 repos~9.5kAutomated safety check: PassMIT
Idiomatic Elixirgeorgeguimaraes/elixir-agent-tools184—~2.1kAutomated safety check: PassApache-2.0
Rust Skillsnoh-rs/nohrs156—~5.3kAutomated safety check: PassMIT
Clean Codejd-solanki/slidev-theme-dracula1611 repos~3.8kAutomated safety check: PassMIT

Similar skills

  • Guide for writing idiomatic Rust code based on Apollo GraphQL's best practices handbook.

    5.6k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Rust Skills

    JMBeresford/retrom

    Comprehensive Rust coding guidelines with 265 rules across 26 categories.

    2.1k GitHub starsUsed in 1 repo~9.5k tokens
    DevelopmentAuto-check passed
  • Idiomatic Elixir

    georgeguimaraes/elixir-agent-tools

    Writes and refactors idiomatic Elixir modules and functions, with rules for pattern matching, error handling, protocols and when a process is really needed.

    184 GitHub stars~2.1k tokensUpdated 18 days ago
    DevelopmentAuto-check passed
  • Rust Skills

    noh-rs/nohrs

    Comprehensive Rust coding guidelines with 179 rules across 14 categories.

    156 GitHub stars~5.3k tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • Clean Code

    jd-solanki/slidev-theme-dracula

    Write readable, maintainable code through disciplined naming, small functions, and clean error handling.

    161 GitHub starsUsed in 1 repo~3.8k tokens
    DevelopmentAuto-check passed
  • Elixir Antipatterns

    Gentleman-Programming/Gentleman-Skills

    Core catalog of 8 critical Elixir/Phoenix anti-patterns covering error handling, separation of concerns, Ecto queries, and testing.

    657 GitHub stars~2.1k tokensUpdated 6 mo ago
    DevelopmentAuto-check passed

Categories

Questions about Better Result Adopt

What does Better Result Adopt do?

Migrate codebase from try/catch or Promise-based error handling to better-result. Better Result Adopt is an agent skill from nikivdev/ts. Migrate codebase from try/catch or Promise-based error handling to better-result.

When should I use Better Result Adopt?

Better Result Adopt fits situations like: adopting Result types; converting thrown exceptions to typed errors; refactoring existing error handling to railway-oriented programming.

How do I install Better Result Adopt in Claude Code?

Run `npx skills add nikivdev/ts --skill better-result-adopt -a claude-code`. Or copy the skill folder (.codex/skills/better-result-adopt in nikivdev/ts) into .claude/skills/better-result-adopt in your project. Claude Code loads it when a task matches its description.

How do I install Better Result Adopt in Codex?

Run `npx skills add nikivdev/ts --skill better-result-adopt -a codex`. Or copy the skill folder (.codex/skills/better-result-adopt in nikivdev/ts) into .agents/skills/better-result-adopt in your project. Codex loads it when a task matches its description.

Can I use Better Result Adopt in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add nikivdev/ts --skill better-result-adopt -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/better-result-adopt, .gemini/skills/better-result-adopt, .github/skills/better-result-adopt and .opencode/skills/better-result-adopt in your project.

What does Better Result Adopt need to run?

SKILL.md names no scripts, command-line tools or credentials: Better Result Adopt is instructions for the agent only.

Does Better Result Adopt access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Better Result Adopt safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Better Result Adopt use?

Better Result Adopt is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Better Result Adopt use?

About 1.4k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.1k tokens, read only when the agent opens those files.

What are the alternatives to Better Result Adopt?

Skills that share tags, products or a category with Better Result Adopt: Rust Best Practices (farm-fe/farm, 5.6k stars), Rust Skills (JMBeresford/retrom, 2.1k stars), Idiomatic Elixir (georgeguimaraes/elixir-agent-tools, 184 stars) and Rust Skills (noh-rs/nohrs, 156 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Better Result Adopt?

nikivdev (a GitHub user) maintains it in nikivdev/ts, which has 820 GitHub stars. The repository was last updated on March 6, 2026.

Source: nikivdev/ts on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.