|
1 | 1 | --- |
2 | 2 | name: effect-ts-guide |
3 | | -description: Teach and apply Effect-TS practices (effect, @effect/schema, @effect/platform) for architecture, typed errors, Layers, dependency injection, resource safety, testing, and migration from async/await/Promise. Use when a user asks how to use Effect, requests best practices, wants to refactor to Effect, or needs mapping from platform modules to Node/Bun/Browser APIs. |
| 3 | +description: Effect-TS guidance for architecture, typed errors, Layers, boundary validation, resource safety, compliance checks, and editor tooling. Use when a task is explicitly about reviewing or implementing Effect or @effect/* application and library code, refactoring code to Effect, validating Effect-style conventions, or wiring Effect editor/language-service setup. Do not use for generic package publishing or plugin scaffolding tasks unless the code under review is the Effect code itself. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | # Effect TS Guide |
7 | 7 |
|
8 | | -## Overview |
| 8 | +## Workflow |
9 | 9 |
|
10 | | -Use this skill to teach Effect-TS fundamentals and best practices, then apply them to user code and architecture questions. |
| 10 | +1. Confirm the codebase or request is actually Effect-oriented. If it is not, stop and do not force this skill. |
| 11 | +2. Run the quick compliance check first: |
11 | 12 |
|
12 | | -## Teaching workflow |
| 13 | +```bash |
| 14 | +SKILL_DIR=<directory containing this SKILL.md> |
| 15 | +bash "$SKILL_DIR/scripts/run-effect-ts-check.sh" . |
| 16 | +``` |
13 | 17 |
|
14 | | -1. Clarify context: runtime (node/bun/browser), goal (new app, refactor, review), and constraints. |
15 | | -2. Separate core vs shell: identify pure domain logic vs effects and boundaries. |
16 | | -3. Model errors and dependencies: define tagged error types and Context.Tag service interfaces. |
17 | | -4. Compose with Effect: use pipe/Effect.gen, typed errors, and Layer provisioning. |
18 | | -5. Validate inputs at boundaries with @effect/schema before entering core. |
19 | | -6. Explain resource safety: acquireRelease, scoped lifetimes, and clean finalizers. |
20 | | -7. Provide minimal, runnable examples tailored to the user context. |
21 | | -8. If the user asks for version-specific or "latest" details, verify with official docs before answering. |
| 18 | +If the repository is mostly tooling, docs, or test fixtures for the checker itself, scope the command to the relevant Effect source directories instead of blindly linting the whole workspace. |
22 | 19 |
|
23 | | -## Core practices (short list) |
| 20 | +3. For stricter product-code policy checks, run: |
24 | 21 |
|
25 | | -- Use Effect for all side effects; keep core functions pure and total. |
26 | | -- Avoid async/await, raw Promise chains, and try/catch in application logic. |
27 | | -- Use Context.Tag + Layer for dependency injection and testability. |
28 | | -- Use tagged error unions and Match.exhaustive for total handling. |
29 | | -- Decode unknown at the boundary with @effect/schema; never leak unknown into core. |
30 | | -- Use Effect.acquireRelease/Effect.scoped for resource safety. |
31 | | -- Use @effect/platform services instead of host APIs (fetch, fs, child_process, etc.). |
| 22 | +```bash |
| 23 | +bash "$SKILL_DIR/scripts/run-effect-ts-check.sh" <effect-source-paths> --profile strict |
| 24 | +``` |
| 25 | + |
| 26 | +4. If the repository wants the official Effect dprint formatting gate too, run: |
| 27 | + |
| 28 | +```bash |
| 29 | +bash "$SKILL_DIR/scripts/run-effect-ts-check.sh" <effect-source-paths> --profile strict-format |
| 30 | +``` |
| 31 | + |
| 32 | +5. Fix the violations that are machine-detectable. |
| 33 | +6. Apply the manual rules from the references for architecture and style decisions. |
| 34 | +7. Re-run the relevant check before finishing. |
| 35 | + |
| 36 | +For editor integration tasks, treat `effect-ts-check` as the reusable CLI/compliance package and `@effect/language-service` plus VSCode settings/extensions as a separate setup concern. |
| 37 | + |
| 38 | +The skill is intentionally self-contained. Resolve `scripts/run-effect-ts-check.sh` relative to the skill directory so the same instructions work for standalone installs, repo-local skills, and plugin-contributed skills without hardcoding `~/.codex`. |
| 39 | + |
| 40 | +## What The Check Covers |
| 41 | + |
| 42 | +The compliance check is for fast, repeatable signals: |
| 43 | + |
| 44 | +- direct `async/await` |
| 45 | +- raw `Promise` usage |
| 46 | +- `try/catch` in product code |
| 47 | +- `switch` |
| 48 | +- `require` |
| 49 | +- common JavaScript and TypeScript module extensions, including `.jsx`, `.mts`, and `.cts` |
| 50 | + |
| 51 | +The `strict` profile also layers in unsafe host import checks, obvious typing-policy violations such as `any` and `ts-ignore`, direct `fetch`, eslint-disable hygiene, thrown-literal checks, and path-aware CORE boundary rules for casts, `unknown`, `catchAll`, CORE-to-SHELL imports, and runtime execution calls such as `Effect.runPromise` / `Effect.runSync`. |
| 52 | + |
| 53 | +The `strict-format` profile runs `strict` plus the official `@effect/dprint` formatting preset. Use it when formatting should be part of the compliance gate; use `strict` when you need semantic policy results without formatting noise. |
| 54 | + |
| 55 | +The wrapper uses `npx` with a bundled `effect-ts-check` tarball. It can run from a standalone skill install, but npm registry access or an npm cache is required for package dependencies. |
| 56 | + |
| 57 | +## What Still Needs Judgment |
| 58 | + |
| 59 | +The check does not replace architectural reasoning. Apply manual rules for: |
| 60 | + |
| 61 | +- CORE vs SHELL boundaries |
| 62 | +- typed error design |
| 63 | +- Layer and dependency injection shape |
| 64 | +- boundary decoding with `@effect/schema` |
| 65 | +- resource safety with `Effect.acquireRelease` and `Effect.scoped` |
| 66 | +- exhaustive handling of unions |
| 67 | +- project-specific service factories, local package boundaries, and allowed runtime entrypoint layouts outside the default CORE/SHELL convention |
32 | 68 |
|
33 | 69 | ## References |
34 | 70 |
|
35 | | -- Read `references/best-practices.md` for the extended checklist and examples. |
36 | | -- Read `references/platform-map.md` when comparing @effect/platform to Node/Bun/Browser APIs. |
| 71 | +- [Best Practices](references/best-practices.md) |
| 72 | +- [Platform Map](references/platform-map.md) |
| 73 | +- [Lint Checks](references/lint-checks.md) |
| 74 | +- [Manual Writing Rules](references/manual-writing-rules.md) |
| 75 | +- [Editor Tooling](references/editor-tooling.md) |
0 commit comments