effect-service-architecture

A set of architecture rules for Effect-TS, a TypeScript library for building programs with explicit services and error handling. It covers data stores, use cases, request handlers, imports, and tests.

In plain words
What is it for?
Use it when designing or reviewing Effect-TS stores, business operations, handlers, service dependencies, and their tests.
Why use it?
It gives developers consistent ways to organize application code as it grows. It helps avoid unclear service boundaries and incorrect internal import patterns.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/charlee-x/effect-cursor-rules/effect-service-architecture
Clone the repo
git clone --depth 1 https://github.com/CharLEE-X/effect-cursor-rules
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,173 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00022 $0.05173
Opus 5 $0.00011 $0.02586
Sonnet 5 $0.00004 $0.01035
Haiku 4.5 $0.00002 $0.00517

Measured 3d ago against content hash dd05693eb980, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

effect-service-architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/effect-service-architecture.mdc · 700 lines

How it starts

The opening of the file, as written. The whole thing — 700 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Effect-TS Service Architecture Patterns and Best Practices

1. Import Patterns

Always Use Relative Paths for Internal Imports

  • CRITICAL: Never use src/ aliases for internal imports
  • Always use relative paths like ../../stores/blog/blog-store.js
  • Use package imports only for external dependencies
// ✅ CORRECT - Relative paths for internal imports
import { BlogStore } from '../../stores/blog/blog-store.js'
import { createBlogPostUsecase } from '../create/usecase.js'

// ✅ CORRECT - Package imports for external dependencies
import { BlogPost, BlogPostId } from '@t6c/blog-domain'
import { Effect as E, Schema as S } from 'effect'

// ❌ WRONG - Never use src/ aliases
import { BlogStore } from 'src/stores/blog/blog-store.js'

2. Store Layer (Data Access)

Service Class Structure

export class BlogStore extends E.Service<BlogStore>()('BlogStore', {
  dependencies: [DynamoDBService, ConfigService],
  effect: E.gen(function* () {
    const dynamodb = yield* DynamoDBService
    const config = yield* ConfigService
    
    return {
      create: (blogPost: BlogPost) => E.gen(function* () {
        // Implementation
      }),
      getById: (id: BlogPostId) => E.gen(function* () {
        // Implementation  
      }),
    }
  }),
}) {}

Store Responsibilities

  • ✅ Data persistence and retrieval only
  • ✅ Schema encoding/decoding
  • ✅ External service integration (DynamoDB, Algolia, S3)
  • ✅ Return raw data without business logic processing
  • ❌ No pagination calculations or business logic

3. Usecase Layer (Business Logic)

Usecase Structure with Observability

/**
 * Creates a new blog post with default values
 * @param input - Blog post creation input
 * @returns Created blog post with generated ID and timestamps
 */
export const createBlogPostUsecase = (input: CreateBlogPostInput) =>
  E.gen(function* () {
    // Start logging - concise format
    yield* E.logInfo('createBlogPostUsecase started', JSON.stringify(input))
    
    const blogStore = yield* BlogStore
    
    // Annotate key data points for tracing
    const blogPostData = BlogPost.make({
      id: BlogPostId.make(randomUUID()),
      ...input,
      // ... other fields
    })
    yield* E.annotateCurrentSpan('blogPostData', JSON.stringify(blogPostData))
    
    const createdBlogPost = yield* blogStore.create(blogPostData)
    yield* E.annotateCurrentSpan('createdBlogPost', JSON.stringify(createdBlogPost))
    
    // Completion logging - concise format
    yield* E.logInfo('createBlogPostUsecase completed successfully', JSON.stringify(createdBlogPost))
    
    return createdBlogPost
  }).pipe(
    E.tapError((error) =>
      E.logError('createBlogPostUsecase failed', JSON.stringify({ error, input }))
    ),
    E.withSpan('createBlogPostUsecase', { attributes: { input } })
  )

Read the full file on GitHub · 700 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 700 lines · 22 tokens per session scan A dd05693eb980

Subscribe to this mod's changes

effect-service-architecture is a cursor rule published in the GitHub repository CharLEE-X/effect-cursor-rules (6 stars, last pushed 1y ago), licensed MIT. It adds 22 tokens to every session and 5,173 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.