Effect Layers & Services

VerifiedSafe

Define services and layers for dependency injection with Effect. Compose infrastructure dependencies at application boundaries and easily switch between live and test implementations. Helps structure DI and keep business logic decoupled.

Sby Skills Guide Bot
DevelopmentIntermediate
3/4/2026
Claude Code
#effect-ts#dependency-injection#layers#services#typescript

Recommended for

Automated summary

This skill explains how to define Effect services, provide layers, and compose dependencies for dependency-injection boundaries and application wiring.

Strengths

  • Shows the `Effect.Service` pattern with a minimal user-repository example
  • Covers providing layers, merging with `Layer.merge`, and switching between test and live implementations
  • Includes concrete pitfalls such as circular layer dependencies and over-deep provisioning
  • Directs the agent to grep local Effect source files before writing code

Limitations

  • Code samples are very short and don't address services with asynchronous dependencies
  • Assumes the local `docs/effect-source/` checkout and the effect-docs MCP server are available
  • Offers little testing depth beyond a simple conditional layer selection
When to use it

Use it when introducing dependency-injection boundaries in an Effect application or when swapping live implementations for test doubles.

When not to use it

Skip it if you are not working with Effect TS or want generic dependency-injection advice for other frameworks.

Security analysis

Safe
Quality score80/100

The skill is documentation for Effect.ts dependency injection: it only declares Read/Grep/Glob/Edit/Write plus a docs-search MCP tool and contains illustrative code snippets. The grep examples are guidance for searching local source, not executable payloads, and there is no network exfiltration, destructive command, obfuscation, or safety-disabling instruction. Write/Edit are used only for editing the user's own Effect source files, which is the stated purpose.

No concerns found

How this analysis is made

Examples

Provide a service layer
In my Effect TS app, I have a UserRepo defined with Effect.Service. Show me how to provide UserRepo.Default to my program and compose it with Logger.Default into a single AppLayer.
Swap test and live layers
Help me switch between a UserRepoTest layer and UserRepo.Default based on NODE_ENV, and explain where in the app boundary I should wire this up.
Fix circular layer dependency
My Effect layers have a circular dependency between Db and UserRepo. Search docs/effect-source/effect/src/Layer.ts and help me restructure the modules so I can provide the layer from above.

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

  • Foundations: requirement channel R and provisioning
  • Resources: scoped resources exposed via layers
  • EffectPatterns inspiration: https://github.com/PaulJPhilp/EffectPatterns

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

  • Agent Skills overview: https://www.anthropic.com/news/skills
  • Skills guide: https://docs.claude.com/en/docs/claude-code/skills

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/effect-layers-services-mmbizjmp/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/effect-layers-services-mmbizjmp' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/effect-layers-services-mmbizjmp/download' --output '.skill-downloads/effect-layers-services-mmbizjmp/SKILL.md.part' && mv '.skill-downloads/effect-layers-services-mmbizjmp/SKILL.md.part' '.skill-downloads/effect-layers-services-mmbizjmp/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Grep, Glob, Edit, Write, mcp__effect-docs__effect_docs_search

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/effect-layers-services-mmbizjmp/SKILL.md' && test -s '.skill-downloads/effect-layers-services-mmbizjmp/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/effect-layers-services' && cp -R '.skill-downloads/effect-layers-services-mmbizjmp' '.claude/skills/effect-layers-services'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/effect-layers-services-mmbizjmp'

openskills read 'effect-layers-services-mmbizjmp'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/effect-layers-services-mmbizjmp/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills