agentleFS
artimathartimath/effect-skills/skills/effectts/SKILL.md

effectts

Skill8 starsChanged 9 months agoMITView on GitHub

Idiomatic Effect-TS patterns for TypeScript functional programming. USE THIS SKILL WHEN: Writing new Effect services or layers, debugging Effect type errors (layer composition, error types), choosing between Effect patterns, setting up Effect testing. TRIGGERS ON: 'effect pattern', 'Layer.provide', 'Context.Tag', 'effect service', 'effect error', 'effect test', 'idiomatic effect'. NOT FOR: general TypeScript without Effect.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write Effect code that looks like it came from the Effect core team.

    line 9
  2. Distinctive:

    If you have effect-mcp configured:

    line 20

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Idiomatic Effect-TS

Write Effect code that looks like it came from the Effect core team.

Prerequisites (Optional)

Research First (ALWAYS)

1. Effect Docs MCP (preferred for concepts)

If you have effect-mcp configured:

// Search documentation
mcp__effect-docs__effect_docs_search({ query: "Layer composition" })

// Then read specific doc
mcp__effect-docs__get_effect_doc({ documentId: 123 })

Otherwise, check https://effect.website/docs for API reference.

2. Effect Source (preferred for real patterns)

# Clone Effect source for pattern verification (if not already done)
# git clone https://github.com/Effect-TS/effect <effect-repo>

# Service patterns (Context.Tag for libraries)
rg "class .* extends Context\.Tag" <effect-repo>/packages/workflow/src
rg "class .* extends Context\.Tag" <effect-repo>/packages/cluster/src

# Effect.Service for concrete impls/tests
rg "Effect\.Service" <effect-repo>/packages/cluster/src

# Error patterns
rg "Schema\.TaggedError" <effect-repo>/packages/cluster/src

# Layer composition
rg "Layer.provideMerge" <effect-repo>/packages/platform/src

Use parallel searches when patterns are unclear.

Quick Reference

Service Patterns (Choose Based on Use Case)

PatternUse WhenLayer Access
Context.TagLibrary interfaces, multiple implsServiceName.Live
Effect.ServiceConcrete impls, tests, appsServiceName.Default
// Library interface (Context.Tag) - canonical for libraries
export class MyService extends Context.Tag("app/MyService")<MyService, {
  readonly doThing: (x: string) => Effect.Effect<Result, MyError>
}>() {
  static readonly Live: Layer.Layer<MyService, never, Deps> = Layer.effect(...)
}

// Concrete impl (Effect.Service) - convenient for apps/tests
export class AppCache extends Effect.Service<AppCache>()("app/Cache", {
  effect: Effect.gen(function* () {
    return { get: (k) => ..., set: (k, v) => ... }
  }),
  dependencies: [SomeDep.Default]  // auto-composed
}) {}

Domain Errors

export class MyError extends Schema.TaggedError<MyError>()("MyError", {
  reason: Schema.Literal("NotFound", "Invalid"),
  cause: Schema.optional(Schema.Defect)
}) {
  static is(u: unknown): u is MyError {
    return hasProperty(u, "_tag") && isTagged(u, "MyError")
  }
}

Domain Types

// Value objects
export class Address extends Schema.Class<Address>("Address")({
  host: Schema.String,
  port: Schema.Number
}) {}

// Branded IDs — always with REAL constraints
export const UserId = Schema.NonEmptyString.pipe(
  Schema.pattern(/^usr_[a-z0-9]+$/),
  Schema.brand("UserId")
)
export type UserId = typeof UserId.Type

Layer Composition — COMMON GOTCHA

This causes most Effect type errors. Know the difference:

MethodDeps SatisfiedAvailable to ProgramUse When
Layer.provideYesNoInternal layer building
Layer.provideMergeYesYesTests using multiple services
Layer.mergeAllNoYesCombining independent layers
// WRONG - test can't access FileSystem
const TestLive = MyService.Live.pipe(Layer.provide(PlatformLive))
// yield* FileSystem.FileSystem -> ERROR

// RIGHT - both services available
const TestLive = MyService.Live.pipe(Layer.provideMerge(PlatformLive))
// yield* MyService -> works
// yield* FileSystem.FileSystem -> also works!

Error pattern to recognize:

Effect<A, E, SomeService> is not assignable to Effect<A, E, never>

or diagnostic: Missing 'SomeService' in the expected Effect context

-> Means SomeService still required. Use provideMerge instead of provide.

Test Pattern

it.effect("works", () =>
  Effect.gen(function* () {
    const svc = yield* MyService
    expect(yield* svc.doThing("x")).toBe(expected)
  }).pipe(Effect.provide(TestLive))  // <- MUST provide at boundary
)

References (Read When Needed)

TopicFileWhen to Read
Service & Layer patternsreferences/services.mdCreating services, Context.Tag vs Effect.Service, layer composition
Layer dependenciesreferences/layer-dependencies.mdHow services access deps (yield + closure), why NOT factory functions
Schema decision matrixreferences/schema-decision.mdSchema.Class vs Struct vs TaggedClass, branded types, migration patterns
Error handlingreferences/errors.mdSchema.TaggedError, TypeId, refail patterns
Domain typesreferences/domain-types.mdSchema.Class, branded types, TaggedRequest
Testingreferences/testing.md@effect/vitest setup, TDD workflow, test helpers
Collections & Statereferences/data.mdChunk, Option, Ref patterns
Process managementreferences/processes.mdScope, Command, background processes

Anti-Patterns

Anti-PatternFix
Data.TaggedError for domain errorsUse Schema.TaggedError
Layer.mergeAll with dependent layersUse Layer.provideMerge
try/catch in Effect.genUse Effect.try or mapError
Missing Effect.provide(...) in testsAlways provide at test boundary
Plain interfaces for domain typesUse Schema.Struct (or Schema.Class if needs behavior)
String IDs without brandingUse Schema.brand()
Guessing patternsGrep Effect source first
Effect.Service for library interfacesUse Context.Tag
Factory function with service paramYield deps in Effect.gen, close over (see layer-dependencies.md)
Schema.Class for simple DTOsUse Schema.Struct unless needs Equal/Hash
String literal union in structUse Schema.TaggedClass for variants
Phantom type & { _tag }Use Schema.brand() for runtime validation
Bare Schema.String.pipe(Schema.brand(...))Add real constraints: NonEmptyString, pattern(), etc.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.