effect-patterns-hub

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Effect Patterns Hub

Effect 模式中心

Purpose: Provide quick access to 130+ curated Effect-TS patterns from the EffectPatterns repository. Use this skill to find specific implementation patterns, compare approaches, and reference best practices.
用途:快速访问来自EffectPatterns仓库的130+个经过筛选的Effect-TS模式。使用此技能查找特定实现模式、对比不同实现方式,并参考最佳实践。

Triggers

触发场景

  • Looking for a specific Effect pattern or idiom
  • Need real-world examples of Effect concepts
  • Want to see multiple approaches to the same problem
  • Comparing implementation strategies
  • Learning new Effect features
  • 查找特定的Effect模式或惯用写法
  • 需要Effect概念的真实场景示例
  • 想了解同一问题的多种解决方法
  • 对比不同实现策略
  • 学习Effect的新特性

Pattern Library Location

模式库位置

Local Patterns:
.claude/skills/effect-patterns-hub/patterns/

Documentation:
docs/effect-patterns/

Count: 130+ patterns in MDX format
本地模式
.claude/skills/effect-patterns-hub/patterns/

文档
docs/effect-patterns/

数量:130+个MDX格式的模式

Quick Decision Tree

快速决策树

I need to...

我需要...

Create Effects

创建Effect

  • From value →
    constructor-succeed-some-right.mdx
  • From sync code →
    constructor-sync-async.mdx
  • From promise →
    constructor-try-trypromise.mdx
  • From nullable →
    constructor-from-nullable-option-either.mdx
  • Pre-resolved →
    create-pre-resolved-effect.mdx
  • 从值创建 →
    constructor-succeed-some-right.mdx
  • 从同步代码创建 →
    constructor-sync-async.mdx
  • 从Promise创建 →
    constructor-try-trypromise.mdx
  • 从可空值创建 →
    constructor-from-nullable-option-either.mdx
  • 预解析Effect →
    create-pre-resolved-effect.mdx

Transform & Compose

转换与组合

  • Map values →
    combinator-map.mdx
  • Chain effects →
    combinator-flatmap.mdx
  • Sequence operations →
    combinator-sequencing.mdx
  • Combine values →
    combinator-zip.mdx
  • Filter →
    combinator-filter.mdx
  • Conditional logic →
    combinator-conditional.mdx
  • Process collections →
    combinator-foreach-all.mdx
  • 映射值 →
    combinator-map.mdx
  • 链式调用Effect →
    combinator-flatmap.mdx
  • 按顺序执行操作 →
    combinator-sequencing.mdx
  • 合并值 →
    combinator-zip.mdx
  • 过滤 →
    combinator-filter.mdx
  • 条件逻辑 →
    combinator-conditional.mdx
  • 处理集合 →
    combinator-foreach-all.mdx

Control Flow

控制流

  • Sequential logic →
    write-sequential-code-with-gen.mdx
  • Business logic →
    use-gen-for-business-logic.mdx
  • Pipe composition →
    use-pipe-for-composition.mdx
  • Branching workflows →
    conditionally-branching-workflows.mdx
  • Combinators →
    control-flow-with-combinators.mdx
  • Repetition →
    control-repetition-with-schedule.mdx
  • 顺序逻辑 →
    write-sequential-code-with-gen.mdx
  • 业务逻辑 →
    use-gen-for-business-logic.mdx
  • Pipe组合 →
    use-pipe-for-composition.mdx
  • 分支工作流 →
    conditionally-branching-workflows.mdx
  • 组合器 →
    control-flow-with-combinators.mdx
  • 重复执行 →
    control-repetition-with-schedule.mdx

Error Handling

错误处理

  • Define errors →
    define-tagged-errors.mdx
  • Catch specific errors →
    pattern-catchtag.mdx
  • Handle all errors →
    handle-errors-with-catch.mdx
  • Retry operations →
    retry-based-on-specific-errors.mdx
  • Flaky operations →
    handle-flaky-operations-with-retry-timeout.mdx
  • Map errors →
    mapping-errors-to-fit-your-domain.mdx
  • Handle unexpected →
    handle-unexpected-errors-with-cause.mdx
  • API errors →
    handle-api-errors.mdx
  • 定义错误 →
    define-tagged-errors.mdx
  • 捕获特定错误 →
    pattern-catchtag.mdx
  • 处理所有错误 →
    handle-errors-with-catch.mdx
  • 重试操作 →
    retry-based-on-specific-errors.mdx
  • 处理不稳定操作 →
    handle-flaky-operations-with-retry-timeout.mdx
  • 映射错误 →
    mapping-errors-to-fit-your-domain.mdx
  • 处理意外错误 →
    handle-unexpected-errors-with-cause.mdx
  • API错误处理 →
    handle-api-errors.mdx

Concurrency

并发

  • Parallel execution →
    run-effects-in-parallel-with-all.mdx
  • Background tasks →
    run-background-tasks-with-fork.mdx
  • Process collections →
    process-collection-in-parallel-with-foreach.mdx
  • Race effects →
    race-concurrent-effects.mdx
  • Fibers explained →
    understand-fibers-as-lightweight-threads.mdx
  • Decouple with queues →
    decouple-fibers-with-queue-pubsub.mdx
  • Polling →
    poll-for-status-until-task-completes.mdx
  • Graceful shutdown →
    implement-graceful-shutdown.mdx
  • 并行执行 →
    run-effects-in-parallel-with-all.mdx
  • 后台任务 →
    run-background-tasks-with-fork.mdx
  • 并行处理集合 →
    process-collection-in-parallel-with-foreach.mdx
  • 竞争执行Effect →
    race-concurrent-effects.mdx
  • Fiber详解 →
    understand-fibers-as-lightweight-threads.mdx
  • 用队列解耦 →
    decouple-fibers-with-queue-pubsub.mdx
  • 轮询 →
    poll-for-status-until-task-completes.mdx
  • 优雅停机 →
    implement-graceful-shutdown.mdx

Services & Dependency Injection

服务与依赖注入

  • Model dependencies →
    model-dependencies-as-services.mdx
  • Understand layers →
    understand-layers-for-dependency-injection.mdx
  • Scoped services →
    scoped-service-layer.mdx
  • Composable modules →
    organize-layers-into-composable-modules.mdx
  • Compose scoped layers →
    compose-scoped-layers.mdx
  • Provide config →
    provide-config-layer.mdx
  • Caching wrapper →
    add-caching-by-wrapping-a-layer.mdx
  • 建模依赖 →
    model-dependencies-as-services.mdx
  • 理解依赖注入的Layer →
    understand-layers-for-dependency-injection.mdx
  • 作用域服务 →
    scoped-service-layer.mdx
  • 可组合模块 →
    organize-layers-into-composable-modules.mdx
  • 组合作用域Layer →
    compose-scoped-layers.mdx
  • 提供配置 →
    provide-config-layer.mdx
  • 缓存包装器 →
    add-caching-by-wrapping-a-layer.mdx

Resource Management

资源管理

  • Bracket pattern →
    safely-bracket-resource-usage.mdx
  • Scope management →
    manage-resource-lifecycles-with-scope.mdx
  • Manual scope →
    manual-scope-management.mdx
  • Scoped resources runtime →
    create-managed-runtime-for-scoped-resources.mdx
  • Bracket模式 →
    safely-bracket-resource-usage.mdx
  • 作用域管理 →
    manage-resource-lifecycles-with-scope.mdx
  • 手动作用域管理 →
    manual-scope-management.mdx
  • 作用域资源运行时 →
    create-managed-runtime-for-scoped-resources.mdx

Streaming

流处理

  • Process streaming data →
    process-streaming-data-with-stream.mdx
  • From iterable →
    stream-from-iterable.mdx
  • From file →
    stream-from-file.mdx
  • From paginated API →
    stream-from-paginated-api.mdx
  • Concurrent processing →
    stream-process-concurrently.mdx
  • Batch processing →
    stream-process-in-batches.mdx
  • Collect results →
    stream-collect-results.mdx
  • Run for effects →
    stream-run-for-effects.mdx
  • Manage resources →
    stream-manage-resources.mdx
  • Retry on failure →
    stream-retry-on-failure.mdx
  • 处理流数据 →
    process-streaming-data-with-stream.mdx
  • 从可迭代对象创建流 →
    stream-from-iterable.mdx
  • 从文件创建流 →
    stream-from-file.mdx
  • 从分页API创建流 →
    stream-from-paginated-api.mdx
  • 并发处理流 →
    stream-process-concurrently.mdx
  • 批处理流 →
    stream-process-in-batches.mdx
  • 收集流结果 →
    stream-collect-results.mdx
  • 为Effect运行流 →
    stream-run-for-effects.mdx
  • 流资源管理 →
    stream-manage-resources.mdx
  • 流失败重试 →
    stream-retry-on-failure.mdx

Schema & Validation

Schema与验证

  • Define contracts →
    define-contracts-with-schema.mdx
  • Parse/decode →
    parse-with-schema-decode.mdx
  • Transform data →
    transform-data-with-schema.mdx
  • Validate body →
    validate-request-body.mdx
  • Brand types →
    brand-model-domain-type.mdx
  • Brand validation →
    brand-validate-parse.mdx
  • Config schema →
    define-config-schema.mdx
  • 定义契约 →
    define-contracts-with-schema.mdx
  • 解析/解码 →
    parse-with-schema-decode.mdx
  • 转换数据 →
    transform-data-with-schema.mdx
  • 验证请求体 →
    validate-request-body.mdx
  • 品牌类型 →
    brand-model-domain-type.mdx
  • 品牌类型验证 →
    brand-validate-parse.mdx
  • 配置Schema →
    define-config-schema.mdx

Data Types

数据类型

  • Option →
    data-option.mdx
    ,
    model-optional-values-with-option.mdx
  • Either →
    data-either.mdx
    ,
    accumulate-multiple-errors-with-either.mdx
  • Chunk →
    data-chunk.mdx
    ,
    use-chunk-for-high-performance-collections.mdx
  • Array →
    data-array.mdx
  • HashSet →
    data-hashset.mdx
  • Duration →
    data-duration.mdx
    ,
    representing-time-spans-with-duration.mdx
  • DateTime →
    data-datetime.mdx
    ,
    beyond-the-date-type.mdx
  • BigDecimal →
    data-bigdecimal.mdx
  • Cause →
    data-cause.mdx
  • Exit →
    data-exit.mdx
  • Ref →
    data-ref.mdx
    ,
    manage-shared-state-with-ref.mdx
  • Redacted →
    data-redacted.mdx
  • Case →
    data-case.mdx
  • Class →
    data-class.mdx
  • Struct →
    data-struct.mdx
  • Tuple →
    data-tuple.mdx
  • Option →
    data-option.mdx
    ,
    model-optional-values-with-option.mdx
  • Either →
    data-either.mdx
    ,
    accumulate-multiple-errors-with-either.mdx
  • Chunk →
    data-chunk.mdx
    ,
    use-chunk-for-high-performance-collections.mdx
  • Array →
    data-array.mdx
  • HashSet →
    data-hashset.mdx
  • Duration →
    data-duration.mdx
    ,
    representing-time-spans-with-duration.mdx
  • DateTime →
    data-datetime.mdx
    ,
    beyond-the-date-type.mdx
  • BigDecimal →
    data-bigdecimal.mdx
  • Cause →
    data-cause.mdx
  • Exit →
    data-exit.mdx
  • Ref →
    data-ref.mdx
    ,
    manage-shared-state-with-ref.mdx
  • Redacted →
    data-redacted.mdx
  • Case →
    data-case.mdx
  • Class →
    data-class.mdx
  • Struct →
    data-struct.mdx
  • Tuple →
    data-tuple.mdx

Pattern Matching

模式匹配

  • Match API →
    pattern-match.mdx
  • Effectful match →
    pattern-matcheffect.mdx
  • Tag matching →
    pattern-matchtag.mdx
  • Option/Either checks →
    pattern-option-either-checks.mdx
  • Match API →
    pattern-match.mdx
  • 带Effect的匹配 →
    pattern-matcheffect.mdx
  • 标签匹配 →
    pattern-matchtag.mdx
  • Option/Either检查 →
    pattern-option-either-checks.mdx

HTTP & Web

HTTP与Web

  • Basic HTTP server →
    build-a-basic-http-server.mdx
  • Launch server →
    launch-http-server.mdx
  • Handle GET →
    handle-get-request.mdx
  • HTTP client request →
    make-http-client-request.mdx
  • Testable HTTP client →
    create-a-testable-http-client-service.mdx
  • JSON response →
    send-json-response.mdx
  • Path parameters →
    extract-path-parameters.mdx
  • Provide dependencies to routes →
    provide-dependencies-to-routes.mdx
  • 基础HTTP服务器 →
    build-a-basic-http-server.mdx
  • 启动服务器 →
    launch-http-server.mdx
  • 处理GET请求 →
    handle-get-request.mdx
  • HTTP客户端请求 →
    make-http-client-request.mdx
  • 可测试的HTTP客户端 →
    create-a-testable-http-client-service.mdx
  • JSON响应 →
    send-json-response.mdx
  • 路径参数 →
    extract-path-parameters.mdx
  • 为路由提供依赖 →
    provide-dependencies-to-routes.mdx

Testing

测试

  • Mocking dependencies →
    mocking-dependencies-in-tests.mdx
  • Use Default layer →
    use-default-layer-for-tests.mdx
  • Tests adapt to code →
    write-tests-that-adapt-to-application-code.mdx
  • 模拟依赖 →
    mocking-dependencies-in-tests.mdx
  • 使用Default Layer →
    use-default-layer-for-tests.mdx
  • 编写适配应用代码的测试 →
    write-tests-that-adapt-to-application-code.mdx

Observability

可观测性

  • Structured logging →
    leverage-structured-logging.mdx
    ,
    observability-structured-logging.mdx
  • Tracing spans →
    trace-operations-with-spans.mdx
    ,
    observability-tracing-spans.mdx
  • Custom metrics →
    add-custom-metrics.mdx
    ,
    observability-custom-metrics.mdx
  • OpenTelemetry →
    observability-opentelemetry.mdx
  • Effect.fn instrumentation →
    observability-effect-fn.mdx
  • 结构化日志 →
    leverage-structured-logging.mdx
    ,
    observability-structured-logging.mdx
  • 追踪Span →
    trace-operations-with-spans.mdx
    ,
    observability-tracing-spans.mdx
  • 自定义指标 →
    add-custom-metrics.mdx
    ,
    observability-custom-metrics.mdx
  • OpenTelemetry →
    observability-opentelemetry.mdx
  • Effect.fn 埋点 →
    observability-effect-fn.mdx

Runtime & Execution

运行时与执行

  • runPromise →
    execute-with-runpromise.mdx
  • runSync →
    execute-with-runsync.mdx
  • runFork →
    execute-long-running-apps-with-runfork.mdx
  • Reusable runtime →
    create-reusable-runtime-from-layers.mdx
  • runPromise →
    execute-with-runpromise.mdx
  • runSync →
    execute-with-runsync.mdx
  • runFork →
    execute-long-running-apps-with-runfork.mdx
  • 可复用运行时 →
    create-reusable-runtime-from-layers.mdx

Configuration

配置

  • Access config →
    access-config-in-context.mdx
  • Define schema →
    define-config-schema.mdx
  • Provide layer →
    provide-config-layer.mdx
  • 访问配置 →
    access-config-in-context.mdx
  • 定义Schema →
    define-config-schema.mdx
  • 提供Layer →
    provide-config-layer.mdx

Time & Scheduling

时间与调度

  • Current time →
    accessing-current-time-with-clock.mdx
  • Duration →
    representing-time-spans-with-duration.mdx
  • DateTime →
    beyond-the-date-type.mdx
  • Schedule repetition →
    control-repetition-with-schedule.mdx
  • 当前时间 →
    accessing-current-time-with-clock.mdx
  • 时长 →
    representing-time-spans-with-duration.mdx
  • 日期时间 →
    beyond-the-date-type.mdx
  • 调度重复执行 →
    control-repetition-with-schedule.mdx

Project Setup

项目搭建

  • New project →
    setup-new-project.mdx
  • Editor LSP →
    supercharge-your-editor-with-the-effect-lsp.mdx
  • AI agents MCP →
    teach-your-ai-agents-effect-with-the-mcp-server.mdx
  • 新项目 →
    setup-new-project.mdx
  • 编辑器LSP →
    supercharge-your-editor-with-the-effect-lsp.mdx
  • AI代理MCP →
    teach-your-ai-agents-effect-with-the-mcp-server.mdx

Advanced Concepts

高级概念

  • Structural equality →
    comparing-data-by-value-with-structural-equality.mdx
  • Effect channels →
    understand-effect-channels.mdx
  • Effects are lazy →
    effects-are-lazy.mdx
  • Not found vs errors →
    distinguish-not-found-from-errors.mdx
  • Promise problems →
    solve-promise-problems-with-effect.mdx
  • Avoid long chains →
    avoid-long-andthen-chains.mdx
  • 结构相等性 →
    comparing-data-by-value-with-structural-equality.mdx
  • Effect通道 →
    understand-effect-channels.mdx
  • Effect是惰性的 →
    effects-are-lazy.mdx
  • 未找到与错误的区分 →
    distinguish-not-found-from-errors.mdx
  • Promise问题解决 →
    solve-promise-problems-with-effect.mdx
  • 避免长andThen链 →
    avoid-long-andthen-chains.mdx

Pattern Categories

模式分类

By Skill Level

按技能水平

Beginner (Getting Started)
  • Constructor patterns (succeed, fail, sync, async)
  • Basic combinators (map, flatMap, tap)
  • Simple error handling (catch, catchTag)
  • Effect.gen basics
  • runPromise/runSync
Intermediate (Building Applications)
  • Services and layers
  • Schema validation
  • HTTP servers and clients
  • Resource management
  • Concurrency basics (Effect.all, fork)
  • Testing with mocks
Advanced (Production Systems)
  • Complex layer composition
  • Custom runtimes
  • Streaming pipelines
  • Graceful shutdown
  • OpenTelemetry integration
  • Performance optimization (Chunk, Ref)
初级(入门)
  • 构造器模式(succeed、fail、sync、async)
  • 基础组合器(map、flatMap、tap)
  • 简单错误处理(catch、catchTag)
  • Effect.gen 基础
  • runPromise/runSync
中级(构建应用)
  • 服务与Layer
  • Schema验证
  • HTTP服务器与客户端
  • 资源管理
  • 基础并发(Effect.all、fork)
  • 模拟测试
高级(生产系统)
  • 复杂Layer组合
  • 自定义运行时
  • 流处理管道
  • 优雅停机
  • OpenTelemetry集成
  • 性能优化(Chunk、Ref)

By Use Case

按使用场景

Domain Modeling
  • Schema definitions
  • Brand types
  • Tagged errors
  • Option/Either for optional/fallible values
API Development
  • HTTP server setup
  • Route handling
  • Request validation
  • Error handling
  • Response formatting
Data Processing
  • Stream processing
  • Batch operations
  • Parallel processing
  • Resource-safe pipelines
Application Architecture
  • Service layer design
  • Dependency injection
  • Module composition
  • Configuration management
Testing
  • Mock layers
  • Test utilities
  • Testable services
Observability
  • Structured logging
  • Distributed tracing
  • Custom metrics
  • Performance monitoring
领域建模
  • Schema定义
  • 品牌类型
  • 标签化错误
  • 用Option/Either处理可选/可能失败的值
API开发
  • HTTP服务器搭建
  • 路由处理
  • 请求验证
  • 错误处理
  • 响应格式化
数据处理
  • 流处理
  • 批处理操作
  • 并行处理
  • 资源安全管道
应用架构
  • 服务层设计
  • 依赖注入
  • 模块组合
  • 配置管理
测试
  • 模拟Layer
  • 测试工具
  • 可测试服务
可观测性
  • 结构化日志
  • 分布式追踪
  • 自定义指标
  • 性能监控

Search Patterns

模式搜索

By Keyword

按关键词

Use
Grep
to search patterns by keyword:
bash
undefined
使用
Grep
按关键词搜索模式:
bash
undefined

Find patterns about error handling

查找错误处理相关模式

grep -l "error" patterns/*.mdx
grep -l "error" patterns/*.mdx

Find patterns about concurrency

查找并发相关模式

grep -l "concurrent|parallel|fiber" patterns/*.mdx
grep -l "concurrent|parallel|fiber" patterns/*.mdx

Find patterns about HTTP

查找HTTP相关模式

grep -l "http|server|client" patterns/*.mdx
grep -l "http|server|client" patterns/*.mdx

Find patterns about testing

查找测试相关模式

grep -l "test|mock" patterns/*.mdx
undefined
grep -l "test|mock" patterns/*.mdx
undefined

By Frontmatter Tags

按Frontmatter标签

All patterns include metadata:
  • title
    : Human-readable name
  • id
    : Unique identifier (filename without extension)
  • skillLevel
    : beginner, intermediate, advanced
  • useCase
    : domain-modeling, error-handling, concurrency, etc.
  • summary
    : Brief description
  • tags
    : Keywords for searching
  • related
    : Links to related patterns
所有模式都包含元数据:
  • title
    :人类可读的名称
  • id
    :唯一标识符(不带扩展名的文件名)
  • skillLevel
    :beginner、intermediate、advanced
  • useCase
    :主要使用场景
  • summary
    :简短描述
  • tags
    :搜索关键词
  • related
    :相关模式链接

Common Searches

常见搜索场景

"How do I create an Effect from..."
  • → Search constructor patterns:
    grep -l "constructor" patterns/*.mdx
  • → Check
    constructor-*.mdx
    files
"How do I handle errors when..."
  • → Search error handling:
    grep -l "error\|catch\|retry" patterns/*.mdx
  • → Check
    handle-*.mdx
    and
    pattern-catchtag.mdx
"How do I run multiple things concurrently?"
  • → Search concurrency:
    grep -l "concurrent\|parallel\|all\|fork" patterns/*.mdx
  • → Check
    run-effects-in-parallel-with-all.mdx
"How do I work with services?"
  • → Search services:
    grep -l "service\|layer\|dependency" patterns/*.mdx
  • → Check
    model-dependencies-as-services.mdx
    ,
    understand-layers-for-dependency-injection.mdx
"How do I validate data?"
  • → Search schema:
    grep -l "schema\|validate\|parse" patterns/*.mdx
  • → Check
    define-contracts-with-schema.mdx
    ,
    parse-with-schema-decode.mdx
“如何从...创建Effect?”
  • → 搜索构造器模式:
    grep -l "constructor" patterns/*.mdx
  • → 查看
    constructor-*.mdx
    文件
“如何在...时处理错误?”
  • → 搜索错误处理:
    grep -l "error\|catch\|retry" patterns/*.mdx
  • → 查看
    handle-*.mdx
    pattern-catchtag.mdx
“如何并发运行多个任务?”
  • → 搜索并发:
    grep -l "concurrent\|parallel\|all\|fork" patterns/*.mdx
  • → 查看
    run-effects-in-parallel-with-all.mdx
“如何使用服务?”
  • → 搜索服务:
    grep -l "service\|layer\|dependency" patterns/*.mdx
  • → 查看
    model-dependencies-as-services.mdx
    understand-layers-for-dependency-injection.mdx
“如何验证数据?”
  • → 搜索Schema:
    grep -l "schema\|validate\|parse" patterns/*.mdx
  • → 查看
    define-contracts-with-schema.mdx
    parse-with-schema-decode.mdx

Integration with Other Skills

与其他技能的集成

Foundations → Patterns Hub

基础 → 模式中心

When you need concrete examples for foundation concepts, check patterns:
  • effect-foundations
    teaches concepts → patterns show implementation
当你需要基础概念的具体示例时,查看模式:
  • effect-foundations
    教授概念 → 模式展示实现方式

Architect → Patterns Hub

架构师 → 模式中心

When designing systems, reference architectural patterns:
  • Layer composition →
    organize-layers-into-composable-modules.mdx
  • Service design →
    model-dependencies-as-services.mdx
  • Scoped resources →
    scoped-service-layer.mdx
设计系统时,参考架构模式:
  • Layer组合 →
    organize-layers-into-composable-modules.mdx
  • 服务设计 →
    model-dependencies-as-services.mdx
  • 作用域资源 →
    scoped-service-layer.mdx

Engineer → Patterns Hub

工程师 → 模式中心

When implementing features, find relevant patterns:
  • HTTP endpoints →
    handle-get-request.mdx
    ,
    validate-request-body.mdx
  • Error handling →
    retry-based-on-specific-errors.mdx
  • Concurrency →
    run-effects-in-parallel-with-all.mdx
实现功能时,查找相关模式:
  • HTTP端点 →
    handle-get-request.mdx
    validate-request-body.mdx
  • 错误处理 →
    retry-based-on-specific-errors.mdx
  • 并发 →
    run-effects-in-parallel-with-all.mdx

Tester → Patterns Hub

测试人员 → 模式中心

When writing tests, reference testing patterns:
  • Mock services →
    mocking-dependencies-in-tests.mdx
  • Test layers →
    use-default-layer-for-tests.mdx
  • Testable design →
    write-tests-that-adapt-to-application-code.mdx
编写测试时,参考测试模式:
  • 模拟服务 →
    mocking-dependencies-in-tests.mdx
  • 测试Layer →
    use-default-layer-for-tests.mdx
  • 可测试设计 →
    write-tests-that-adapt-to-application-code.mdx

Usage Workflow

使用流程

  1. Identify Need: "I need to [do something] with Effect"
  2. Check Decision Tree: Find relevant section above
  3. Read Pattern: Use
    Read
    tool on the pattern file
  4. Adapt to Context: Apply pattern to your specific use case
  5. Check Related: Follow
    related
    links in pattern frontmatter
  6. Consult Agent: If unclear, use
    @effect-engineer
    or
    @effect-architect
  1. 明确需求:“我需要用Effect做[某事]”
  2. 查看决策树:找到上方相关章节
  3. 阅读模式:使用
    Read
    工具打开模式文件
  4. 适配场景:将模式应用到你的具体场景
  5. 查看相关模式:跟随模式frontmatter中的
    related
    链接
  6. 咨询代理:如果有疑问,使用
    @effect-engineer
    @effect-architect

Anti-Pattern Detection

反模式检测

If you find yourself:
  • Using imperative loops → Check
    process-collection-in-parallel-with-foreach.mdx
  • Mixing promises and Effects → Check
    constructor-try-trypromise.mdx
    ,
    solve-promise-problems-with-effect.mdx
  • Long andThen chains → Check
    avoid-long-andthen-chains.mdx
    ,
    use-gen-for-business-logic.mdx
  • Leaking requirements → Check
    model-dependencies-as-services.mdx
  • Manual resource cleanup → Check
    safely-bracket-resource-usage.mdx
如果你发现自己在做以下事情:
  • 使用命令式循环 → 查看
    process-collection-in-parallel-with-foreach.mdx
  • 混合使用Promise和Effect → 查看
    constructor-try-trypromise.mdx
    solve-promise-problems-with-effect.mdx
  • 长andThen链 → 查看
    avoid-long-andthen-chains.mdx
    use-gen-for-business-logic.mdx
  • 泄露需求 → 查看
    model-dependencies-as-services.mdx
  • 手动清理资源 → 查看
    safely-bracket-resource-usage.mdx

Pattern File Structure

模式文件结构

Each pattern file follows this structure:
mdx
---
title: Human-readable title
id: kebab-case-id
skillLevel: beginner | intermediate | advanced
useCase: primary-use-case
summary: Brief description
tags:
  - keyword1
  - keyword2
related:
  - related-pattern-id-1
  - related-pattern-id-2
author: Author name
---
每个模式文件遵循以下结构:
mdx
---
title: 人类可读标题
id: kebab-case-id
skillLevel: beginner | intermediate | advanced
useCase: 主要使用场景
summary: 简短描述
tags:
  - keyword1
  - keyword2
related:
  - related-pattern-id-1
  - related-pattern-id-2
author: 作者名称
---

Title

标题

Guideline

指南

What to do
应该做什么

Rationale

原理

Why do it this way
为什么要这样做

Good Example

好示例

✅ Recommended approach
✅ 推荐方案

Bad Example

坏示例

❌ What to avoid
❌ 需要避免的做法

Related Patterns

相关模式

Links to related patterns
undefined
相关模式链接
undefined

Maintenance

维护

Patterns are synced from EffectPatterns repository.
To update patterns:
bash
cd /tmp
git clone --depth=1 https://github.com/PaulJPhilp/EffectPatterns.git
cp -r EffectPatterns/content/published/* /Users/pooks/Dev/crate/.claude/skills/effect-patterns-hub/patterns/
cp -r EffectPatterns/content/published/* /Users/pooks/Dev/crate/docs/effect-patterns/
模式从EffectPatterns仓库同步。
更新模式的步骤:
bash
cd /tmp
git clone --depth=1 https://github.com/PaulJPhilp/EffectPatterns.git
cp -r EffectPatterns/content/published/* /Users/pooks/Dev/crate/.claude/skills/effect-patterns-hub/patterns/
cp -r EffectPatterns/content/published/* /Users/pooks/Dev/crate/docs/effect-patterns/

Summary

总结

  • 130+ patterns covering all Effect-TS concepts
  • Decision tree for quick pattern lookup
  • Integration with existing skills and agents
  • Searchable by keyword, use case, skill level
  • Examples showing good and bad practices
  • Related patterns for deeper exploration
Use this skill as your go-to reference for "How do I... with Effect?"
  • 130+个模式,覆盖所有Effect-TS概念
  • 决策树,快速查找模式
  • 与现有技能和代理集成
  • 可按关键词、使用场景、技能水平搜索
  • 展示优劣实践的示例
  • 相关模式,深入探索
将此技能作为你解决“如何用Effect做...?”问题的首选参考。