Skip to content
Skillpedia
General coding48k · #3029

fp-option-ref

Helps your agent handle values that might not exist. It's useful for avoiding errors when accessing potentially missing data.

What it does

This tool helps you handle values that may or may not exist in your code. It provides a safe way to work with potentially missing data, preventing common errors.

When to use it

  • ✓When you need to check if a value exists before using it.
  • ✓When dealing with data that might come from external sources and be incomplete.
  • ✓To avoid error messages when an expected value is not found.

Example of what to ask your AI

“How can I safely check if a user's name exists?”

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

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-option-ref/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-option-ref/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

It uses a concept called 'Option', which can be 'Some(value)' if the value exists, or 'None' if it doesn't. This allows for safe chaining of operations.

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-option-ref

Or download just the file:

curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/fp-option-ref/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Option Quick Reference

Option = value that might not exist. Some(value) or None.

When to Use

  • You need a quick fp-ts reference for nullable or optional values.
  • The task involves eliminating null checks, safe property access, or optional chaining with Option.
  • You want a short reference card rather than a full migration guide.

Create

import * as O from 'fp-ts/Option'

O.some(5)              // Some(5)
O.none                 // None
O.fromNullable(x)      // null/undefined → None, else Some(x)
O.fromPredicate((n: number) => n > 0)(x) // false → None, true → Some(x)

Transform

O.map(fn)              // Transform inner value
O.flatMap(fn)          // Chain Options (fn returns Option)
O.filter(predicate)    // None if predicate false

Extract

O.getOrElse(() => fallbackValue)  // Get value or default
O.toNullable(opt)           // Back to T | null
O.toUndefined(opt)          // Back to T | undefined
O.match(onNone, onSome)     // Pattern match

Common Patterns

import { pipe } from 'fp-ts/function'
import * as O from 'fp-ts/Option'

// Safe property access
pipe(
  O.fromNullable(user),
  O.flatMap(u => O.fromNullable(u.profile)),
  O.flatMap(p => O.fromNullable(p.avatar)),
  O.getOrElse(() => '/default-avatar.png')
)

// Array first element
import * as A from 'fp-ts/Array'
pipe(
  users,
  A.head,  // Option<User>
  O.map(u => u.name),
  O.getOrElse(() => 'No users')
)

vs Nullable

// Nullable: concise and safe for a short access chain
const name = user?.profile?.name ?? 'Guest'

// Option: explicit and composable across multiple operations
pipe(
  O.fromNullable(user),
  O.flatMap(u => O.fromNullable(u.profile)),
  O.flatMap(p => O.fromNullable(p.name)),
  O.getOrElse(() => 'Guest')
)

Use Option when you need to chain operations on optional values.

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 using 'Option' and simply checking if something is 'null' or 'undefined'?

'Option' is safer for long chains of checks, as it forces you to explicitly and organizedly handle both cases (value exists or doesn't exist).

Can I convert a 'null' or 'undefined' value to an 'Option'?

Yes, you can use functions like `fromNullable` to transform a potentially null value into an 'Option'.

What happens if I try to use a non-existent value with 'Option'?

Instead of an error, you'll typically get a default value or a result indicating the value wasn't present, depending on how you've set it up.

Details

Original description by the author

Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks.

repo: sickn33/agentic-awesome-skills

Popularity

GitHub stars
48k
Ranking position
#3029
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills