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.
development
Deep review of branch diffs, working trees, or GitHub PRs at any size. Use when the user asks for CodeRabbit-grade review, an incremental re-review after new pushes, publication of findings to a PR, a cross-LLM peer-review verdict round, or conformance review against spec artifacts. Don't use for applying fixes, reviewing specs or PRDs as documents, or quick single-file feedback.
tools
Orchestrate Claude and Codex worker TUIs from a controller agent through herdr panes and the herdr socket CLI. Use when delegating bounded tasks to herdr worker panes, running user-activated plan-first delegations (Claude Code plan mode, Codex Plan mode), waiting on native agent status (idle, working, blocked, done), or verifying worker reports. Workers launch as interactive TUIs via herdr agent start — never through headless runners (compozy exec, claude -p, codex exec). Not for cmux workspaces (see cmux-orchestration) and not for end-user herdr control.
tools
TanStack Query, Router, and Form patterns for React. Use when writing useQuery/queryOptions, mutations, caching, file-based routes, search params, loaders, or TanStack Form validation. Don't use for TanStack Start, TanStack DB/collections, Zustand client state, or non-TanStack routing.
development
Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.