effect-patterns-platform
Effect-TS patterns for Platform. Use when working with platform in Effect-TS applications.
Install
mkdir -p .claude/skills/effect-patterns-platform && curl -L -o skill.zip "https://mcp.directory/api/skills/download/7772" && unzip -o skill.zip -d .claude/skills/effect-patterns-platform && rm skill.zipInstalls to .claude/skills/effect-patterns-platform
About this skill
Effect-TS Patterns: Platform
This skill provides 6 curated Effect-TS patterns for platform. Use this skill when working on tasks related to:
- platform
- Best practices in Effect-TS applications
- Real-world patterns and solutions
🟢 Beginner Patterns
Platform Pattern 4: Interactive Terminal I/O
Rule: Use Terminal for user input/output in CLI applications, providing proper buffering and cross-platform character encoding.
Good Example:
This example demonstrates building an interactive CLI application.
import { Terminal, Effect } from "@effect/platform";
interface UserInput {
readonly name: string;
readonly email: string;
readonly age: number;
}
const program = Effect.gen(function* () {
console.log(`\n[INTERACTIVE CLI] User Information Form\n`);
// Example 1: Simple prompts
yield* Terminal.writeLine(`=== User Setup ===`);
yield* Terminal.writeLine(``);
yield* Terminal.write(`What is your name? `);
const name = yield* Terminal.readLine();
yield* Terminal.write(`What is your email? `);
const email = yield* Terminal.readLine();
yield* Terminal.write(`What is your age? `);
const ageStr = yield* Terminal.readLine();
const age = parseInt(ageStr);
// Example 2: Display collected information
yield* Terminal.writeLine(``);
yield* Terminal.writeLine(`=== Summary ===`);
yield* Terminal.writeLine(`Name: ${name}`);
yield* Terminal.writeLine(`Email: ${email}`);
yield* Terminal.writeLine(`Age: ${age}`);
// Example 3: Confirmation
yield* Terminal.writeLine(``);
yield* Terminal.write(`Confirm information? (yes/no) `);
const confirm = yield* Terminal.readLine();
if (confirm.toLowerCase() === "yes") {
yield* Terminal.writeLine(`✓ Information saved`);
} else {
yield* Terminal.writeLine(`✗ Cancelled`);
}
});
Effect.runPromise(program);
Rationale:
Terminal operations:
- readLine: Read single line of user input
- readPassword: Read input without echoing (passwords)
- writeLine: Write line with newline
- write: Write without newline
- clearScreen: Clear terminal
Pattern: Terminal.readLine().pipe(...)
Direct stdin/stdout causes issues:
- No buffering: Interleaved output in concurrent context
- Encoding issues: Special characters corrupted
- Password echo: Security vulnerability
- No type safety: String manipulation error-prone
Terminal enables:
- Buffered I/O: Safe concurrent output
- Encoding handling: UTF-8 and special chars
- Password input: No echo mode
- Structured interaction: Prompts and validation
Real-world example: CLI setup wizard
- Direct: console.log mixed with readline, no error handling
- With Terminal: Structured input, validation, formatted output
Platform Pattern 2: Filesystem Operations
Rule: Use FileSystem module for safe, resource-managed file operations with proper error handling and cleanup.
Good Example:
This example demonstrates reading, writing, and manipulating files.
import { FileSystem, Effect, Stream } from "@effect/platform";
import * as fs from "fs/promises";
const program = Effect.gen(function* () {
console.log(`\n[FILESYSTEM] Demonstrating file operations\n`);
// Example 1: Write a file
console.log(`[1] Writing file:\n`);
const content = `Hello, Effect-TS!\nThis is a test file.\nCreated at ${new Date().toISOString()}`;
yield* FileSystem.writeFileUtf8("test.txt", content);
yield* Effect.log(`✓ File written: test.txt`);
// Example 2: Read the file
console.log(`\n[2] Reading file:\n`);
const readContent = yield* FileSystem.readFileUtf8("test.txt");
console.log(readContent);
// Example 3: Get file stats
console.log(`\n[3] File stats:\n`);
const stats = yield* FileSystem.stat("test.txt").pipe(
Effect.flatMap((stat) =>
Effect.succeed({
size: stat.size,
isFile: stat.isFile(),
modified: stat.mtimeMs,
})
)
);
console.log(` Size: ${stats.size} bytes`);
console.log(` Is file: ${stats.isFile}`);
console.log(` Modified: ${new Date(stats.modified).toISOString()}`);
// Example 4: Create directory and write multiple files
console.log(`\n[4] Creating directory and files:\n`);
yield* FileSystem.mkdir("test-dir");
yield* Effect.all(
Array.from({ length: 3 }, (_, i) =>
FileSystem.writeFileUtf8(
`test-dir/file-${i + 1}.txt`,
`Content of file ${i + 1}`
)
)
);
yield* Effect.log(`✓ Created directory with 3 files`);
// Example 5: List directory contents
console.log(`\n[5] Listing directory:\n`);
const entries = yield* FileSystem.readDirectory("test-dir");
entries.forEach((entry) => {
console.log(` - ${entry}`);
});
// Example 6: Append to file
console.log(`\n[6] Appending to file:\n`);
const appendContent = `\nAppended line at ${new Date().toISOString()}`;
yield* FileSystem.appendFileUtf8("test.txt", appendContent);
const finalContent = yield* FileSystem.readFileUtf8("test.txt");
console.log(`File now has ${finalContent.split("\n").length} lines`);
// Example 7: Clean up
console.log(`\n[7] Cleaning up:\n`);
yield* Effect.all(
Array.from({ length: 3 }, (_, i) =>
FileSystem.remove(`test-dir/file-${i + 1}.txt`)
)
);
yield* FileSystem.remove("test-dir");
yield* FileSystem.remove("test.txt");
yield* Effect.log(`✓ Cleanup complete`);
});
Effect.runPromise(program);
Rationale:
FileSystem operations:
- read: Read file as string
- readDirectory: List files in directory
- write: Write string to file
- remove: Delete file or directory
- stat: Get file metadata
Pattern: FileSystem.read(path).pipe(...)
Direct file operations without FileSystem create issues:
- Resource leaks: Files not closed on errors
- No error context: Missing file names in errors
- Blocking: No async/await integration
- Cross-platform: Path handling differences
FileSystem enables:
- Resource safety: Automatic cleanup
- Error context: Full error messages
- Async integration: Effect-native
- Cross-platform: Handles path separators
Real-world example: Process log files
- Direct: Open file, read, close, handle exceptions manually
- With FileSystem:
FileSystem.read(path).pipe(...)
🟡 Intermediate Patterns
Platform Pattern 3: Persistent Key-Value Storage
Rule: Use KeyValueStore for simple persistent storage of key-value pairs, enabling lightweight caching and session management.
Good Example:
This example demonstrates storing and retrieving persistent data.
import { KeyValueStore, Effect } from "@effect/platform";
interface UserSession {
readonly userId: string;
readonly token: string;
readonly expiresAt: number;
}
const program = Effect.gen(function* () {
console.log(`\n[KEYVALUESTORE] Persistent storage example\n`);
const store = yield* KeyValueStore.KeyValueStore;
// Example 1: Store session data
console.log(`[1] Storing session:\n`);
const session: UserSession = {
userId: "user-123",
token: "token-abc-def",
expiresAt: Date.now() + 3600000, // 1 hour
};
yield* store.set("session:user-123", JSON.stringify(session));
yield* Effect.log(`✓ Session stored`);
// Example 2: Retrieve stored data
console.log(`\n[2] Retrieving session:\n`);
const stored = yield* store.get("session:user-123");
if (stored._tag === "Some") {
const retrievedSession = JSON.parse(stored.value) as UserSession;
console.log(` User ID: ${retrievedSession.userId}`);
console.log(` Token: ${retrievedSession.token}`);
console.log(
` Expires: ${new Date(retrievedSession.expiresAt).toISOString()}`
);
}
// Example 3: Check if key exists
console.log(`\n[3] Checking keys:\n`);
const hasSession = yield* store.has("session:user-123");
const hasOther = yield* store.has("session:user-999");
console.log(` Has session:user-123: ${hasSession}`);
console.log(` Has session:user-999: ${hasOther}`);
// Example 4: Store multiple cache entries
console.log(`\n[4] Caching API responses:\n`);
const apiResponses = [
{ endpoint: "/api/users", data: [{ id: 1, name: "Alice" }] },
{ endpoint: "/api/posts", data: [{ id: 1, title: "First Post" }] },
{ endpoint: "/api/comments", data: [] },
];
yield* Effect.all(
apiResponses.map((item) =>
store.set(
`cache:${item.endpoint}`,
JSON.stringify(item.data)
)
)
);
yield* Effect.log(`✓ Cached ${apiResponses.length} endpoints`);
// Example 5: Retrieve cache with expiration
console.log(`\n[5] Checking cached data:\n`);
for (const item of apiResponses) {
const cached = yield* store.get(`cache:${item.endpoint}`);
if (cached._tag === "Some") {
const data = JSON.parse(cached.value);
console.log(
` ${item.endpoint}: ${Array.isArray(data) ? data.length : 1} items`
);
}
}
// Example 6: Remove specific entry
console.log(`\n[6] Removing entry:\n`);
yield* store.remove("cache:/api/comments");
const removed = yield* store.has("cache:/api/comments");
console.log(` Exists after removal: ${removed}`);
// Example 7: Iterate and count entries
console.log(`\n[7] Counting entries:\n`);
const allKeys = yield* store.entries.pipe(
Effect.map((entries) => entries.length)
);
console.log(` Total entries: ${allKeys}`);
});
Effect.runPromise(program);
Rationale:
KeyValueStore operations:
- set: Store key-value pair
- get: Retrieve value by key
- remove: Delete key
- has: Check if key exists
- clear: Remove all entries
Pattern: KeyValueStore.set(key, value).pipe(...)
Without persistent storage, transient data is lost:
- Session data: Lost on restart
- Caches: Rebuilt from scratch
- Configuration: Hardcoded or file-based
- State: Scat
Content truncated.
More by PaulJPhilp
View all skills by PaulJPhilp →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversEffortlessly manage Google Cloud with this user-friendly multi cloud management platform—simplify operations, automate t
RSS Feed Parser is a powerful rss feed generator and rss link generator with RSSHub integration, perfect for creating cu
Manage Google Cloud Platform resources via natural language — compute, storage, networking, databases — with automated O
Enhance your workflow with platform-specific notification sounds on Android. Get alert sounds & custom tones, including
Prisma Postgres offers local and remote MCP servers to simplify database workflows for developers and AI platforms.
MCP server connects Claude and AI coding tools to shadcn/ui components. Accurate TypeScript props and React component da
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.