effect-errors-schema
Skill1 starsChanged 6 months agoMITView on GitHub
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.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-self-checkSkill
- biome-grit-rulesSkill
- biome-toolingSkill
- bun-testSkill
- bun-workspaceSkill
- cleanup-auditSkill
- code-reviewSkill
- dispatch-satelliteSkill
- docs-managementSkill
- docs-readingSkill
- effect-concurrency-lifecycleSkill
- effect-observability-timeSkill
- effect-services-layersSkill
- effect-testing-runtimeSkill
- effect-v4Skill
- jsx-md-authoringSkill
- monorepo-maintenanceSkill
- refactoring-disciplineSkill
- roadmap-managementSkill
- runtime-engineSkill
- server-runtimeSkill
- testing-patternsSkill
- theseus-designSkill
- tool-authoringSkill
- typescript-strictSkill
- ui-layout-disciplineSkill
- theseus-designSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. About 0 are common, 8 are distinctive, and 14 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
14
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill for typed failures, schema contracts, and boundary normalization.
- Distinctive: line 12
Use explicit domain errors.
- Very specific: line 18
Use Data.TaggedError for plain runtime/domain errors.
- Very specific: line 19
Use Schema.TaggedErrorClass when the error must be schema-backed or serialized.
- Very specific: line 20
Use Effect.catchTag / Effect.catchTags for known tagged failures.
- Very specific: line 21
Use Effect.catch for all typed failures only when deliberately collapsing the union.
- Very specific: line 22
Use Effect.catchCause when interrupts or defects must be inspected.
- Very specific: line 23
Use Cause.hasInterruptsOnly(cause) to distinguish pure interruption from failure.
- Very specific: line 24
Use Effect.catchDefect only for defect conversion at a boundary.
- Very specific: line 25
Use Effect.die, thrown invariant errors, or equivalent hard failure for impossible internal states when types failed to prevent them.
- Very specific: line 26
Do not use try/catch inside Effect.gen to catch Effect failures.
- Distinctive: line 27
Do not throw expected failures.
- Distinctive: line 28
Do not recover from unsupported internal variants, impossible state transitions, or violated contracts with defaults, dropped events, or …
- Very specific: line 29
Do not erase error unions with any, unknown, or generic wrappers.
- Distinctive: line 46
Use Schema at external boundaries: tool inputs/outputs, RPC, persistence serialization, provider payloads, and config.
- Very specific: line 62
Use Schema.Struct, Schema.Union, Schema.Literal, and Schema.Literals for wire contracts.
- Very specific: line 63
Use Schema.optional(...) for optional fields in this repo.
- Distinctive: line 64
Use branded schemas for IDs that cross service/package boundaries.
- Distinctive: line 66
Keep schemas near the boundary they protect unless they are shared API contracts.
- Distinctive: line 67
Put JSON parse/stringify for protocol, provider, RPC, and persistence data behind schema-backed boundary helpers when practical.
- Very specific: line 68
Keep raw Record<string, unknown> at ingress or opaque passthrough boundaries.
- Very specific: line 69
Prefer narrow schemas for commands and events.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.TaggedErrorfor plain runtime/domain errors. - Use
Schema.TaggedErrorClasswhen the error must be schema-backed or serialized. - Use
Effect.catchTag/Effect.catchTagsfor known tagged failures. - Use
Effect.catchfor all typed failures only when deliberately collapsing the union. - Use
Effect.catchCausewhen interrupts or defects must be inspected. - Use
Cause.hasInterruptsOnly(cause)to distinguish pure interruption from failure. - Use
Effect.catchDefectonly 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.gento 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, andSchema.Literalsfor 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.Unknownexcept 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
_tagvalues globally safe where pattern matching crosses modules? - Is this recovery handling external uncertainty, or is it hiding a broken internal contract?
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

