discriminated-unions

강함 · 77
Registry 색인

Apply, review, and explain discriminated unions in TypeScript. Use automatically for tasks involving mutually exclusive variants, invalid state prevention, exhaustiveness checking, variant-specific object properties, application state, function arguments, or React props.

Verified installs0
스타780
버전1.0.0
품질76/100 · 강함
신뢰77/100 · 검토 후 설치
감사85/100 · 안전하게 시도 가능

공급 자산 프로필

리서치 및 지식 작업

Deep research, source comparison, literature review, RAG, knowledge search, and reports.

트랙 보기

시나리오

리서치 Agent

I need my agent to research a topic, compare sources, and produce a concise report.

Agent 적합도

Claude Code + CLI + Codex

Codex, Claude Code, Cursor, CLI 또는 맞춤형 Agent에 적합합니다.

설치

준비됨

npx skills add mkosir/typescript-style-guide --skill discriminated-unions

유지보수

최신

오늘 푸시됨

위험

안전하게 시도 가능

Quality score needs review

GitHub 품질

780

76/100 품질 · 82/100 신뢰

커버리지 태그

리서치리서치 Agentagent-skill

검토 메모

Quality score needs review

Agent 채택 스코어카드

신뢰, 감사, 설치 준비 상태를 한눈에 확인하세요

이 점수는 공개 저장소 메타데이터, OpenAgentSkill 검토 신호, 유지보수 최신성, 설치 준비 상태를 결합합니다. 후보 선정 신호일 뿐, 사람의 검토를 대체하지 않습니다.

품질

강함
76

프로덕션 워크플로 후보군에 넣을 만한 탄탄한 선택입니다.

신뢰

검토 후 설치
77

좋은 후보 신호이지만 Agent는 실행 전에 감사 메모, 설치 정책 및 결과 근거를 검토해야 합니다.

감사

안전하게 시도 가능
85

설치 준비 상태, 보안 메타데이터, 유지보수 및 채택 위험에 대한 기계 판독형 검토입니다.

OpenAgentSkill 신뢰 점수 v5

설치 전 사람 검토

사람 검토 또는 샌드박스 검증 후 우선 후보로 사용하세요.

CodexClaude CodeCursorOpenAgentSkill CLI

스타

GitHub 스타 780

저장소 활동

스타 780, 포크 37

유지보수

오늘 푸시됨

라이선스

MIT

설치

npx skills add mkosir/typescript-style-guide --skill discriminated-unions

설치 안전성

표준 패키지 또는 런타임 설치 경로

권한 범위

filesystem or document access, network or browser access

Agent 결과

아직 Agent 결과 데이터가 없습니다

문서

README/SKILL.md 맥락이 충분합니다

위험 요약

낮은 메타데이터 위험

  • Quality score needs review

설치 준비 상태

설치 경로 사용 가능

  • 설치 경로를 사용할 수 있습니다
  • 저장소 근거를 사용할 수 있습니다
  • 라이선스가 명시되었습니다
  • 아직 Agent 검증 결과 근거가 없습니다

Agent 읽기용 메타데이터

이 스킬의 기계 판독형 의사결정 데이터.

이 블록 또는 포함된 JSON을 사용해 Agent가 이 스킬을 설치할지, 대안을 고를지, 먼저 사람의 검토를 요청할지 판단할 수 있습니다.

JSON 열기

적합한 작업

  • 코딩 Agent 워크플로
  • Claude Code 팀
  • GitHub 채택 신호를 중시하는 팀
  • Inspect source files

적합한 Agent

CodexClaude CodeCursorOpenAgentSkill CLICLI

설치 결정

명령어
npx skills add mkosir/typescript-style-guide --skill discriminated-unions
정책
검토
사람 검토

신뢰와 위험

신뢰
77/100
감사
85/100
위험 수준
안전하게 시도 가능

결과 루프

엔드포인트
/api/agent/outcome
이벤트 ID
resolve
결과
5

설치 명령어

npx skills add mkosir/typescript-style-guide --skill discriminated-unions

사용하지 말아야 할 경우

  • 벤더 지원 SLA가 필요한 팀
  • 내부 보안 검토가 없는 고규정 준수 환경
  • 현재 메타데이터에서 주요 위험 신호가 발견되지 않았습니다
  • Quality score needs review
  • Production credentials, payments, or irreversible account changes without explicit human review

Agent 안전 v2

69/100 · 설치 전 검토

검토됨검토

공개 메타데이터에 고위험 권한 힌트가 없으며 감사와 안전성 신호가 양호합니다.

감사 페이지를 검토한 뒤 샌드박스 워크플로에서 Agent 설치를 허용하세요.

API로 해결

중간

네트워크 접근

Skill은 원격 페이지, API, 저장소 또는 외부 서비스에 접근할 수 있습니다.

중간

파일 시스템 접근

Skill은 프로젝트 파일, 문서, 생성 산출물 또는 로컬 작업 공간 상태를 읽거나 쓸 수 있습니다.

  • Quality score needs review

설치 대상

Agent 워크플로에 이 스킬 설치

공개 설치 엔드포인트에서 명령어, 안전 체크리스트, 대상 프롬프트와 정규 링크를 가져옵니다.

skill install

OpenAgentSkill CLI

Resolve policy, run the source installer safely, and report a verified install receipt.

$ npx --yes https://github.com/Leon-Drq/openagentskill/releases/download/cli-v0.2.1/openagentskill-0.2.1.tgz install mkosir-discriminated-unions

Agent 해결 계획

설치 전에 Agent가 적합성을 검증하게 하세요.

Resolve API는 최우선 스킬, 대안, 안전 정책, 감사 메모, 설치 대상 및 Agent가 페이지를 스크래핑하지 않고 사용할 수 있는 프롬프트를 반환합니다.

텍스트 계획 열기

Agent가 확인할 항목

  • Resolve API에서 작업 적합도와 대안을 확인합니다.
  • 감사 점수, 신뢰 점수 및 안전 정책 경고를 확인합니다.
  • Codex, Claude Code, Cursor 또는 CLI의 설치 대상 호환성을 확인합니다.

프롬프트 복사

Task: Use discriminated-unions in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20discriminated-unions%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/mkosir-discriminated-unions/install
Install command: npx skills add mkosir/typescript-style-guide --skill discriminated-unions
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.

Agent 핸드오프

또 다른 디렉터리 페이지 대신 설치 경로를 Agent에게 제공합니다.

공개 설치 엔드포인트에서 명령어, 안전 체크리스트, 대상 프롬프트와 정규 링크를 가져옵니다.

설치 API 열기

Agent 프롬프트

Use discriminated-unions for this task. Review https://www.openagentskill.com/api/skills/mkosir-discriminated-unions/install, then install with: npx skills add mkosir/typescript-style-guide --skill discriminated-unions

Registry 메타데이터

자동 스킬 선택을 위한 Agent 읽기용 프로필.

Registry API를 통해 동일한 결정, 신뢰, 감사, 사용 사례, 설치 신호를 제공하므로 Agent가 UI를 스크래핑하지 않고도 순위를 매길 수 있습니다.

Manifest 열기

Agent 적합도

88/100

코딩 Agent

플랫폼

Claude Code

감사 보고서

안전하게 시도 가능 · 85/100

설치 준비 상태, 보안 메타데이터, 유지보수 및 채택 위험에 대한 기계 판독형 검토입니다.

감사 보고서 보기평가 보고서 보기

Agent 결정 패널

코딩 Agent용 우선 추천

우선 후보로 사용하되, 자신의 Agent 환경에서 README와 설치 경로를 검증하세요.

88
준비 상태
채택
단계

스택 내 역할

우선 추천

주요 적합도

코딩 Agent

신뢰 라벨

프로덕션 준비 완료

설치 경로

명령어 준비됨

사용 시점

  • 코딩 Agent 워크플로
  • Claude Code 팀
  • GitHub 채택 신호를 중시하는 팀

근거

  • GitHub 스타 780
  • 최근 저장소 활동
  • 설치 명령 또는 GitHub 저장소를 사용할 수 있습니다
  • 품질 프로필 76/100
  • OpenAgentSkill 상호작용 2건

먼저 검토

  • 현재 메타데이터에서 주요 위험 신호가 발견되지 않았습니다

구현 경로

  1. 1샌드박스 Agent에 설치하고 코딩 Agent 작업을 처음부터 끝까지 한 번 실행하세요.
  2. 2Compare output quality, latency, and failure behavior against at least one alternative.
  3. 3Promote it into production only after reviewing repository permissions, license, and maintenance signals.

신뢰 프로필

검토 후 설치

좋은 후보 신호이지만 Agent는 실행 전에 감사 메모, 설치 정책 및 결과 근거를 검토해야 합니다.

77
OpenAgentSkill 신뢰 점수

GitHub 채택도

정보

GitHub 스타 780

스타/포크 활동

정보

스타 780, 포크 37; 현재 메타데이터에서 이슈 활동을 확인할 수 없습니다

최근 유지보수

통과

오늘 푸시됨

라이선스 명확성

통과

MIT

긍정 신호

  • AI 검토 승인됨
  • 설치 경로를 사용할 수 있습니다
  • 저장소 근거를 사용할 수 있습니다
  • 최근 유지보수된 저장소
  • 의미 있는 GitHub 채택 신호
  • 설치 명령에서 뚜렷한 고위험 패턴이 발견되지 않았습니다
  • 결과 루프는 준비되었지만 첫 실제 Agent 실행이 필요합니다

설치 전 검토

  • Quality score needs review
  • 아직 실제 Agent 결과 보고서가 없습니다
  • 무인 설치 전에 사람 검토가 필요합니다

권장 작업

사람 검토 또는 샌드박스 검증 후 우선 후보로 사용하세요.

품질 프로필

강함 Agent 워크플로용 후보

프로덕션 워크플로 후보군에 넣을 만한 탄탄한 선택입니다.

76
GitHub 스타
780
최신성
오늘
설치 준비됨
라이선스
MIT

워크플로 적합도

이 스킬을 사용할 시나리오

워크플로 적합도

완전한 워크플로에 추가

대안 후보

설치 전 비교

이 작업에 적합할 수 있는 유사 스킬입니다.

모두 비교

개요

--- name: discriminated-unions description: Apply, review, and explain discriminated unions in TypeScript. Use automatically for tasks involving mutually exclusive variants, invalid state prevention, exhaustiveness checking, variant-specific object properties, application state, function arguments, or React props. ---

# Discriminated Unions

Apply the TypeScript Style Guide's discriminated-union conventions in the context of the current task.

## Workflow

1. Inspect the consuming repository's conventions and configuration. 2. Let explicit repository conventions take precedence over this opinionated guidance. 3. Apply, review, or explain only the guidance relevant to the task. 4. State important tradeoffs when the appropriate model depends on context or judgment.

## Boundaries

- Use discriminated unions for mutually exclusive variants that require different data. - Do not force a discriminated union when properties may independently be absent or when only a value changes. - Keep TypeScript and ESLint responsible for checks they can enforce automatically. - Do not introduce unrelated TypeScript Style Guide conventions merely because this skill is active.

<!-- BEGIN CANONICAL GUIDE CONTENT -->

## Discriminated Unions {#discriminated-unions}

If there's only one TypeScript feature to choose from, embrace discriminated unions.

A discriminated union is a union of object types that share a property with distinct literal values. Checking that property narrows the value to the matching variant.

Use discriminated unions when variants are mutually exclusive and each variant requires different data. Keep properties optional when they may independently be absent, and use a literal union when only the value changes.

Discriminated unions are a powerful concept to model complex data structures and improve type safety, leading to clearer and less error-prone code. You may encounter discriminated unions under different names, such as tagged unions or sum types, in languages such as C, Haskell, and Rust (in conjunction with pattern-matching).

Advantages of discriminated unions:

- As mentioned in [Required & Optional Object Properties](#required--optional-object-properties), [Function Arguments](#function-arguments), and [Props as Discriminated Type](#props-as-discriminated-type), discriminated unions replace optional properties that depend on a variant with required properties for that variant, reducing complexity. - Exhaustiveness Checking - The configured ESLint rule reports when a switch does not handle every variant of a discriminated union.

<Rule href="https://typescript-eslint.io/rules/switch-exhaustiveness-check/">{`"@typescript-eslint/switch-exhaustiveness-check": "error"`}</Rule>

```ts type Circle = { kind: 'circle'; radius: number }; type Square = { kind: 'square'; size: number }; type Triangle = { kind: 'triangle'; base: number; height: number };

// Create a discriminated union 'Shape', with the 'kind' property to discriminate the type of object. type Shape = Circle | Square | Triangle;

const calculateArea = (shape: Shape) => { // ESLint reports that the switch is missing the 'triangle' case switch (shape.kind) { case 'circle': return Math.PI * shape.radius ** 2; case 'square': return shape.size ** 2; } }; ```

- Avoid code complexity introduced by multiple [boolean flags](#application-state) that represent mutually exclusive states. - Clear code intent, as it becomes easier to read and understand by explicitly indicating the possible cases for a given type. - TypeScript can narrow down union types, ensuring code correctness at compile time. - Discriminated unions make refactoring and maintenance easier by providing a centralized definition of related types. When adding or modifying types within the union, the compiler reports any inconsistencies throughout the codebase. - IDEs can leverage discriminated unions to provide better autocompletion and type inference.

### Practical Applications

#### Required & Optional Object Properties {#required--optional-object-properties}

**Strive to have the majority of object properties required and use optional properties sparingly.**

This approach reflects designing type-safe and maintainable code:

- Clarity and Predictability - Required properties make it explicit which data is always expected. This reduces ambiguity for developers using or consuming the object, as they know exactly what must be present. - Type Safety - When properties are required, TypeScript can enforce their presence and catch missing properties during type checking. - Avoids Overuse of Optional Chaining - If too many properties are optional, it often leads to extensive use of optional chaining (`?.`) to handle potential undefined values. This clutters the code and obscures its intent.

Use optional properties when values may independently be absent. When property presence depends on the object's variant, use a **discriminated union type**.

```ts // ❌ Avoid optional properties when their presence depends on the variant type User = { id?: number; email?: string; dashboardAccess?: boolean; adminPermissions?: ReadonlyArray<string>; subscriptionPlan?: 'free' | 'pro' | 'premium'; rewardsPoints?: number; temporaryToken?: string; };

// ✅ Use a discriminated union so each variant has only its required properties type AdminUser = { role: 'admin'; id: number; email: string; dashboardAccess: boolean; adminPermissions: ReadonlyArray<string>; };

type RegularUser = { role: 'regular'; id: number; email: string; subscriptionPlan: 'free' | 'pro' | 'premium'; rewardsPoints: number; };

type GuestUser = { role: 'guest'; temporaryToken: string; };

// Discriminated union type 'User' ensures clear intent with no optional properties type User = AdminUser | RegularUser | GuestUser;

const regularUser: User = { role: 'regular', id: 212, email: 'lea@user.com', subscriptionPlan: 'pro', rewardsPoints: 1500, dashboardAccess: false, // Error: 'dashboardAccess' property does not exist }; ```

#### Application State

When application states require different data, model the state and its data together with a discriminated union. This prevents invalid combinations, such as loading while holding both data and an error.

```ts // ❌ Boolean flags and optional properties allow invalid state combinations type RequestState = { isLoading: boolean; data?: Products; error?: string; };

// ✅ Each state contains only the data valid for that state type RequestState = | { status: 'idle' } | { status: 'loading' } | { status: 'success'; data: Products } | { status: 'error'; error: string }; ```

#### Function Arguments

When a function accepts mutually exclusive variants that require different properties, use a **discriminated union type**. This decreases complexity in the function's API and ensures that only the required properties are passed for each use case.

```ts // ❌ Avoid optional properties that allow invalid combinations in the function API type NotificationParams = { channel: 'email' | 'sms'; email?: string; phoneNumber?: string; subject?: string; message: string; };

// ✅ Use a discriminated union so each variant requires only its valid properties type EmailNotificationParams = { channel: 'email'; email: string; subject: string; message: string; };

type SmsNotificationParams = { channel: 'sms'; phoneNumber: string; message: string; };

type NotificationParams = EmailNotificationParams | SmsNotificationParams;

export const sendNotification = (params: NotificationParams) => { switch (params.channel) { case 'email': return sendEmail(params.email, params.subject, params.message); case 'sms': return sendSms(params.phoneNumber, params.message); } }; ```

#### React Props

##### Required & Optional Props

**Strive to have the majority of props required and use optional props sparingly.**

Especially when creating a new component for its first or single use case, the majority of props should be required. When the component starts covering more use cases, introduce optional props only for values that may genuinely be absent across those use cases. There are potential exceptions where a component API needs to implement optional props from the start (e.g. shared components covering multiple use cases, UI design system components - button `isDisabled` etc.)

If a component or hook becomes too complex, it should probably be broken into smaller pieces. An exaggerated example: implementing 10 React components with 5 required props each is better than implementing one "can do it all" component that accepts 50 optional props.

##### Props as Discriminated Type

When component variants require different props, use a **discriminated union type**. This approach reduces complexity in the component API and ensures that only the required props are passed for each variant.

```tsx // ❌ Avoid optional props that allow invalid combinations in the component API type AvatarProps = { variant: 'image' | 'initials'; src?: string; alt?: string; initials?: string; };

// ✅ Use a discriminated union so each variant requires only its valid props type ImageAvatarProps = { variant: 'image'; src: string; alt: string; };

type InitialsAvatarProps = { variant: 'initials'; initials: string; };

type AvatarProps = ImageAvatarProps | InitialsAvatarProps;

export const Avatar = (props: AvatarProps) => { switch (props.variant) { case 'image': return <img src={props.src} alt={props.alt} />; case 'initials': return <span>{props.initials}</span>; } }; ```

<!-- END CANONICAL GUIDE CONTENT -->

기술 세부 사항

버전
1.0.0
라이선스
MIT
최근 업데이트
2026년 8월 23일
게시일
2026년 8월 23일

결정 스냅샷

우선 추천

88
준비됨
채택
단계

GitHub 스타 780

감사

설치 검토

설치 및 채택 검토

85
안전하게 시도 가능
보안
86/100
유지보수
100/100
설치
92/100
전체 감사 열기평가 보고서 보기

Agent 검증 증거

Agent 검증 증거

Resolve, 검토, 설치 및 한 번의 제한된 실행 후 결과 보고서입니다.

0
검증됨
Needs first agent run자동 설치: 먼저 검토최근: 알 수 없음
성공률
최근 실패
결과
0
출력 품질
실패
0
관련 없음
0
설치
0
위험 차단
0
설정 필요
0
프로덕션
0

아직 Agent 결과 데이터가 없습니다. 첫 실행은 /api/agent/outcome을 통해 성공, 설정 필요, 위험 차단, 실패 또는 비관련 결과를 보고할 수 있습니다.

설치

Agent 워크플로에 추가

무료 오픈 소스. 프로덕션 Agent에 설치하기 전에 보고서를 검토하세요.

성장 루프

공유 키트

X

discriminated-unions용 시나리오 기반 초안입니다. X에 수동으로 게시할 수 있습니다.

큐레이터 노트
A practical pick for source-backed research:

discriminated-unions: Apply, review, and explain discriminated unions in TypeScript. Use automatically for tasks involving mutually exclusive var...

780 stars

https://www.openagentskill.com/skills/mkosir-discriminated-unions?ref=x
X 초안 열기
선택 사항: 설치 명령이 포함된 답글
Listing + install path for discriminated-unions:
https://www.openagentskill.com/skills/mkosir-discriminated-unions?ref=x

Install: npx skills add mkosir/typescript-style-guide --skill discriminated-unions

등록 출처

Registry 색인

소유권 주장 가능

이 등록은 공개 소스에서 색인되었으며 유지보수자 소유권 주장이 승인될 때까지 공식으로 표시되지 않습니다.

제작자
mkosir
색인 주체
OpenAgentSkill 커뮤니티 인덱스

귀속은 공개 저장소 또는 제작자 프로필에 연결됩니다. 제작자는 등록을 주장하여 소유권 신호를 업데이트할 수 있습니다.

이 스킬 소유권 주장

소유자 소유권 주장

이 스킬 등록 소유권 주장

이 Registry 색인 등록은 mkosir에게 귀속되어 있지만 아직 공식으로 표시되지 않았습니다. 소유권을 주장하면 확인된 소유자 신호가 추가되어 이후 출시, 설치 및 감사 업데이트를 더 신뢰할 수 있습니다.

크리에이터 백링크 키트

README에 증거 배지 추가

개발자가 저장소를 평가하는 위치에 정규 등록, 현재 신뢰 및 감사 신호, 실제 Agent-Proven 증거를 표시합니다.

[![Listed on OpenAgentSkill](https://www.openagentskill.com/api/badge/mkosir-discriminated-unions?metric=listed&label=Listed)](https://www.openagentskill.com/skills/mkosir-discriminated-unions)
[![OpenAgentSkill Trust](https://www.openagentskill.com/api/badge/mkosir-discriminated-unions?metric=trust&label=Trust)](https://www.openagentskill.com/skills/mkosir-discriminated-unions)
[![OpenAgentSkill Audit](https://www.openagentskill.com/api/badge/mkosir-discriminated-unions?metric=audit&label=Audit)](https://www.openagentskill.com/skills/mkosir-discriminated-unions/audit)
[![Agent Proven](https://www.openagentskill.com/api/badge/mkosir-discriminated-unions?metric=proven&label=Agent%20Proven)](https://www.openagentskill.com/skills/mkosir-discriminated-unions)

작성자

M

mkosir

@mkosir

플랫폼 적합도

상태 신호

GitHub 스타
780
품질 점수
44/100
최근 GitHub 푸시
2026년 8월 23일
프레임워크 힌트
알 수 없음
OpenAgentSkill 조회수
2
설치 명령 복사
0
외부 클릭
0

커뮤니티 신호

이 스킬이 Agent 워크플로에 유용한지 알려 주세요. 집계된 피드백은 시간이 지날수록 순위를 개선합니다.

신뢰와 안전

검토 후 설치

77
  • GitHub 채택도GitHub 스타 780정보
  • 스타/포크 활동스타 780, 포크 37; 현재 메타데이터에서 이슈 활동을 확인할 수 없습니다정보
  • 최근 유지보수오늘 푸시됨통과
  • 라이선스 명확성MIT통과
  • README/SKILL.md 완성도메타데이터에 충분한 사용 및 워크플로 맥락이 포함되어 있습니다통과
  • 의존성/런타임 위험network or browser surface통과