mpsuesser/pi-effect-harness/effect-managed-runtime
Claude Code and agent skill by mpsuesser/pi-effect-harness
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Bridge Effect services into non-Effect frameworks (Hono, Express, Fastify, Lambda, Workers) using ManagedRuntime. Use this skill when you need to run Effects outside of runMain — in HTTP handlers, serverless functions, or any embedded context where Effect doesn't own the process lifecycle.
Install
npx vskill@latest install mpsuesser/pi-effect-harness/effect-managed-runtimeSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as mpsuesser/pi-effect-harness/effect-managed-runtime.
You are an Effect TypeScript expert specializing in integrating Effect services into external frameworks using ManagedRuntime.
Effect Source Reference
The Effect v4 source is available at ~/.cache/effect-v4/. Browse and read files there directly to look up APIs, types, and implementations.
Reference this for:
packages/effect/src/ManagedRuntime.ts— full API surfaceai-docs/src/03_integration/10_managed-runtime.ts— Hono integration example
When to Use ManagedRuntime
Use ManagedRuntime when Effect does not own the process lifecycle. This is the bridge pattern — your domain logic lives in Effect services and layers, but the outer framework (Hono, Express, Fastify, Koa, AWS Lambda, Cloudflare Workers, etc.) controls the HTTP server, routing, and process lifecycle.
Typical scenarios:
- Web frameworks: Hono, Express, Fastify, Koa handlers that call Effect services
- Serverless functions: AWS Lambda, Cloudflare Workers, Vercel Edge Functions
- Embedded contexts: Running Effect inside a larger non-Effect application
- Tests: Creating a runtime with test layers for integration testing
Do NOT use ManagedRuntime when:
- Effect owns the entire process → use
NodeRuntime.runMain/BunRuntime.runMain - You have a long-running Effect service that IS the application → use
Layer.launch
Core API
Creating a ManagedRuntime
Signature:
The ManagedRuntime<R, ER> type parameters:
R— the services provided by the runtime (available to effects you run)ER— errors that can occur during layer construction
Shared MemoMap
When using multiple ManagedRuntime instances in the same application, share a MemoMap so that memoized layers (the default) are built only once:
If you only have a single ManagedRuntime, you can omit the memoMap option — one is created automatically.
Running Effects
A ManagedRuntime provides all the standard run methods. The runtime automatically provides the services from its layer to every effect you run.
runtime.runPromise(effect) — Async execution (most common)
Returns a Promise<A>. Rejects with the first error or exception. Use this in async HTTP handlers, Lambda handlers, etc.
runtime.runSync(effect) — Synchronous execution
Throws if the effect is async or fails. Use sparingly — only when you are certain the effect is synchronous.
runtime.runFork(effect) — Fire and forget
Returns a Fiber<A, E | ER>. The effect runs in the background. Use for fire-and-forget work.
runtime.runCallback(effect) — Callback-style execution
Use for callback-only APIs (e.g., some Node.js patterns).
runtime.runPromiseExit(effect) / runtime.runSyncExit(effect)
Return Exit<A, E | ER> instead of throwing — useful when you want to inspect failures structurally.
Lifecycle Management
ManagedRuntime owns the scope of the layers it builds. When you dispose the runtime, all resources acquired during layer construction (database pools, HTTP clients, file handles, etc.) are released.
Disposing the runtime
Shutdown hook pattern
Critical: Always dispose ManagedRuntime on shutdown. Unlike runMain which handles this automatically, ManagedRuntime requires explicit lifecycle management.
Integration Patterns
Hono
Express
AWS Lambda
Cloudflare Workers
ManagedRuntime vs Layer.launch
| ManagedRuntime | Layer.launch | ||
|---|---|---|---|
| Who owns the process? | External framework | Effect | |
| Use case | Bridge to Hono/Express/Lambda/etc. | Effect IS the application | |
| How to run effects | runtime.runPromise(effect) | Effects run inside the layer graph | |
| Lifecycle | Manual dispose on shutdown | Automatic — runs until interrupted | |
| Typical shape | Web handler calls runtime.runPromise | Layer.launch(pipe(...layers)) in runMain |
Use Layer.launch when Effect is the entire application — it builds the layer, runs it, and tears it down when the process exits. Use ManagedRuntime when you need to call into Effect from non-Effect code.
ManagedRuntime vs runMain
| ManagedRuntime | runMain | ||
|---|---|---|---|
| Context | Embedded in another framework | Effect owns the process | |
| Signal handling | Manual (you wire SIGINT/SIGTERM) | Automatic | |
| Scope management | Manual dispose | Automatic | |
| Multiple entry points | Yes — many handlers share one runtime | Single entry point |
runMain is for CLI apps and standalone Effect services. ManagedRuntime is for when your Effect code lives inside a larger system.
Type-Level Utilities
Extract service and error types from a ManagedRuntime:
Guard
Common Mistakes
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingharnesses/effect/skills/effect-managed-runtime/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mpsuesser/pi-effect-harness/effect-managed-runtime)