effect-style-error-modeling
Models success and failure explicitly in TypeScript using Result or Either-like flows instead of uncontrolled exceptions. Use when implementing predictable error propagation across async workflows.
Best use case
effect-style-error-modeling is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Models success and failure explicitly in TypeScript using Result or Either-like flows instead of uncontrolled exceptions. Use when implementing predictable error propagation across async workflows.
Teams using effect-style-error-modeling should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/effect-style-error-modeling/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How effect-style-error-modeling Compares
| Feature / Agent | effect-style-error-modeling | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Models success and failure explicitly in TypeScript using Result or Either-like flows instead of uncontrolled exceptions. Use when implementing predictable error propagation across async workflows.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Effect-Style Error Modeling
## Rule Anchor
- `AGENTS.md` > "No Fallback Policy" (Result type mandatory for failable public functions)
- `AGENTS.md` > "Development Patterns"
## Use This Skill When
- Error handling is inconsistent (`throw`, `null`, `undefined`, magic strings).
- Async logic has nested try/catch with unclear propagation.
- You need explicit, typed failure paths.
## Core Principles
1. Model errors as data, not hidden control flow.
2. Return a typed result from domain operations.
3. Convert external exceptions into domain error variants at boundaries.
4. Keep one canonical error path per use case.
5. Preserve terminal failure integrity: do not convert terminal failure into active processing unless a separately gated policy explicitly allows it.
## Minimal Result Shape
```ts
type Result<T, E> =
| { ok: true; value: T }
| { ok: false; error: E };
```
## Workflow
1. Define domain-specific error unions.
2. Make domain/application methods return `Result<T, E>`.
3. Wrap external calls in boundary adapters and map exceptions.
4. Compose operations by checking `ok` and returning early on failure.
5. Convert final `Result` to transport response (HTTP/event/log) once.
6. If a reprocess path is required, model it as a separately authorized policy path (disabled by default), not as implicit fallback.
## Reference Skeleton
```ts
type CreateUserError = "EMAIL_TAKEN" | "INVALID_INPUT" | "INFRA_FAILURE";
async function createUser(input: Input, deps: Deps): Promise<Result<User, CreateUserError>> {
if (!input.email) return { ok: false, error: "INVALID_INPUT" };
const exists = await deps.users.exists(input.email);
if (exists) return { ok: false, error: "EMAIL_TAKEN" };
const saved = await deps.users.save(input);
return saved ? { ok: true, value: saved } : { ok: false, error: "INFRA_FAILURE" };
}
```
## Checklist
- [ ] Error union types are explicit and domain-meaningful.
- [ ] No mixed error channels in same layer.
- [ ] Boundary adapters map third-party errors once.
- [ ] Callers handle `ok: false` explicitly.
- [ ] Logs and responses derive from typed error values.
- [ ] Terminal failure is not converted to queued/running without explicit policy gate.
## When to Use Result vs Throw
| Scenario | Use | Rationale |
|----------|-----|-----------|
| Domain operation that can fail (validation, not found, conflict) | `Result<T, E>` | Caller must handle failure explicitly |
| Truly unexpected programmer error (assertion, invariant violation) | `throw` | Should crash, not be silently handled |
| External SDK/API call boundary | `Result<T, E>` via boundary adapter | Convert exception to typed error at boundary |
| Internal helper called only by functions that already return Result | Either | Match the caller's convention |
**Decision rule:** If the caller should reasonably handle the failure, return `Result`. If the failure means a bug in the code, throw.
## Anti-Patterns
- Catching everything and returning generic fallback success.
- Throwing raw strings or unknown objects from domain logic.
- Mixing `throw` and `Result` randomly in one flow.
- Re-queuing failed work silently because "operations need convenience".
- Using `throw` for expected failures (not found, validation error, conflict).
- Returning `Result` for programmer errors that should crash.Related Skills
api-error-standard
Defines the standard error response format for HTTP APIs based on RFC 7807 Problem Details. Use when implementing or reviewing API error responses.
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
vitest-testing-strategy
Defines a practical testing strategy for TypeScript and JavaScript using Vitest across unit, integration, and type-level tests. Use when adding features, refactoring, or preventing regressions with fast feedback loops.
version-management
All packages must have the same version. Use changesets for coordinated version bumps. Never version packages independently.
vercel-react-native-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
vercel-composition-patterns
React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.
user-request-gate
Use immediately when the user requests any implementation, code change, feature addition, fix, or modification. Gates code writing behind a backlog draft document. Read-only exploration is always permitted.
type-boundary-and-ssot
Applies Robota's preferred workflow for trust-boundary validation, strict typing, quality gates, and owner-based SSOT reuse. Use when adding or reviewing type contracts, boundary parsing, shared contract ownership, or running quality checks.
tdd-red-green-refactor
Kent Beck's TDD workflow. Use when writing new code or modifying existing behavior. Enforces the Red-Green-Refactor cycle with small, verifiable steps.
task-tracking
Track work using task files in .agents/tasks/. Use when starting, progressing, or completing a task to maintain a persistent record of work.
tailwind-truncation
Provide Tailwind truncation patterns for single-line and multi-line text. Use when discussing text ellipsis, truncation, or line-clamp usage.