skills/community/elysia/SKILL.md
Expert guide for building APIs with the Elysia framework, including routing, validation, plugins, error handling, and type-safe handlers. Use when building APIs with Elysia framework, defining routes, plugins, or type-safe handlers.
npx skillsauth add pedronauck/skills elysiaInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides guidelines, patterns, and best practices for working with the Elysia framework in this project.
For detailed development guidelines, imports, and patterns, please refer to references/patterns.md in this skill directory.
new Elysia({ prefix }) instance as the controller for that feature. Do not pass entire class methods directly as handlers. Instead, inline a small handler that calls service functions.src/modules/<feature>/index.ts - Elysia controller (routes, guards, cookies)src/modules/<feature>/service.ts - business logic (no HTTP context)src/modules/<feature>/model.ts - schemas & types via t (TypeBox)src/utils/*..use() (e.g., OpenAPI, JWT, CORS).When scaffolding a feature, generate:
model.ts with t.Object(...) schemas and exported type aliases via typeof schema.static.service.ts with pure functions (or an abstract class of statics when no instance state is needed).index.ts that mounts the Elysia routes, applies guard() with shared validation, and returns typed responses.import { t } from 'elysia' to define Body, Query, Params, Headers, Cookie, and Response schemas.typeof schema.static and export them (e.g., export type SignInBody = typeof signInBody.static)..guard({ ... }). If combining guards, consider schema: 'standalone' to keep them independent.fileType (magic number) when using standard schema systems.When generating handlers:
body/query/params/headers/cookie/response.t.Object, t.Array, t.Union, t.Literal, file schemas, and show guard() for shared query/headers..onError(({ code, error, path, request }) => { ... }) on the app to map framework and custom errors to a uniform JSON shape (e.g., { ok: false, error: { code, message, details } }).throw status(code, messageOrPayload) for error control flow that onError can catch. Note: return status(...) won't be caught by onError.x-request-id) and log within onError. Avoid leaking stack traces in production.{ ok: true, data } for uniformity.When generating code, create:
src/plugins/error.ts that installs .onError(...).src/plugins/logging.ts to log in onResponse & onError.@elysiajs/openapi plugin and expose docs route (Scalar UI).@elysiajs/jwt for JWT signing/verification, or integrate with your auth of choice.user after verification..guard({ headers: t.Object({ authorization: t.String() }) }) and verify bearer tokens before handlers.@elysiajs/cors where needed.@elysiajs/server-timing and @elysiajs/opentelemetry for observability.When scaffolding, generate src/plugins/openapi.ts, src/plugins/auth.ts, and wire them in src/app.ts.
index.ts) that forks workers and imports server.ts per worker.--minify or mark instrumented modules as --external.process.env.PORT (with fallback) and bind 0.0.0.0 for PaaS.CMD ["./server"].When generating a deploy scaffold, include:
src/index.ts (cluster launcher), src/server.ts (app), Dockerfile (multi-stage), and build scripts.vitest.app.handle(new Request(url, options)) to assert status/body/headers.body validation (both valid and invalid paths).Authorization header..state() and .decorate() to add version info, helpers, etc., then read from { store, getDate }..ws() for simple real-time APIs..onParse() for special content types.Before finishing a task involving Elysia:
model.ts, service.ts, index.ts pattern..onError() plugin.app.handle(new Request(...)) pattern.pnpm run typecheck) and tests (pnpm run test).For detailed patterns and code examples, see references/patterns.md.
testing
Assess DDD fit; discover domains with EventStorming, define language and bounded contexts, and design aggregates, value objects, events, and repositories. Excludes architecture-only audits, product specs, and CQRS/Event Sourcing catalogs.
development
Build terminal UIs with ratatui following 2026 Rust best practices. Use when: (1) Creating new TUI apps, (2) Adding widgets/layouts, (3) Keyboard navigation/state management, (4) Image integration via ratatui-image, (5) Async event handling, (6) Release optimization. Covers v0.30.0+ API, Elm Architecture, StatefulWidget, color-eyre.
development
Find 10x product opportunities and high-leverage improvements. Use when user wants strategic product thinking, mentions '10x', wants to find high-impact features, or says 'what would make this 10x better', 'product strategy', or 'what should we build next'.
development
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.