Token导航 LogoToken导航

Agent Skill · 前端设计

effect-error-handling(效果错误处理)

effect-error-handling 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

effect-error-handling 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 5,315。

总安装 698周安装 30GitHub Stars 142下载 245核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:effect-error-handling(效果错误处理)
来源仓库:https://github.com/thebushidocollective/han
仓库路径:skills/effect-error-handling
安装命令:
npx skills add https://github.com/thebushidocollective/han --skill effect-error-handling
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/thebushidocollective/han --skill effect-error-handling

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

effect-error-handling 区分预期错误与缺陷,提供类型安全的错误恢复与转换机制。适用于需要精细控制错误流的 Effect 应用开发。通过 GitHub 安装,使用 npx skills add 命令添加指定仓库的 skill/effect-error-handling 路径。

禁止使用 catchAll 处理 never 类型错误或全局 Error 对象。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/effect-error-handling

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/thebushidocollective/han --skill effect-error-…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

effect-error-handling 怎么安装?

在终端执行 npx skills add https://github.com/thebushidocollective/han --skill effect-error-handling。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

effect-error-handling 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

effect-error-handling 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

effect-error-handling 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

effect-error-handling 用的人多吗?

公开数据是累计安装 698 次,近一周安装 30 次,下载 245 次,GitHub 142 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

effect-error-handling 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
effect-error-handling

效果错误处理 · 本页

698142需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Effect Error Handling

Master type-safe error handling in Effect applications. This skill covers expected errors, error recovery, selective error handling, and error transformations using Effect's error management operators.

Expected Errors vs Defects

Effect distinguishes between two types of failures:

  • Expected Errors (E channel): Recoverable errors tracked in the type system
  • Defects: Unexpected failures (bugs, programming errors)
import { Effect } from "effect"

// Expected error - tracked in type
interface ValidationError {
  _tag: "ValidationError"
  field: string
  message: string
}

const validateEmail = (email: string): Effect.Effect<string, ValidationError, never> => {
  if (!email.includes("@")) {
    return Effect.fail({
      _tag: "ValidationError",
      field: "email",
      message: "Invalid email format"
    })
  }
  return Effect.succeed(email)
}

// Defect - throws, becomes unexpected failure
const riskyOperation = Effect.sync(() => {
  throw new Error("Unexpected error") // This is a defect
})

// Proper way - expected error
const safeOperation = Effect.try({
  try: () => {
    // Code that might throw
    return riskyParse(data)
  },
  catch: (error) => ({
    _tag: "ParseError",
    message: String(error)
  })
})

Tagged Error Types

Use tagged unions for error types to enable pattern matching:

import { Effect } from "effect"

// Define tagged error types
interface NotFoundError {
  _tag: "NotFoundError"
  id: string
}

interface UnauthorizedError {
  _tag: "UnauthorizedError"
  userId: string
}

interface NetworkError {
  _tag: "NetworkError"
  message: string
}

type AppError = NotFoundError | UnauthorizedError | NetworkError

// Functions returning typed errors
const fetchUser = (id: string): Effect.Effect<User, NotFoundError | NetworkError, never> => {
  // Implementation
}

const authenticate = (token: string): Effect.Effect<User, UnauthorizedError | NetworkError, never> => {
  // Implementation
}

Catching All Errors

Effect.catchAll - Recover from Any Error

Catches all expected errors and provides fallback:

import { Effect } from "effect"

const program = Effect.gen(function* () {
  const user = yield* fetchUser("123")
  return user
}).pipe(
  Effect.catchAll((error) =>
    Effect.succeed({ id: "default", name: "Guest" })
  )
)
// Effect<User, never, never> - Error channel is now never

// With error inspection
const programWithLogging = Effect.gen(function* () {
  const user = yield* fetchUser("123")
  return user
}).pipe(
  Effect.catchAll((error) => {
    console.error("Error occurred:", error)
    return Effect.succeed(defaultUser)
  })
)

// Fallback to another effect
const programWithFallback = pipe(
  fetchUser("123"),
  Effect.catchAll(() => fetchUserFromCache("123"))
)

Selective Error Handling

Effect.catchTag - Handle Specific Error Types

Catches errors by their _tag field:

import { Effect, pipe } from "effect"

const program = pipe(
  fetchUser("123"),
  Effect.catchTag("NotFoundError", (error) =>
    Effect.succeed({ id: error.id, name: "Not Found" })
  )
)
// Still can fail with NetworkError

// Handling multiple tags
const program2 = pipe(
  authenticatedRequest(),
  Effect.catchTag("UnauthorizedError", (error) =>
    Effect.fail({ _tag: "LoginRequired" })
  ),
  Effect.catchTag("NetworkError", (error) =>
    retryRequest()
  )
)

// Using Effect.gen with early return
const program3 = Effect.gen(function* () {
  const result = yield* riskyOperation().pipe(
    Effect.catchTag("TemporaryError", () =>
      Effect.succeed(null)
    )
  )
  return result
})

Effect.catchTags - Handle Multiple Error Types

import { Effect, pipe } from "effect"

const program = pipe(
  complexOperation(),
  Effect.catchTags({
    NotFoundError: (error) =>
      Effect.succeed(defaultValue),
    UnauthorizedError: (error) =>
      Effect.fail({ _tag: "LoginRequired" }),
    NetworkError: (error) =>
      retryOperation()
  })
)

// With different recovery strategies
const programWithStrategies = pipe(
  processPayment(amount),
  Effect.catchTags({
    InsufficientFunds: (error) =>
      Effect.fail({ _tag: "PaymentDeclined", reason: "insufficient-funds" }),
    NetworkError: () =>
      retryPayment(amount),
    ValidationError: (error) =>
      Effect.fail({ _tag: "InvalidPayment", field: error.field })
  })
)

Effect.catchIf - Conditional Error Handling

Catches errors that match a predicate:

import { Effect, pipe } from "effect"

const isRetryable = (error: AppError): boolean => {
  return error._tag === "NetworkError" || error._tag === "TimeoutError"
}

const program = pipe(
  fetchData(),
  Effect.catchIf(isRetryable, (error) =>
    retryFetchData()
  )
)

// With type narrowing
const program2 = pipe(
  operation(),
  Effect.catchIf(
    (error): error is NetworkError => error._tag === "NetworkError",
    (error) => {
      // TypeScript knows error is NetworkError here
      console.log("Network error:", error.message)
      return retry()
    }
  )
)

Effect.catchSome - Partial Error Handling

Catches errors and optionally handles them:

import { Effect, Option, pipe } from "effect"

const program = pipe(
  fetchUser("123"),
  Effect.catchSome((error) => {
    if (error._tag === "NotFoundError") {
      return Option.some(Effect.succeed(guestUser))
    }
    return Option.none() // Don't handle, propagate error
  })
)

// Complex decision logic
const programWithDecision = pipe(
  processRequest(request),
  Effect.catchSome((error) => {
    if (error._tag === "RateLimitError" && error.retryAfter < 1000) {
      return Option.some(
        Effect.sleep(error.retryAfter).pipe(
          Effect.andThen(processRequest(request))
        )
      )
    }
    return Option.none()
  })
)

Converting Errors

Effect.either - Convert to Either<Success, Error>

Transforms an effect into one that cannot fail, wrapping result in Either:

import { Effect, Either } from "effect"

const program = Effect.gen(function* () {
  const result = yield* fetchUser("123").pipe(Effect.either)

  if (Either.isLeft(result)) {
    // Handle error
    console.error("Error:", result.left)
    return null
  } else {
    // Handle success
    return result.right
  }
})
// Effect<User | null, never, never>

// Pattern matching on Either
const program2 = pipe(
  fetchUser("123"),
  Effect.either,
  Effect.map(
    Either.match({
      onLeft: (error) => ({ success: false, error }),
      onRight: (user) => ({ success: true, data: user })
    })
  )
)

Effect.option - Convert to Option

Converts failures to None, success to Some:

import { Effect, Option } from "effect"

const program = Effect.gen(function* () {
  const maybeUser = yield* fetchUser("123").pipe(Effect.option)

  if (Option.isNone(maybeUser)) {
    return guestUser
  } else {
    return maybeUser.value
  }
})
// Effect<User, never, never>

// Using Option.match
const program2 = pipe(
  fetchUser("123"),
  Effect.option,
  Effect.map(
    Option.match({
      onNone: () => "No user found",
      onSome: (user) => `Found: ${user.name}`
    })
  )
)

Error Transformation

Effect.mapError - Transform Error Types

import { Effect, pipe } from "effect"

interface DbError {
  _tag: "DbError"
  code: string
  message: string
}

interface AppError {
  _tag: "AppError"
  message: string
  context: string
}

const program = pipe(
  queryDatabase(),
  Effect.mapError((dbError: DbError): AppError => ({
    _tag: "AppError",
    message: dbError.message,
    context: `Database operation failed: ${dbError.code}`
  }))
)

// Enriching errors with context
const enrichError = <E extends { message: string }>(
  context: string
) => (error: E) => ({
  ...error,
  message: `${context}: ${error.message}`
})

const programWithContext = pipe(
  fetchData(),
  Effect.mapError(enrichError("Failed to fetch user data"))
)

Effect.tapError - Side Effects on Error

Perform side effects when an error occurs without changing it:

import { Effect, pipe } from "effect"

const program = pipe(
  processPayment(amount),
  Effect.tapError((error) =>
    Effect.sync(() => {
      console.error("Payment failed:", error)
      logToMonitoring(error)
    })
  ),
  Effect.tapError((error) =>
    sendErrorNotification(error)
  )
)
// Error still propagates after taps

Retry and Fallback Patterns

Effect.orElse - Fallback Effect

Provide alternative effect on failure:

import { Effect, pipe } from "effect"

const program = pipe(
  fetchFromPrimarySource(),
  Effect.orElse(() => fetchFromSecondarySource())
)

// With error-specific fallbacks
const programWithCheck = pipe(
  fetchData(),
  Effect.orElse((error) => {
    if (error._tag === "NetworkError") {
      return fetchFromCache()
    }
    return Effect.fail(error)
  })
)

// Multiple fallbacks
const programWithMultipleFallbacks = pipe(
  fetchFromPrimary(),
  Effect.orElse(() => fetchFromSecondary()),
  Effect.orElse(() => fetchFromTertiary()),
  Effect.orElse(() => Effect.succeed(defaultData))
)

Effect.retry - Retry on Failure

import { Effect, Schedule, pipe } from "effect"

// Retry with schedule
const program = pipe(
  fetchData(),
  Effect.retry(Schedule.recurs(3)) // Retry up to 3 times
)

// Exponential backoff
const programWithBackoff = pipe(
  fetchData(),
  Effect.retry(
    Schedule.exponential("100 millis", 2.0) // 100ms, 200ms, 400ms, ...
  )
)

// Conditional retry
const programConditionalRetry = pipe(
  fetchData(),
  Effect.retry({
    while: (error) => error._tag === "NetworkError",
    schedule: Schedule.recurs(5)
  })
)

Combining Error Handlers

Chaining Multiple Handlers

import { Effect, pipe } from "effect"

const program = pipe(
  complexOperation(),
  Effect.catchTag("NotFoundError", () =>
    Effect.succeed(defaultValue)
  ),
  Effect.catchTag("NetworkError", () =>
    retryOperation()
  ),
  Effect.catchTag("UnauthorizedError", () =>
    Effect.fail({ _tag: "LoginRequired" })
  ),
  Effect.catchAll((unknownError) =>
    Effect.sync(() => {
      console.error("Unhandled error:", unknownError)
      return fallbackValue
    })
  )
)

Error Accumulation

import { Effect, Array } from "effect"

interface ValidationError {
  _tag: "ValidationError"
  errors: string[]
}

const validateAll = (fields: string[]) =>
  Effect.gen(function* () {
    const results = yield* Effect.all(
      fields.map(validateField),
      { mode: "either" } // Don't short-circuit on first error
    )

    const errors = results.filter(Either.isLeft)
    if (errors.length > 0) {
      return yield* Effect.fail({
        _tag: "ValidationError",
        errors: errors.map(e => e.left.message)
      })
    }

    return results.map(r => r.right)
  })

Handling Defects

Effect.catchAllCause - Handle Both Errors and Defects

import { Effect, Cause, Exit, pipe } from "effect"

const program = pipe(
  riskyOperation(),
  Effect.catchAllCause((cause) => {
    if (Cause.isFailure(cause)) {
      // Expected error
      const error = Cause.failureOption(cause)
      return handleExpectedError(error)
    } else if (Cause.isDie(cause)) {
      // Defect (unexpected error)
      const defect = Cause.dieOption(cause)
      return handleDefect(defect)
    } else {
      // Interruption
      return Effect.succeed(defaultValue)
    }
  })
)

Effect.sandbox - Expose Defects as Errors

Converts defects into the error channel for handling:

import { Effect, Cause, pipe } from "effect"

const program = pipe(
  riskyOperation(),
  Effect.sandbox,
  Effect.catchAll((cause) => {
    console.error("Failure cause:", cause)
    return Effect.succeed(fallbackValue)
  })
)

Best Practices

  1. Use Tagged Error Types: Always tag errors with _tag for catchTag.
  2. Keep Error Types Specific: Don't use generic Error. Define specific error types for each failure mode.
  3. Handle Errors Close to Source: Catch errors where you have enough context to handle them properly.
  4. Use catchTag Over catchAll: Prefer specific error handling to blanket catching.
  5. Convert at Boundaries: Use either/option when interfacing with code that doesn't expect errors.
  6. Log Before Catching: Use tapError to log before handling errors.
  7. Don't Swallow Errors: Always handle errors meaningfully or propagate them.
  8. Use Retry Strategically: Only retry transient failures, not all errors.
  9. Enrich Errors with Context: Add context to errors as they propagate up.
  10. Document Error Types: Clearly document what errors each function can produce.

Common Pitfalls

  1. Using catchAll Everywhere: Over-using catchAll hides error types. Use catchTag.
  2. Not Tagging Errors: Without tags, you can't use catchTag effectively.
  3. Swallowing Errors: Catching errors and returning success without proper handling.
  4. Infinite Retry: Not limiting retries or checking error types before retrying.
  5. Losing Error Information: Transforming errors without preserving important details.
  6. Not Handling Defects: Forgetting that some operations can throw unexpectedly.
  7. Wrong Error Boundaries: Catching errors too early or too late in the pipeline.
  8. Type Widening: Losing specific error types by combining with catchAll too early.
  9. Ignoring Error Channel: Not checking the E type parameter when composing effects.
  10. Not Testing Error Paths: Only testing happy paths, not failure scenarios.

When to Use This Skill

Use effect-error-handling when you need to:

  • Handle expected errors in a type-safe manner
  • Recover from failures with fallback logic
  • Implement retry strategies for transient failures
  • Transform errors between different layers
  • Log errors without stopping execution
  • Implement error boundaries in applications
  • Handle specific error types differently
  • Convert errors to Option or Either
  • Accumulate validation errors
  • Build resilient error recovery systems

Resources

Official Documentation

Related Skills

  • effect-core-patterns - Basic Effect operations
  • effect-testing - Testing error scenarios

平台分布

Codex

34.76%
按下载量换算85

Claude

28.85%
按下载量换算71

Cursor

19.22%
按下载量换算47

Gemini CLI

10.02%
按下载量换算25

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills