EF

effect-patterns-project-setup--execution

Provides 4 curated patterns for executing synchronous effects and managing program flow in Effect-TS.

Install

mkdir -p .claude/skills/effect-patterns-project-setup-execution && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5621" && unzip -o skill.zip -d .claude/skills/effect-patterns-project-setup-execution && rm skill.zip

Installs to .claude/skills/effect-patterns-project-setup-execution

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Effect-TS patterns for Project Setup Execution. Use when working with project setup execution in Effect-TS applications.
120 chars✓ has a “when” trigger
Beginner

Key capabilities

  • Execute synchronous Effect-TS programs
  • Execute asynchronous Effect-TS programs
  • Set up a new Effect-TS project with strict type-checking
  • Create a reusable runtime from Effect-TS layers

How it works

The skill provides patterns for executing synchronous and asynchronous Effect-TS programs using runSync and runPromise, and for setting up projects and creating reusable runtimes from layers.

Inputs & outputs

You give it
An Effect-TS program or layers
You get back
The result of the Effect-TS program or a reusable runtime

When to use effect-patterns-project-setup--execution

  • Implement Effect.runSync for synchronous program execution
  • Structure programs using Effect.gen
  • Apply standardized error handling in Effect-TS
  • Log program execution flow with Effect.log

About this skill

Effect-TS Patterns: Project Setup Execution

This skill provides 4 curated Effect-TS patterns for project setup execution. Use this skill when working on tasks related to:

  • project setup execution
  • Best practices in Effect-TS applications
  • Real-world patterns and solutions

🟢 Beginner Patterns

Execute Synchronous Effects with Effect.runSync

Rule: Execute synchronous effects with Effect.runSync.

Good Example:

import { Effect } from "effect";

// Simple synchronous program
const program1 = Effect.gen(function* () {
  const n = 10;
  const result = n * 2;
  yield* Effect.log(`Simple program result: ${result}`);
  return result;
});

// Run simple program
Effect.runSync(program1);

// Program with logging
const program2 = Effect.gen(function* () {
  yield* Effect.logInfo("Starting calculation...");
  const n = yield* Effect.sync(() => 10);
  yield* Effect.logInfo(`Got number: ${n}`);
  const result = yield* Effect.sync(() => n * 2);
  yield* Effect.logInfo(`Result: ${result}`);
  return result;
});

// Run with logging
Effect.runSync(program2);

// Program with error handling
const program3 = Effect.gen(function* () {
  yield* Effect.logInfo("Starting division...");
  const n = yield* Effect.sync(() => 10);
  const divisor = yield* Effect.sync(() => 0);

  yield* Effect.logInfo(`Attempting to divide ${n} by ${divisor}...`);
  return yield* Effect.try({
    try: () => {
      if (divisor === 0) throw new Error("Cannot divide by zero");
      return n / divisor;
    },
    catch: (error) => {
      if (error instanceof Error) {
        return error;
      }
      return new Error("Unknown error occurred");
    },
  });
}).pipe(
  Effect.catchAll((error) => Effect.logInfo(`Error occurred: ${error.message}`))
);

// Run with error handling
Effect.runSync(program3);

Explanation:
Use runSync only for Effects that are fully synchronous. If the Effect contains async code, use runPromise instead.

Anti-Pattern:

Do not use runSync on an Effect that contains asynchronous operations like Effect.delay or Effect.promise. This will result in a runtime error.

Rationale:

To execute an Effect that is guaranteed to be synchronous, use Effect.runSync. This will return the success value directly or throw the error.

Effect.runSync is an optimized runner for Effects that don't involve any asynchronous operations. If the Effect contains any async operations, runSync will throw an error.


Execute Asynchronous Effects with Effect.runPromise

Rule: Execute asynchronous effects with Effect.runPromise.

Good Example:

import { Effect } from "effect";

const program = Effect.succeed("Hello, World!").pipe(Effect.delay("1 second"));

const promise = Effect.runPromise(program);

const programWithLogging = Effect.gen(function* () {
  const result = yield* program;
  yield* Effect.log(result); // Logs "Hello, World!" after 1 second.
  return result;
});

Effect.runPromise(programWithLogging);

Explanation:
Effect.runPromise executes your effect and returns a Promise, making it easy to integrate with existing JavaScript async workflows.

Anti-Pattern:

Never call runPromise inside another Effect composition. Effects are meant to be composed together before being run once at the end.

Rationale:

To execute an Effect that may be asynchronous and retrieve its result, use Effect.runPromise. This should only be done at the outermost layer of your application.

Effect.runPromise is the bridge from the Effect world to the Promise-based world of Node.js and browsers. If the Effect succeeds, the Promise resolves; if it fails, the Promise rejects.


Set Up a New Effect Project

Rule: Set up a new Effect project.

Good Example:

// 1. Init project (e.g., `npm init -y`)
// 2. Install deps (e.g., `npm install effect`, `npm install -D typescript tsx`)
// 3. Create tsconfig.json with `"strict": true`
// 4. Create src/index.ts
import { Effect } from "effect";

const program = Effect.log("Hello, World!");

Effect.runSync(program);

// 5. Run the program (e.g., `npx tsx src/index.ts`)

Explanation:
This setup ensures you have TypeScript and Effect ready to go, with strict type-checking for maximum safety and correctness.

Anti-Pattern:

Avoid disabling strict mode in your tsconfig.json. Running with "strict": false will cause you to lose many of the type-safety guarantees that make Effect so powerful.

Rationale:

To start a new Effect project, initialize a standard Node.js project, add effect and typescript as dependencies, and create a tsconfig.json file with strict mode enabled.

A proper setup is crucial for leveraging Effect's powerful type-safety features. Using TypeScript's strict mode is non-negotiable.


🟠 Advanced Patterns

Create a Reusable Runtime from Layers

Rule: Create a reusable runtime from layers.

Good Example:

import { Effect, Layer, Runtime } from "effect";

class GreeterService extends Effect.Service<GreeterService>()("Greeter", {
  sync: () => ({
    greet: (name: string) => Effect.sync(() => `Hello ${name}`),
  }),
}) {}

const runtime = Effect.runSync(
  Layer.toRuntime(GreeterService.Default).pipe(Effect.scoped)
);

// In a server, you would reuse `run` for every request.
Runtime.runPromise(runtime)(Effect.log("Hello"));

Explanation:
By compiling your layers into a Runtime once, you avoid rebuilding the dependency graph for every effect execution.

Anti-Pattern:

For a long-running application, avoid providing layers and running an effect in a single operation. This forces Effect to rebuild the dependency graph on every execution.

Rationale:

For applications that need to run multiple effects (e.g., a web server), use Layer.toRuntime(appLayer) to compile your dependency graph into a single, reusable Runtime object.

Building the dependency graph from layers has a one-time cost. Creating a Runtime once when your application starts is highly efficient for long-running applications.


When not to use it

  • Using runSync for Effects containing asynchronous operations
  • Calling runPromise inside another Effect composition
  • Disabling strict mode in tsconfig.json

Limitations

  • runSync will throw an error if the Effect contains any async operations.
  • runPromise should only be done at the outermost layer of your application.
  • For a long-running application, avoid providing layers and running an effect in a single operation.

How it compares

This skill offers specific Effect-TS patterns for project setup and execution, providing structured approaches for synchronous and asynchronous operations and dependency management.

Compared to similar skills

effect-patterns-project-setup--execution side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
effect-patterns-project-setup--execution (this skill)17moNo flagsBeginner
monorepo-structure16moReviewIntermediate
add-policy01moReviewAdvanced
ai-code02moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

monorepo-structure

dadbodgeoff

Set up a Turborepo + pnpm monorepo for sharing code between frontend, backend, and workers. One repo, multiple packages, shared types, parallel builds.

14

add-policy

microsoft

Use when adding, modifying, or reviewing VS Code configuration policies. Covers the full policy lifecycle from registration to export to platform-specific artifacts. Run on ANY change that adds a `policy:` field to a configuration property.

00

ai-code

arcasilesgroup

Writes production code that satisfies stack-context standards on the first pass: interface-first design, backward-compatibility checks, lightweight self-review. Trigger for 'implement this', 'write the code for', 'add X to Y', 'build this function', 'make this work'. Not for tests; use /ai-test inst

00

rust

microsoft

Use this guide when working on Rust changes in the FAST monorepo.

00

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

turborepo

vercel

Turborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries. Use when user: configures tasks/workflows/pipelines, creates packages, sets up monorepo, shares code between apps, runs changed/affected packages, debugs cache, or has apps/packages directories.

61191

Search skills

Search the agent skills registry