Skip to content

Guardrails for Coding Agents

An agent edits an Effect program and widens its error channel from a tagged error to Error. TypeScript compiles it, oxlint passes, and the PR reads as a small change. The error channel is a property of the whole program, so a check that looks at one expression at a time has nothing to complain about.

The official Effect diagnostics from @effect/tsgo cover the expression scope. They report an unused floating effect, or an R that still needs UserRepository, in a sentence the agent can act on. effect-analyzer runs them by default. This page covers the layer above: what a program requires, what it can fail with, how it retries, and which services it reaches.

An agent needs to answer two questions from a check: is this mine to fix, and did this run actually pass. Both are answerable without parsing message text.

Every diagnostic carries a source — tsgo for a type-aware Effect language service diagnostic, analyzer for one of ours — and language service entries carry their code in the 377xxx range. An entry outside that range is not an Effect advisory, and none of these are TypeScript compiler errors, which neither tool emits. Analyzer rules carry code: 0.

The exit status is a deliberate contract, not a side effect:

Terminal window
# Advisory: reports everything, never changes the exit status.
npx effect-analyze ./src --lint-source
# Gated: exit 1 when any finding is at or above the given severity.
npx effect-analyze ./src --lint-source --fail-on=error

For diagnostics, the exit code is effect-tsgo’s own — 1 on any error, and with --strict on any warning — and --fail-on overrides it, with --fail-on=none for a purely advisory run.

Terminal window
npx effect-analyze ./src --agent-report
Agent Report Summary
====================
Files: 52 | Programs: 345 | Unknown: 0.0%
Lint: 0 errors, 37 warnings, 111 infos
Error channel: 0 | Service health: 4 | Performance: 0 | Coupling: 0
Total improvements: 36
P1 (Important): 5
P2 (Recommended): 31
Top improvements:
[P1] Replace throw new Error with Effect.fail(tagged error) (3x, medium)
[P1] Use Ref or Atomic for shared state in concurrent code (2x, medium)
[P1] Use Effect.suspend or flatMap instead of sync returning Effect (1x, low)

Each entry carries a file and line, a suggestion, and an effort estimate, so an agent picks up the top item and works down instead of guessing at priorities. Point your agent at the markdown report, or parse the JSON.

Add --improve to apply the fixes the analyzer makes on its own, and --improve-dry-run to read them first. See Improve Mode & Agent Report.

Record a baseline once, on main:

Terminal window
npx effect-analyze ./src --lint-source -o .cache/effect-baseline.json

Check every branch against it:

Terminal window
npx effect-analyze ./src --lint-source --baseline .cache/effect-baseline.json --fail-on-new
"baseline": {
"new": 0,
"resolved": 0,
"unchanged": 148
}

The analyzer fingerprints each finding, so moving code between files does not trip the gate. It exits 1 when a finding appears that your baseline does not contain, and your agent can read that failure and regenerate against it rather than waiting for you to repeat the same correction. Findings your team fixes drop out of the report, so the baseline shrinks as the codebase improves.

See the Source Linter for the rule list and SARIF output.

Terminal window
npx effect-analyze HEAD:src/transfer.ts src/transfer.ts --diff
# Effect Program Diff: sendMoney → sendMoney
| Metric | Count |
|--------|-------|
| Added | 6 |
| Renamed | 1 |
| Unchanged | 7 |
| Structural changes | 2 |
+ **FraudScreening** (added)
+ **fraud.screen** (added)
+ **notifications.sendConfirmation** (added)
## Structural Changes
- + pipe block added
- + retry block added

The text diff for that change reports 45 added lines and leaves you to work out what they do. The semantic diff names the services that arrived and the retry block that wrapped the transfer.

--diff reports and always exits 0. Post it as a PR comment for a human, or pipe it back to an agent that needs to know what its last edit did. Use --format json for machine consumption, --format mermaid for a diagram, and --regression to flag removed programs.

For gates that fail a build, use --fail-on-new above, --assert-diagram-fidelity, the audit policy flags, or --format statechart-coverage --min-coverage.

See Semantic Diff and What a text diff misses.

- run: npx effect-analyze ./src --lint-source --baseline .cache/effect-baseline.json --fail-on-new
- run: npx effect-analyze ./src --coverage-audit --quiet --max-audit-failed-files 0
- if: always()
run: |
npx effect-analyze "origin/main:src/transfer.ts" src/transfer.ts --diff \
>> "$GITHUB_STEP_SUMMARY"

The first two steps fail the build and give your agent something to fix. The third runs either way and puts the shape change in the job summary, where you read it before approving.

effect-analyze mcp serves the analyzer to a coding agent over stdio. Add it to Claude Code:

Terminal window
claude mcp add effect-analyzer -- npx -y -p effect-analyzer effect-analyze mcp

Or to any client’s MCP config:

{
"mcpServers": {
"effect-analyzer": {
"command": "npx",
"args": ["-y", "-p", "effect-analyzer", "effect-analyze", "mcp"]
}
}
}

The agent gets five read-only tools, each a wrapper around a command on this page:

Tool What it returns
analyze One file’s programs as a summary, a plain-language walk, the IR, or a Mermaid diagram
review The review report for a git change, state leads included, as markdown or JSON
lint Source rule findings for a file or directory, with typeAware for the Effect language service
ref_map Each Ref’s readers and writers, and writers that skip a companion call
explain_rule One rule’s rationale and bad/good example

The server also publishes the effect-analyze skill over the Skills extension, so the agent loads the review and state-bug method from the server it already uses. The skill updates with each release.

The server speaks MCP 2026-07-28 and still answers clients on the 2025 handshake. It reads the paths you name, relative to the directory the client starts it in, and writes nothing.

The analyzer reads source. It sees the retry policy you wrote, not how often that policy fired last night, and it cannot tell you which of the paths in a diagram production traffic reaches. Pass OpenTelemetry spans to renderMermaidWithRuntimeTrace to overlay a real trace onto a static diagram. Your observability stack still owns the rest.