Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计提醒

building-with-effect有效果的建筑

Agent Skill

building-with-effect 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

196

周安装

8

GitHub Stars

公开资料未说明

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:building-with-effect(有效果的建筑)
来源仓库:https://github.com/felixnorden/skills
仓库路径:skills/building-with-effect
安装命令:
npx skills add https://github.com/felixnorden/skills --skill building-with-effect
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/felixnorden/skills --skill building-with-effect

简介

building-with-effect 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕仓库状态、代码变更或协作事项进行整理时使用。
  • 通过 Effect.fn 创建类型安全函数,支持错误处理、依赖注入和并发管理。
  • 安装前建议确认权限范围和维护状态,注意可能触发联网或文件读写操作。
  • 可结合来源仓库和原始 README 进一步核验具体用法和实现细节。

SKILL.md

Building with Effect

Effect is a powerful TypeScript library for building complex, type-safe programs with composable abstractions for error handling, dependency injection, concurrency, and resource management.

Quick Start

Using Effect.fn (Recommended)

import { Effect, Schema } from "effect";

// Define errors with Schema.TaggedErrorClass
class FetchError extends Schema.TaggedErrorClass<FetchError>()("FetchError", {
  message: Schema.String,
}) {}

// Create functions with Effect.fn
export const fetchUser = Effect.fn("fetchUser")(
  function* (id: number) {
    yield* Effect.logInfo("Fetching user:", id);

    // Always return when raising an error
    return yield* new FetchError({ message: "Failed to fetch" });
  },
  // Add combinators as additional arguments (no .pipe needed)
  Effect.catch((error) => Effect.logError(`Error: ${error}`)),
  Effect.withSpan("fetchUser", { attributes: { method: "Effect.fn" } }),
);

Generator Style

const program = Effect.gen(function* () {
  const a = yield* Effect.succeed(10);
  const b = yield* Effect.succeed(20);
  return a + b;
});

Running Effects

// As Promise
Effect.runPromise(program).then(console.log);

// With NodeRuntime (recommended for apps)
import { NodeRuntime } from "@effect/platform-node";
NodeRuntime.runMain(program);

// Using Layer.launch as entry point
Layer.launch(WorkerLayer).pipe(NodeRuntime.runMain);

Degrees of Freedom

Match the level of specificity to the task's fragility:

Low Freedom (specific patterns, consistency critical)

These operations have a narrow safe path - follow exactly:

  • Error definition: Always use Schema.TaggedErrorClass with descriptive _tag
  • Service structure: Extend Context.Service with static layer property
  • Effect.fn usage: Always use Effect.fn("name") for functions returning Effects
  • Resource cleanup: Always use acquireUseRelease or Effect.addFinalizer
  • Resource pattern selection: Use acquireUseRelease for external resources, Ref for shared mutable state, addFinalizer for cleanup within existing scope
  • Error recovery vs propagation: Use catchTags/orElse to recover; use return yield* new Error() to propagate (ALWAYS use return yield* to signal the function stops)

Medium Freedom (preferred patterns, some variation acceptable)

These have recommended approaches but context matters:

  • Combinator selection: Choose based on need - catchTag for specific errors, catchTags for multiple, catch for all
  • Layer composition: Use Layer.provide for dependency injection, order matters for overrides
  • Concurrency control: Use Effect.all or Effect.forEach with appropriate concurrency option
  • Error recovery: Select retry schedules based on failure characteristics

High Freedom (multiple valid approaches, context-dependent)

These depend on application needs:

  • Application architecture: Service boundaries, layer organization, entry point structure
  • Testing strategies: Test at service level, effect level, or integration level based on needs
  • Performance optimization: Caching strategies, batching decisions, bundle size tradeoffs
  • Observability setup: Logging granularity, tracing scope, metric selection

Core Type

Effect<Success, Error, Requirements>;
  • Success: Value type on success
  • Error: Type-tracked errors
  • Requirements: Services needed (use never if none)

Key Operators

Transformation

  • map - Transform success value
  • flatMap / andThen - Chain effects
  • tap - Side effects without changing value
  • mapError - Transform error type

Error Handling

  • catch - Handle all errors (renamed from catchAll in earlier versions)
  • catchTag - Handle specific error types
  • catchTags - Handle multiple tagged errors at once
  • catchReason / catchReasons - Handle errors with reasons
  • catchFilter - Handle filtered errors (renamed from catchSome in earlier versions)
  • orElse - Fallback effect
  • retry - Retry with policy

Composition

  • all - Run multiple effects
  • forEach - Map over collection
  • zip / zipWith - Combine effects
  • provide - Supply dependencies

Best Practices

  1. Use Effect.fn for functions that return Effects (not Effect.gen alone)
  2. Define errors with Schema.TaggedErrorClass for type safety
  3. Use Context.Service for dependency injection
  4. Build layers explicitly with Layer.effect and compose with Layer.provide
  5. Use ExecutionPlan for AI provider fallback strategies
  6. Handle interruptions with acquireRelease for resources
  7. Use Layer.launch as application entry point for long-running apps
  8. Enable dual APIs when appropriate (data-first + data-last)
  9. Choose resource patterns deliberately: See Resource Pattern Selector
  10. Use error recovery for resilience: See Error Handling Decision Tree
  11. Prefer Effect.forEach with concurrency: See Concurrency Anti-Patterns

Workflows

Use these checklists for complex multi-step tasks:

Creating a New Service

Copy this checklist and track progress:

Service Creation Progress:
- [ ] Step 1: Define error types with Schema.TaggedErrorClass
- [ ] Step 2: Create service class extending Context.Service
- [ ] Step 3: Implement methods using Effect.fn
- [ ] Step 4: Build Layer.effect with service implementation
- [ ] Step 5: Provide dependencies via Layer.provide
- [ ] Step 6: Test the service layer

Step 1: Define error types

class ServiceError extends Schema.TaggedErrorClass<ServiceError>()(
  "ServiceError",
  { cause: Schema.Defect },
) {}

Step 2: Create service class

export class MyService extends Context.Service<
  MyService,
  {
    method(): Effect.Effect<ReturnType, ServiceError>;
  }
>()("namespace/MyService") {}

Step 3: Implement methods

const method = Effect.fn("MyService.method")(function* () {
  // Implementation
});

Step 4-6: Build and test layer

See Services & Layers for complete examples.

Setting Up AI Integration

Copy this checklist and track progress:

AI Setup Progress:
- [ ] Step 1: Install provider packages (@effect/ai-openai, @effect/ai-anthropic)
- [ ] Step 2: Configure client layers with API keys
- [ ] Step 3: Define ExecutionPlan for fallback strategy
- [ ] Step 4: Create AI service with Effect.fn
- [ ] Step 5: Implement error handling with mapError
- [ ] Step 6: Provide client layers to service layer

See AI Modules for detailed implementation.

Error Handling Strategy

Copy this checklist and track progress:

Error Handling Progress:
- [ ] Step 1: Define all error types with Schema.TaggedErrorClass
- [ ] Step 2: Use catchTags for multiple specific error handlers
- [ ] Step 3: Add catch for final fallback if needed
- [ ] Step 4: Consider retry with Schedule for transient failures
- [ ] Step 5: Log errors at appropriate layers
- [ ] Step 6: Test error scenarios

See Error Handling for patterns and examples.

Common Patterns

Service with Effect.fn

import { Effect, Context, Layer, Schema } from "effect";

class DatabaseError extends Schema.TaggedErrorClass<DatabaseError>()(
  "DatabaseError",
  { cause: Schema.Defect },
) {}

export class Database extends Context.Service<
  Database,
  {
    query(sql: string): Effect.Effect<unknown[], DatabaseError>;
  }
>()("app/Database") {
  static readonly layer = Layer.effect(
    Database,
    Effect.gen(function* () {
      const query = Effect.fn("Database.query")(function* (sql: string) {
        yield* Effect.log("Executing SQL:", sql);
        return [{ id: 1, name: "Alice" }];
      });
      return Database.of({ query });
    }),
  );
}

// Exported type with proper inference
export type DatabaseService = Database["Service"];

Error Handling with catchTags

const configWithFallback = loadConfig().pipe(
  Effect.catchTags({
    ParseError: () => Effect.succeed(defaultConfig),
    FileError: () => Effect.succeed(defaultConfig),
  }),
);

Resource Safety

const program = Effect.acquireUseRelease(
  openFile("data.txt"),
  (file) => processFile(file),
  (file) => closeFile(file),
);

Package Structure

Core Package

import { Effect } from "effect";

Unstable Modules (may have breaking changes in minor releases)

import { Schema } from "effect/unstable/schema";
import { HttpClient } from "effect/unstable/http";
import { LanguageModel } from "effect/unstable/ai";
import { PubSub } from "effect/unstable/pubsub";

Platform-Specific Packages (separate packages)

import { NodeRuntime } from "@effect/platform-node";
import { SqlClient } from "@effect/sql-pg";
import { OpenAiClient } from "@effect/ai-openai";

References

Dive deeper into specific topics and patterns:

Anti-Patterns to Avoid

  • Using try/catch with Effect (defeats type safety)
  • Mixing Promise-based and Effect-based code without conversion
  • Not handling all error cases (use catch or match)
  • Ignoring resource cleanup (always use acquireRelease)
  • Running effects at module level (breaks composability)
  • Using global state instead of Services
  • Overusing Effect for simple synchronous operations
  • Using Effect.gen alone instead of Effect.fn for functions

Troubleshooting

Type errors with Requirements

  • Ensure all services are provided via Effect.provide
  • Check Layer composition matches service dependencies
  • Use Effect.provideService for quick inline provisions

Effects not executing

  • Effects are lazy - must be run with runPromise, runSync, or runFork
  • Check that effect is actually yielded in generator context

Performance issues

  • Avoid excessive allocations in hot loops
  • Use Effect.cached for expensive computations
  • Consider Micro module for bundle-size sensitive apps

Example Files

Browse detailed examples in the effect-smol/ai-docs/src/ directory:

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.64%
按下载量换算23

Claude

30.38%
按下载量换算19

Cursor

15.95%
按下载量换算10

Gemini CLI

8.61%
按下载量换算5

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills