effect-services-layers
Skill1 starsChanged 6 months agoMITView on GitHub
Use when defining or wiring Effect services in Theseus, including Context.Service, service interfaces, Layer.effect/succeed/mergeAll/provideMerge, dependency graphs, runtime construction, and test seams.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-self-checkSkill
- biome-grit-rulesSkill
- biome-toolingSkill
- bun-testSkill
- bun-workspaceSkill
- cleanup-auditSkill
- code-reviewSkill
- dispatch-satelliteSkill
- docs-managementSkill
- docs-readingSkill
- effect-concurrency-lifecycleSkill
- effect-errors-schemaSkill
- effect-observability-timeSkill
- effect-testing-runtimeSkill
- effect-v4Skill
- jsx-md-authoringSkill
- monorepo-maintenanceSkill
- refactoring-disciplineSkill
- roadmap-managementSkill
- runtime-engineSkill
- server-runtimeSkill
- testing-patternsSkill
- theseus-designSkill
- tool-authoringSkill
- typescript-strictSkill
- ui-layout-disciplineSkill
- theseus-designSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 3 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill for replaceable dependencies and runtime wiring.
- Distinctive: line 12
Search current service/layer patterns before adding a new style.
- Distinctive: line 15
Keep service interfaces free of construction details.
- Very specific: line 41
Do not cargo-cult Effect.Service unless local v4 types and repo patterns support it for the case at hand.
- Very specific: line 43
Use Layer.succeed(Service)(implementation) when the implementation already exists.
- Very specific: line 44
Use Layer.effect(Service)(effect) when construction needs effects or dependencies.
- Very specific: line 46
Use Layer.provideMerge when wiring dependencies into another layer while preserving provided services.
- Very specific: line 47
Avoid repeated Effect.provide inside hot paths.
- Very specific: line 55
Do not call Effect.runPromise or Effect.runSync inside services.
≈ “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.
Files
Effect Services And Layers
Use this skill for replaceable dependencies and runtime wiring. Keep domain methods as effects and construction in layers.
Workflow
- Search current service/layer patterns before adding a new style.
- Inspect local Effect type declarations for unfamiliar
ContextorLayerAPIs. - Decide whether the dependency is a primitive contract, infrastructure adapter, runtime service, or test seam.
- Keep service interfaces free of construction details.
Service Shape
import { Context, Effect, Layer } from "effect"
interface UsersService {
readonly find: (id: UserId) => Effect.Effect<User, UserNotFound>
}
export class Users extends Context.Service<Users, UsersService>()("Users") {}
export const UsersLive = Layer.effect(Users)(
Effect.gen(function* () {
const db = yield* Db
return Users.of({
find: (id) => db.queryUser(id),
})
}),
)Rules:
- This repo currently prefers
Context.Service<Service, Shape>()("Name"). - Do not cargo-cult
Effect.Serviceunless local v4 types and repo patterns support it for the case at hand. - Declare service requirements in return types; do not hide them with
any. - Use
Layer.succeed(Service)(implementation)when the implementation already exists. - Use
Layer.effect(Service)(effect)when construction needs effects or dependencies. - Compose same-level layers with
Layer.mergeAll. - Use
Layer.provideMergewhen wiring dependencies into another layer while preserving provided services. - Avoid repeated
Effect.provideinside hot paths; provide layers at composition boundaries.
Boundaries
- Runtime services, clocks, random/id generation, stores, language models, and mutable context should be read from the Effect environment at execution time.
- Constructors and factories may capture static configuration.
- Constructors/builders should shape data and service values only. They should not perform I/O, allocate runtime resources, read config, call providers, or start fibers.
- Runtime code should avoid ambient
Date.now(),new Date(),Math.random(), andcrypto.randomUUID(). Use services/layers or explicit injected providers; boundary adapters and tests may wrap those primitives. - Do not call
Effect.runPromiseorEffect.runSyncinside services. Run effects at process, test, or script edges. - For test seams, provide alternate layers instead of conditionals inside production services.
Checks
- Is this dependency replaceable in tests?
- Does the service interface expose behavior, not its implementation backend?
- Did layer wiring preserve requirements the caller still needs?
- Did the change introduce a package dependency in the wrong direction?
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
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.

