ワンクリックで
effect-option
Option vs nullable types in Effect. Use when handling optional, nullable, or potentially undefined properties.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Option vs nullable types in Effect. Use when handling optional, nullable, or potentially undefined properties.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Effect service definition, interface design, error types, retries. Use when creating new services or defining error hierarchies.
AXM - Agent Extension Manager: Use for any operation (install/create/new/edit/update/add/remove/delete/publish/find/discover) on agent skills, subagents, slash commands/stored prompts, MCP servers, context packages, rule extensions, hook extensions, or packs — e.g. "create a skill", "make a /command", "add a subagent", "build an MCP server", "publish an extension". Use this BEFORE hand-authoring or editing any SKILL.md, slash-command, subagent, MCP, rule, hook, or extension manifest file: route extension authoring through AXM instead of writing these files directly.
Native skill manifest with two unknown top-level keys.
Effect CLI + Effect architecture. Use when adding commands, defining flags, or wiring handlers. Covers file organization, argument/flag patterns, and testing.
"unterminated
Native skill with an invalid extension name in manifest.
| name | effect-option |
| description | Option vs nullable types in Effect. Use when handling optional, nullable, or potentially undefined properties. |
| user-invocable | false |
Use Option<T> as the default for optional values within Effect codebases. Reserve nullable types (T | null | undefined) for interop boundaries with external APIs, DOM operations, and JSON serialization.
Effect<Option<A>, E>)// Domain modeling: explicit absence
interface User {
email: Option<string>; // "may not have provided" vs "not loaded yet"
}
// Distinguishing absence from error
const findUser = (id: string): Effect.Effect<Option<User>, DatabaseError> =>
// Some(user) = found, None = not found, DatabaseError = actual error
null vs undefined semantics matterparam?: T syntax is clearerConvert eagerly—fromNullable at entry, getOrNull at exit:
// Incoming: convert immediately
const userOption = Option.fromNullable(externalApi.getUser());
// Work with Option throughout
const result = pipe(
userOption,
Option.map((u) => u.preferences),
Option.flatMap((p) => Option.fromNullable(p.theme)),
Option.filter((theme) => theme !== "system"),
Option.getOrElse(() => "dark"),
);
// Outgoing: convert at the edge
const response = { theme: Option.getOrNull(themeOption) };
| From | To | Method |
|---|---|---|
T | null | undefined | Option<T> | Option.fromNullable() |
Option<T> | T | null | Option.getOrNull() |
Option<T> | T | undefined | Option.getOrUndefined() |
() => T | null | (a: A) => Option<T> | Option.liftNullable() |
// REST API with null for absence
Schema.OptionFromNullOr(Schema.String); // null ↔ None
// JavaScript-style undefined
Schema.OptionFromUndefinedOr(Schema.String); // undefined ↔ None
// APIs using both
Schema.OptionFromNullishOr(Schema.String); // null | undefined ↔ None
pipe(
Option.fromNullable(user),
Option.map((u) => u.preferences),
Option.flatMap((p) => Option.fromNullable(p.theme)),
Option.filter((theme) => theme !== "system"),
Option.getOrElse(() => "dark"),
);
const result = Option.gen(function* () {
const user = yield* Option.fromNullable(maybeUser);
const prefs = yield* Option.fromNullable(user.preferences);
return prefs.theme;
});
import { Array, Option, pipe } from "effect";
// filterMap: combines filter + transform
const updated = Array.filterMap(skills, (s) =>
Option.map(s.locked, (locked) => ({ ...s, version: locked.version })),
);
// getSomes: extracts values from Option array
const lockedSkills = Array.getSomes(Array.map(skills, (s) => s.locked));
// Exhaustive handling with match
Option.match(userOption, {
onNone: () => "Anonymous",
onSome: (user) => user.displayName,
});
// Type guards for narrowing
if (Option.isSome(opt)) {
opt.value; // narrowed to Some<A>
}
// Default values
Option.getOrElse(() => fallback); // lazy evaluation
Option.getOrThrow(opt); // escape hatch when invariant guaranteed
// Option to Effect with typed error
Effect.fromOption(opt).pipe(Effect.mapError(() => new NotFoundError()));
// Effect<Option<A>> for recoverable absence
const findUser = (id: string): Effect.Effect<Option<User>, DbError> =>
Effect.gen(function* () {
const result = yield* db.query(id);
return Option.fromNullable(result);
});
Option<T>fromNullable at entry, getOrNull at exitOptionFromNullOr for API contractsEffect<Option<A>, E> for "not found"Option.match for both casesfilterMap, getSomes for Option arrays