This skill enforces consistent patterns for Effect-TS codebases, optimizing for type safety, testability, and maintainability. It is tailored for developers using Effect-TS and React.
$ npx skills add https://github.com/makisuo/skills --skill effect-best-practicesThis skill enforces opinionated, consistent patterns for Effect-TS codebases, helping developers write type-safe, testable, and maintainable code. It provides guidance on Effect.Service definitions, Schema.TaggedError error handling, Layer composition, and effect-atom React components. The skill integrates with the Effect Language Server, which catches 30+ Effect-specific issues at edit-time that TypeScript alone cannot detect, including floating Effects, missing requirements, and incorrect yield patterns. Developers using Effect-TS benefit from automated diagnostics, quick info on Effect type parameters, and refactoring tools that convert async code to Effect.gen and auto-compose Layers.
Install the Effect Language Server for diagnostics and tool support.
Enforce business logic patterns in Effect-TS services
Facilitate React state management with Effect Atom patterns
Enhance type safety and error handling in Effect-TS codebases
$ npx skills add https://github.com/makisuo/skills --skill effect-best-practicesgit clone https://github.com/makisuo/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Provide Effect-TS best practices for [COMPANY]'s [INDUSTRY] codebase. Focus on [SPECIFIC_AREA: e.g., error handling, layer composition, React integration]. Include code examples in TypeScript using Effect-TS patterns. Suggest tools or libraries that can enforce these practices automatically.
# Effect-TS Best Practices for Acme Corp's FinTech Dashboard
## 1. Layer Composition
Always structure your application into clear layers to enforce separation of concerns. Here's a recommended structure for a FinTech dashboard:
```typescript
// Layers: Domain -> Service -> Presentation
// Domain layer (pure business logic)
export const Account = S.Struct({
id: S.String,
balance: S.Number,
owner: S.String
});
// Service layer (effectful operations)
export const AccountService = {
getBalance: (accountId: string) => Effect.gen(function* () {
const account = yield* getAccountFromDB(accountId);
return account.balance;
}),
transfer: (fromId: string, toId: string, amount: number) => Effect.gen(function* () {
yield* validateTransfer(fromId, toId, amount);
yield* deductBalance(fromId, amount);
yield* addBalance(toId, amount);
})
};
// Presentation layer (React components)
export const AccountBalance = ({ accountId }: { accountId: string }) => {
const balance = useEffect(AccountService.getBalance(accountId));
return <div>Balance: ${balance}</div>;
};
```
## 2. Error Handling
Use Effect's typed errors to make error handling explicit:
```typescript
type AccountError =
| { _tag: 'NotFound'; message: string }
| { _tag: 'InsufficientFunds'; balance: number; required: number }
| { _tag: 'NetworkError'; error: unknown };
const getAccountFromDB = (id: string): Effect.Effect<Account, AccountError, never> =>
Effect.tryPromise({
try: () => db.getAccount(id),
catch: (e) => ({ _tag: 'NetworkError', error: e } as const)
}).pipe(
Effect.filterOrFail(
(acc) => acc !== null,
() => ({ _tag: 'NotFound', message: `Account ${id} not found` } as const)
)
);
```
## 3. Testing
Use `@effect/test` for testing Effect-TS code:
```typescript
describe('AccountService', () => {
it('should transfer funds between accounts', async () => {
const program = AccountService.transfer('acc1', 'acc2', 100);
const result = await Effect.runPromise(program);
expect(result).toEqual({ _tag: 'Success' });
});
it('should fail on insufficient funds', async () => {
const program = AccountService.transfer('acc1', 'acc2', 1000000);
await expect(Effect.runPromise(program)).rejects.toMatchObject({
_tag: 'InsufficientFunds'
});
});
});
```
## 4. Tooling
- **ESLint**: Use `@effect/eslint-plugin` for Effect-TS specific linting rules
- **Prettier**: Configure with Effect-TS plugin for consistent formatting
- **CI Checks**: Add a step to validate layer imports don't cross boundaries
## 5. React Integration
Use `@effect/react` for React integration:
```typescript
import { useEffect } from '@effect/react/Effect';
const Dashboard = () => {
const { data: accounts, error } = useEffect(AccountService.getAllAccounts);
if (error) return <ErrorDisplay error={error} />;
return <AccountsList accounts={accounts} />;
};
```
**Key Takeaways:**
- Always separate concerns into Domain/Service/Presentation layers
- Use Effect's error types to make error handling explicit
- Test Effect-TS code using the test library
- Enforce patterns with tooling in your CI/CD pipelineTake a free 3-minute scan and get personalized AI skill recommendations.
Take free scan