agentsclimarketplace

Effect errors schema

Skill theseus-run/theseus/.agents/skills/effect-errors-schema

the harness rebuilds itself — agents rewrite agents, skills replace skills.

Install
npx -y skills add theseus-run/theseus --skill effect-errors-schema

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when modeling Effect errors, defects, Cause handling, Schema contracts, Schema.TaggedErrorClass, boundary decoding/encoding, RPC/tool/persistence validation, and typed failure recovery in Theseus.

SKILL.md

4.0 KB, as published. Nobody here has run it

Effect Errors And Schema

Use this skill for typed failures, schema contracts, and boundary normalization.

Error Model

Use explicit domain errors. Expected failures stay in the Effect error channel. Defects are bugs, thrown exceptions, rejected promise defects, interrupts, or violated invariants.

Recovery is for expected external uncertainty: user input, network, filesystem, subprocesses, model providers, persistence, environment, and other foreign systems. Controlled internal protocol violations are defects.

Rules:

  • Use Data.TaggedError for plain runtime/domain errors.
  • Use Schema.TaggedErrorClass when the error must be schema-backed or serialized.
  • Use Effect.catchTag / Effect.catchTags for known tagged failures.
  • Use Effect.catch for all typed failures only when deliberately collapsing the union.
  • Use Effect.catchCause when interrupts or defects must be inspected.
  • Use Cause.hasInterruptsOnly(cause) to distinguish pure interruption from failure.
  • Use Effect.catchDefect only for defect conversion at a boundary.
  • Use Effect.die, thrown invariant errors, or equivalent hard failure for impossible internal states when types failed to prevent them.
  • Do not use try/catch inside Effect.gen to catch Effect failures; they are not thrown.
  • Do not throw expected failures.
  • Do not recover from unsupported internal variants, impossible state transitions, or violated contracts with defaults, dropped events, or generic fallbacks.
  • Do not erase error unions with any, unknown, or generic wrappers.

Boundary Pattern

At every external boundary, normalize once:

  • raw input -> Schema decode -> typed input
  • foreign exception -> tagged typed failure
  • domain failure -> explicit response or presentation
  • defect -> logged/crashed/interrupted according to boundary policy

Examples of boundaries: tool calls, RPC handlers, SQLite calls, filesystem, subprocesses, model provider calls, WebSocket messages.

Inside the domain, keep typed values and typed failures. Do not repeatedly decode or stringify internal data. At important internal seams, validate or assert invariants and fail loudly when they are violated.

Schema

Use Schema at external boundaries: tool inputs/outputs, RPC, persistence serialization, provider payloads, and config.

import { Schema } from "effect"

export const UserId = Schema.String.pipe(Schema.brand("UserId"))
export type UserId = Schema.Schema.Type<typeof UserId>

export class RpcError extends Schema.TaggedErrorClass<RpcError>()("RpcError", {
  code: Schema.String,
  message: Schema.String,
}) {}

Rules:

  • Use Schema.Struct, Schema.Union, Schema.Literal, and Schema.Literals for wire contracts.
  • Use Schema.optional(...) for optional fields in this repo.
  • Use branded schemas for IDs that cross service/package boundaries.
  • Decode unknown inputs with Schema.decodeUnknownEffect(schema)(raw) when failures should stay typed.
  • Keep schemas near the boundary they protect unless they are shared API contracts.
  • Put JSON parse/stringify for protocol, provider, RPC, and persistence data behind schema-backed boundary helpers when practical. Raw JSON is acceptable for tests, debug output, or truly opaque passthrough data.
  • Keep raw Record<string, unknown> at ingress or opaque passthrough boundaries. Domain code should receive decoded schemas or explicit extension points.
  • Prefer narrow schemas for commands and events. Avoid Schema.Unknown except for explicitly open extension points.

Checks

  • Is the failure expected and recoverable, or is it a defect?
  • Does the boundary serialize or persist this error?
  • Are parse failures kept typed until the boundary handles them?
  • Are _tag values globally safe where pattern matching crosses modules?
  • Is this recovery handling external uncertainty, or is it hiding a broken internal contract?

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.