Claude Code Plugins

Community-maintained marketplace

Feedback

effect-layers-services

@mepuka/crate
0
0

Define services, provide layers, compose dependencies, and switch live/test. Use for DI boundaries and app composition.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name effect-layers-services
description Define services, provide layers, compose dependencies, and switch live/test. Use for DI boundaries and app composition.
allowed-tools Read, Grep, Glob, Edit, Write, mcp__effect-docs__effect_docs_search

Layers & Services

When to use

  • You need DI boundaries or swapping test/live implementations
  • You want to compose infra (logger, db, http) once for the app

Define Service

class UserRepo extends Effect.Service<UserRepo>()("UserRepo", {
  sync: () => ({ find: (id: string) => Effect.succeed({ id }) })
}) {}

Provide Layer

const program = Effect.gen(function* () {
  const repo = yield* UserRepo
  return yield* repo.find("123")
}).pipe(Effect.provide(UserRepo.Default))

Compose

const AppLayer = Layer.merge(UserRepo.Default, Logger.Default)

Test vs Live

const layer = process.env.NODE_ENV === "test" ? UserRepoTest : UserRepo.Default

Guidance

  • Services define interfaces; Layers bind implementations
  • Compose layers at the app boundary; keep handlers unaware of wiring
  • Use .Default for quick live/test setup; add custom layers as needed

Pitfalls

  • Circular layer dependencies → split modules, provide from above
  • Providing layers too deep → centralize to avoid duplication and confusion

Cross-links

Local Source Reference

CRITICAL: Search local Effect source before implementing

The full Effect source code is available at docs/effect-source/. Always search the actual implementation before writing Effect code.

Key Source Files

  • Layer: docs/effect-source/effect/src/Layer.ts
  • Effect: docs/effect-source/effect/src/Effect.ts
  • Context: docs/effect-source/effect/src/Context.ts

Example Searches

# Find Layer composition patterns
grep -F "Layer.merge" docs/effect-source/effect/src/Layer.ts
grep -F "Layer.provide" docs/effect-source/effect/src/Layer.ts

# Study Effect.Service patterns
grep -F "Effect.Service" docs/effect-source/effect/src/Effect.ts

# Find Context usage
grep -F "Tag" docs/effect-source/effect/src/Context.ts
grep -F "make" docs/effect-source/effect/src/Context.ts

# Look at Layer test examples
grep -F "Layer." docs/effect-source/effect/test/Layer.test.ts

Workflow

  1. Identify the Layer or Service API you need
  2. Search docs/effect-source/effect/src/Layer.ts for the implementation
  3. Study the types and composition patterns
  4. Look at test files for usage examples
  5. Write your code based on real implementations

Real source code > documentation > assumptions

References