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
Guides a founder through the full Y Combinator batch application end-to-end. A 10-phase workflow that captures the live YC form, profiles the founders, stress-tests the idea via an embedded grill loop, runs a mandatory 5-agent parallel external research pass on the startup, drafts every form field with anti-pattern and accepted-example checks, produces founder-video bullet notes (no script), runs a final adversarial gate, generates paste-ready submission answers, unlocks an interview-prep simulator after invite, and supports reapplicant delta tracking and post-decision post-mortems. Writes a documented markdown trail under a user-chosen workspace. Use when a founder wants to prepare a YC batch application, build their founder video, drill mock YC interview questions, or reapply with delta evidence. Don't use for pitch-deck design unrelated to YC, generic startup advice without applying, or post-funding work.
development
Authors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
tools
Provides guardrails for user-facing UI work: usability heuristics, accessibility floors, design-system discipline, component states, microcopy, motion, dark mode, responsive behavior, and human-AI UX. Use when designing, generating, reviewing, or refactoring visible product surfaces such as components, pages, dashboards, forms, dialogs, loading/empty/error states, or AI interfaces. Do not use for backend-only work, infrastructure, CLI/TUI design, or pure documentation editing.
tools
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects. Don't use for plain JavaScript, runtime validation libraries (Zod, Yup), or basic TypeScript syntax questions.