fp-option-ref
하는 일
이 도구는 코드에서 존재할 수도, 없을 수도 있는 값을 다루도록 돕습니다. 잠재적으로 없는 데이터를 안전하게 다루는 방법을 제공하며 흔한 오류를 막습니다.
사용하는 경우
- ✓사용하기 전에 값이 있는지 확인해야 할 때.
- ✓외부에서 와서 불완전할 수 있는 데이터를 다룰 때.
- ✓기대한 값이 없을 때 오류 메시지를 피하고 싶을 때.
스킬 링크
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/fp-option-ref/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“사용자의 이름이 있는지 안전하게 확인하려면 어떻게 하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
「Option」이라는 개념을 사용합니다. 값이 있으면 「Some(value)」, 없으면 「None」이 됩니다. 이렇게 하면 작업을 안전하게 연결할 수 있습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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.
자주 묻는 질문
「Option」을 쓰는 것과 그냥 「null」이나 「undefined」인지 확인하는 것의 차이는 무엇인가요?
긴 확인 체인에서는 「Option」이 더 안전합니다. 값이 있는 경우와 없는 경우를 모두 명시적이고 체계적으로 처리하도록 강제하기 때문입니다.
「null」이나 「undefined」 값을 「Option」으로 바꿀 수 있나요?
네, `fromNullable` 같은 함수를 사용해 null일 수 있는 값을 「Option」으로 바꿀 수 있습니다.
존재하지 않는 값을 「Option」으로 사용하면 어떻게 되나요?
오류 대신, 보통 기본값이나 값이 없었다는 결과를 받게 됩니다. 설정 방식에 따라 다릅니다.
상세 정보
작성자의 원본 설명
Quick reference for Option type. Use when user needs to handle nullable values, optional data, or wants to avoid null checks.
인기도
- GitHub 스타
- 48k
- 순위
- #4643
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
00-andruia-consultant
48k에이전트가 AI 프로젝트를 시작하거나 개선할 수 있도록 코드를 분석하고 스페인어로 실행 계획을 세워 줍니다.
007
48k에이전트가 보안 감사와 위협 모델링을 수행해 공격과 취약점으로부터 프로젝트를 보호하도록 돕습니다.
10-andruia-skill-smith
48k에이전트가 AI 도구의 작동 방식을 정의하고 문서를 쓰며 구조를 검증하도록 돕습니다.
20-andruia-niche-intelligence
48k에이전트가 신뢰할 수 있는 자료를 바탕으로 특정 산업의 맥락, 규칙, 사용 패턴, 위험을 정리한 요약을 만들도록 돕습니다.