fp-either-ref
Helps your agent handle errors safely. It's useful for managing operations that might fail, making code more reliable.
What it does
This tool helps manage errors in computer programs in an organized way. It lets you know if something succeeded (with a value) or failed (with a specific error message), without the program crashing unexpectedly.
When to use it
- ✓When you need to check if data is correct before using it.
- ✓When performing an operation that might fail, like reading a file.
- ✓To transform code that can throw errors into a format the program understands as 'success' or 'failure'.
Example of what to ask your AI
“How can I check if an email is valid and, if not, show a clear error message?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
It works by defining two paths: one for success (with the expected result) and another for failure (with the problem description). You can then choose which path to follow depending on the outcome.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill fp-either-refOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/fp-either-ref/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Either Quick Reference
Either = success or failure. Right(value) or Left(error).
When to Use
- You need a quick fp-ts reference for typed synchronous error handling.
- The task involves validation, fallible operations, or converting throwing code to
Either. - You want a compact cheat sheet rather than a long tutorial.
Create
import * as E from 'fp-ts/Either'
E.right(value) // Success
E.left(error) // Failure
E.fromNullable(err)(x) // null → Left(err), else Right(x)
E.tryCatch(fn, toError) // try/catch → Either
Transform
E.map(fn) // Transform Right value
E.mapLeft(fn) // Transform Left error
E.flatMap(fn) // Chain (fn returns Either)
E.filterOrElse(pred, toErr) // Right → Left if pred fails
Extract
E.getOrElse(err => fallbackValue) // Get Right or default
E.match(onLeft, onRight) // Pattern match
E.toUnion(either) // E | A (loses type info)
Common Patterns
import { pipe, identity } from 'fp-ts/function'
import * as E from 'fp-ts/Either'
// Toy validation; an @ check is not complete email validation
const validateEmail = (s: string): E.Either<string, string> =>
s.includes('@') ? E.right(s) : E.left('Invalid email')
// Chain validations (stops at first error)
pipe(
E.right({ email: 'test@example.com', age: 25 }),
E.flatMap(d => pipe(validateEmail(d.email), E.map(() => d))),
E.flatMap(d => d.age >= 18 ? E.right(d) : E.left('Must be 18+'))
)
// Convert throwing code
const parseJson = (s: string) => E.tryCatch(
() => JSON.parse(s),
(e) => `Parse error: ${e}`
)
vs try/catch
// ❌ try/catch - errors not in types
try {
const data = JSON.parse(input)
process(data)
} catch (e) {
handleError(e)
}
// ✅ Either - errors explicit in types
pipe(
E.tryCatch(() => JSON.parse(input), String),
E.flatMap(data => E.tryCatch(() => process(data), String)),
E.match(handleError, identity)
)
Use Either when error type matters and you want to chain operations.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Reference scope
These are fp-ts 2.x fragments. Supply application variables, types, validators and imports, and check the installed version. map does not catch thrown exceptions. Task has no typed error channel; an improperly wrapped promise can still reject. Use tryCatch at fallible boundaries.
Official API: fp-ts modules.
FAQ
What's the difference between 'Right' and 'Left'?
'Right' represents success, holding the value you expected. 'Left' represents failure, holding the error message or type that occurred.
Can I use this with code that might throw errors (like reading a file)?
Yes, the tool has a specific function (`tryCatch`) to turn operations that can cause errors into either a 'Right' (success) or 'Left' (failure) result.
How do I get the final result if it could be a success or an error?
You can use functions like `getOrElse` to provide a default value if an error occurs, or `match` to perform different actions depending on whether it was a success or an error.
Details
Original description by the author
Quick reference for Either type. Use when user needs error handling, validation, or operations that can fail with typed errors.
Popularity
- GitHub stars
- 48k
- Ranking position
- #3027
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC