Effect
Repositories built on the effect library — typed error handling, tagged constructors, Layers.
Repositories built on the effect library — typed error handling, tagged constructors, Layers.
Extends TypeScript — those rules apply too; this file only adds what's specific to Effect.
Which repositories get it
A repository on this profile: typescript-effect. redline init detects the profile and --profile overrides it — see Profiles & stacks.
Within such a repository, a file gets these rules when it matches one of these globs:
**/*.ts**/*.tsx**/*.mts**/*.cts
The 5 rules
When a review comment cites one of these ids, this is where to look up what it catches. Of the 5, 3 HIGH and 2 SUGGESTION. A finding from this file opens like this:
Redline/HIGH [effect/manual-error-tag-in-catch]: <one-line problem>What each severity obliges you to do is on The output contract.
| Rule id | Severity | Catches |
|---|---|---|
effect/manual-error-tag-in-catch | HIGH | Branching on `error._tag` (or `switch (error._tag)`) inside a broad `Effect.catch`/`catchAll`/`catchIf` handler. The error channel is not narrowed, so the handled error stays in the effect's type and every caller still has to handle it. Use `Effect.catchTag`/`catchTags` (or `catchReason`/`catchReasons` for a tagged `reason`). |
effect/manual-tagged-construction | HIGH | An object literal with a literal `_tag` (`{ _tag: "NotFound", id }`) where a tagged constructor exists. It skips the Schema's validation and the class's identity — `instanceof`, `Equal` and the error's stack trace — while looking identical to the type checker. Use the Schema `.make`, the tagged class or error constructor, or the `Data.taggedEnum` variant constructor. Not a pattern passed to `Match.when`. |
effect/service-constructor-import | HIGH | Runtime code importing a service's `make…` constructor from a relative path (`import { makeIssueService } from "./issue-service"`). The service's own requirements stop propagating to the composition root, and a test can no longer provide a different implementation. Import the owning `Layer` and yield the service from context. Test files are exempt. |
effect/manual-tag-comparison | SUGGESTION | Comparing `value._tag` to a string literal, or switching on it, outside a catch handler. `Match.tag`/`Match.tags` with `Match.exhaustive` makes a variant added later a compile error instead of a silent fall-through; `Predicate.isTagged` for a single reusable check. |
effect/prefer-match | SUGGESTION | A chained ternary comparing one value against two or more literals (`kind === "a" ? x : kind === "b" ? y : z`). Use `Match.value(kind).pipe(Match.when(…), …)`. |
Changing a rule
Edit standards/stacks/effect.md and nowhere else. Every other copy is generated from it. A merged change reaches every onboarded repository as a pull request, so treat it as a production change.
Rule ids are permanent. Reword a rule freely; it keeps its id. Renaming or removing an id orphans every telemetry record that cited it.
- Edit the markdownstandards/ is the only place a human edits a rule. AGENTS.md, CLAUDE.md, .github/copilot-instructions.md and .github/instructions/ are rendered from it, and the next render overwrites any hand edit there.
- node scripts/assign-rule-ids.mjsAssigns a permanent <stack>/<slug> id to any new rule bullet and rewrites the file in place. Do not invent an id by hand. CI runs the same script with --check and fails if a rule is missing one.
- node scripts/render-self.mjsRe-renders this repository's own copies of those files. CI runs it with --check, so a stale copy fails the build.
- Bump standards/manifest.json → versionIn the same pull request as the rule change. Sync pull requests quote the version, so every repository can tell which standards it is on.
- Add a CHANGELOG.md entryAlso in the same pull request. Say what changed and why, and record the seed score: a standards change with no measurement is an opinion.
- node scripts/validate.mjsThe self-check CI runs: the manifest is consistent, rule ids are well formed, the output contract is intact, and every glob is one Copilot can read.
Related
- The output contract — what each severity obliges you to do.
- Profiles & stacks — how a repository ends up with a set of rules.
- Seeded corpus: effect — the known-bad code that tests whether reviewers catch these rules.
- All standards
The full file
# Effect Review Rules
**Scope:** TypeScript in a repository built on the `effect` library. These rules extend the
TypeScript rules; they exist because Effect already ships the typed operator for each of
these jobs, and hand-rolling it discards what the type system was tracking. Do not apply
them to a repository that does not depend on `effect`.
## HIGH
- `effect/manual-error-tag-in-catch` — Branching on `error._tag` (or `switch (error._tag)`) inside a broad
`Effect.catch`/`catchAll`/`catchIf` handler. The error channel is not narrowed, so the handled error stays in the
effect's type and every caller still has to handle it. Use `Effect.catchTag`/`catchTags` (or
`catchReason`/`catchReasons` for a tagged `reason`).
- `effect/manual-tagged-construction` — An object literal with a literal `_tag` (`{ _tag: "NotFound", id }`) where a
tagged constructor exists. It skips the Schema's validation and the class's identity — `instanceof`, `Equal` and
the error's stack trace — while looking identical to the type checker. Use the Schema `.make`, the tagged
class or error constructor, or the `Data.taggedEnum` variant constructor. Not a pattern passed to `Match.when`.
- `effect/service-constructor-import` — Runtime code importing a service's `make…` constructor from a relative
path (`import { makeIssueService } from "./issue-service"`). The service's own requirements stop propagating to
the composition root, and a test can no longer provide a different implementation. Import the owning `Layer`
and yield the service from context. Test files are exempt.
## SUGGESTION
- `effect/manual-tag-comparison` — Comparing `value._tag` to a string literal, or switching on it, outside a catch
handler. `Match.tag`/`Match.tags` with `Match.exhaustive` makes a variant added later a compile error instead of a
silent fall-through; `Predicate.isTagged` for a single reusable check.
- `effect/prefer-match` — A chained ternary comparing one value against two or more literals
(`kind === "a" ? x : kind === "b" ? y : z`). Use `Match.value(kind).pipe(Match.when(…), …)`.