effect-patterns-hub
npx skills add https://github.com/mepuka/effect-ontology --skill effect-patterns-hub
Agent 安装分布
Skill 文档
Effect Patterns Hub
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.
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
Pattern Library Location
Local Patterns: .claude/skills/effect-patterns-hub/patterns/
Documentation: docs/effect-patterns/
Count: 130+ patterns in MDX format
Quick Decision Tree
I need to…
Create Effects
- 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
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
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
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
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
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
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
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
Schema & Validation
- 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
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
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
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
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
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
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
Configuration
- Access config â
access-config-in-context.mdx - Define schema â
define-config-schema.mdx - Provide 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
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
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
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)
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
Search Patterns
By Keyword
Use Grep to search patterns by keyword:
# Find patterns about error handling
grep -l "error" patterns/*.mdx
# Find patterns about concurrency
grep -l "concurrent\|parallel\|fiber" patterns/*.mdx
# Find patterns about HTTP
grep -l "http\|server\|client" patterns/*.mdx
# Find patterns about testing
grep -l "test\|mock" patterns/*.mdx
By Frontmatter Tags
All patterns include metadata:
title: Human-readable nameid: Unique identifier (filename without extension)skillLevel: beginner, intermediate, advanceduseCase: domain-modeling, error-handling, concurrency, etc.summary: Brief descriptiontags: Keywords for searchingrelated: Links to related patterns
Common Searches
“How do I create an Effect from…”
- â Search constructor patterns:
grep -l "constructor" patterns/*.mdx - â Check
constructor-*.mdxfiles
“How do I handle errors when…”
- â Search error handling:
grep -l "error\|catch\|retry" patterns/*.mdx - â Check
handle-*.mdxandpattern-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
Integration with Other Skills
Foundations â Patterns Hub
When you need concrete examples for foundation concepts, check patterns:
effect-foundationsteaches concepts â patterns show implementation
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
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
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
Usage Workflow
- Identify Need: “I need to [do something] with Effect”
- Check Decision Tree: Find relevant section above
- Read Pattern: Use
Readtool on the pattern file - Adapt to Context: Apply pattern to your specific use case
- Check Related: Follow
relatedlinks in pattern frontmatter - Consult Agent: If unclear, use
@effect-engineeror@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
Pattern File Structure
Each pattern file follows this structure:
---
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
---
# 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
Maintenance
Patterns are synced from EffectPatterns repository.
To update patterns:
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?”