effect-core_skill
- TypeScript
5
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill andrueandersoncs/claude-skill-effect-ts --skill effect-core- SKILL.md7.1 KB
Overview
This skill teaches the fundamental Effect type and core APIs for writing TypeScript with Effect. It covers how to create effects from sync and async values, compose them (map, flatMap, gen, all), and run them with the runtime. Follow the project Code Style guidance before producing any Effect code to ensure idiomatic and safe patterns.
How this skill works
Effect represents a description of a computation that may succeed with A, fail with E, or require an environment R: Effect<A, E, R>. You create effects with helpers like Effect.succeed, Effect.fail, Effect.sync, Effect.promise, Effect.try, and Effect.tryPromise. Compose effects using pipeable operators (Effect.map, Effect.flatMap, Effect.andThen, Effect.tap) or the recommended Effect.gen generator syntax. Run descriptions with Effect.runPromise / runSync / runPromiseExit / runSyncExit to get values or Exit results.
When to use it
- Any time you write TypeScript code that needs predictable, typed effects instead of raw Promises
- When you need to model success, typed failure, and environmental requirements in the type system
- When converting Promise-based code or callback APIs into the Effect world
- When composing sequential or concurrent workflows with clear error handling
- When you want clear boundaries for side effects and runtime execution
Best practices
- Prefer Effect.gen for sequential, readable code over nested flatMap chains
- Use typed error values instead of throwing; convert exceptions with Effect.try or Effect.tryPromise
- Keep side effects in Effect.sync / Effect.promise and use Effect.tap for logging
- Prefer data-last (pipeable) operators for consistency with the ecosystem
- Validate external JSON with schema-based parsing rather than raw JSON.parse
Example use cases
- Wrap fetch() in Effect.tryPromise to produce a typed error boundary for HTTP calls
- Compose several dependent operations with Effect.gen and return a combined result
- Run a synchronous computation with Effect.sync and get a value via Effect.runSync in tests
- Combine independent effects in parallel using Effect.all for tuples or objects
- Convert legacy try/catch code into Effect.try to preserve typed failures
FAQ
An Effect is a description of a computation with typed success, failure, and environment; a Promise is an executing runtime value. Effects are composed and then explicitly run.
When should I use Effect.gen vs flatMap?
Use Effect.gen for clearer sequential code and easier local variable usage. flatMap and pipe are equivalent but more verbose for multi-step flows.
How do I handle exceptions from synchronous code?
Wrap throwing code with Effect.try to convert exceptions into typed error values rather than letting them escape.