一键导入
effect-path
Use effect Path for platform-abstract file path operations including joining, resolving, and URL conversion.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use effect Path for platform-abstract file path operations including joining, resolving, and URL conversion.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Define type-safe RPC contracts with effect/unstable/rpc — Rpc.make payload/success/error/defect schemas, RpcSchema.Stream streaming responses, RpcGroup composition (add/merge/omit/prefix/annotate), and RpcMiddleware.Service definitions shared by client and server. Use when declaring or evolving RPC procedures, building a shared contract package, adding streaming endpoints, or defining auth/observability middleware types.
Consume typed RPC services with Effect's RpcClient — protocol layers (HTTP, WebSocket, TCP, worker, in-memory), RpcSerialization codecs, per-call and ambient headers, streaming calls, interruption, reconnection, and RpcClientError handling. Use when calling an RpcGroup from a client, wiring a client transport + serialization stack, debugging RPC transport failures or reconnects, or testing RPC consumers with RpcTest.
Serve RpcGroup contracts with Effect's RpcServer — handler layers (RpcGroup.toLayer/toLayerHandler), protocol layers (HTTP, WebSocket, TCP, stdio, worker), RpcSerialization, server middleware, streaming results, interruption and shutdown semantics, RpcTest. Use when implementing the server side of an Effect RPC API, mounting RPC on an HttpRouter or existing HTTP app, choosing a wire format, implementing RpcMiddleware, handling client aborts, or testing RPC handlers.
Make outgoing HTTP requests with Effect's HttpClient — HttpClientRequest builders, schema-decoded HttpClientResponse bodies, the HttpClientError taxonomy, retryTransient/rate limiting/cookies/redirects, streaming uploads and downloads, and FetchHttpClient/NodeHttpClient transport layers. Use when calling external REST/JSON APIs, uploading or downloading files and streams, adding retries/auth/tracing to outbound HTTP, or mocking HTTP responses in tests.
Build HTTP servers with effect/unstable/http — HttpRouter routes and middleware, HttpServerRequest schema decoding, HttpServerResponse constructors, multipart uploads, websocket upgrades, static files, NodeHttpServer/BunHttpServer layers, and in-memory web handlers. Use when serving raw HTTP routes, reading request bodies/cookies/uploads, writing server middleware, streaming responses, or testing handlers without a real port.
Build bidirectional socket transports with effect/unstable/socket — the Socket run/writer surface, WebSocket-backed sockets, TCP/Unix-domain clients via NodeSocket, SocketServer accept loops, channel adapters, the SocketError taxonomy, and reconnect patterns. Use when connecting to or serving raw TCP, Unix-domain, or WebSocket endpoints, framing socket bytes with Stream/Channel (NDJSON), building reconnecting socket clients, or providing socket transports to RPC/devtools layers.
| name | effect-path |
| description | Use effect Path for platform-abstract file path operations including joining, resolving, and URL conversion. |
Use effect Path abstraction for platform-abstract file path operations. Apply this skill when working with file paths, joining segments, resolving absolute paths, or converting between file URLs and paths. Path.layer supplies POSIX semantics from effect; Node.js and Bun platform layers provide host-specific path semantics. @effect/platform-browser does not provide a BrowserPath layer in beta.74, so browser code should provide Path.layer or a custom layer explicitly.
import { Path } from 'effect';
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
});
import { Path } from 'effect';
import { Effect } from 'effect';
// Get platform-specific separator
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const separator = path.sep; // "/" on Unix, "\" on Windows
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const fullPath = path.join('src', 'components', 'Button.tsx');
// "src/components/Button.tsx" on Unix
// "src\components\Button.tsx" on Windows
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const absolutePath = path.resolve('src', 'index.ts');
// "/Users/username/project/src/index.ts" on Unix
// "C:\Users\username\project\src\index.ts" on Windows
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const clean = path.normalize('/foo/bar//baz/asdf/quux/..');
// "/foo/bar/baz/asdf"
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const dir = path.dirname('/foo/bar/baz.txt');
// "/foo/bar"
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const name = path.basename('/foo/bar/baz.txt');
// "baz.txt"
const nameWithoutExt = path.basename('/foo/bar/baz.txt', '.txt');
// "baz"
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const ext = path.extname('/foo/bar/baz.txt');
// ".txt"
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const parsed = path.parse('/home/user/dir/file.txt');
// {
// root: "/",
// dir: "/home/user/dir",
// base: "file.txt",
// ext: ".txt",
// name: "file"
// }
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const fullPath = path.format({
root: '/',
dir: '/home/user/dir',
base: 'file.txt'
});
// "/home/user/dir/file.txt"
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const isAbs = path.isAbsolute('/foo/bar');
// true on Unix
const isRel = path.isAbsolute('foo/bar');
// false
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const relPath = path.relative(
'/data/orandea/test/aaa',
'/data/orandea/impl/bbb'
);
// "../../impl/bbb"
});
Both operations can fail with BadArgument error.
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const filePath = yield* path.fromFileUrl(
new URL('file:///home/user/file.txt')
);
// "/home/user/file.txt" on Unix
// "C:\home\user\file.txt" on Windows
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
const fileUrl = yield* path.toFileUrl('/home/user/file.txt');
// URL object with href "file:///home/user/file.txt"
});
import { Path } from 'effect';
import { Effect } from 'effect';
const buildOutputPath = Effect.gen(function* () {
const path = yield* Path.Path;
// Join segments
const srcPath = path.join('src', 'index.ts');
// Resolve to absolute
const absoluteSrc = path.resolve(srcPath);
// Get directory and basename
const dir = path.dirname(absoluteSrc);
const base = path.basename(absoluteSrc, '.ts');
// Build output path
const outputPath = path.join(dir, '..', 'dist', `${base}.js`);
// Normalize
return path.normalize(outputPath);
});
import { Path } from 'effect';
import { Effect } from 'effect';
const program = Effect.gen(function* () {
const path = yield* Path.Path;
// On POSIX, returns the path unchanged.
// On Windows, converts to a \\?\-prefixed namespaced path
// that allows longer path lengths.
const namespaced = path.toNamespacedPath('/foo/bar/baz.txt');
});
path.sep for platform-specific separatorspath.join() to combine path segmentspath.resolve() to get absolute pathsfromFileUrl and toFileUrl with Effect error handlingURL object (not a string) to fromFileUrlnode:path directly (breaks portability)fromFileUrl — it requires a URL object