Command Palette

Search for a command to run...

Назад к скиллам
скилл № 05954

elysia-architecture

Use when the user asks about an Elysia API on Bun with typed routes, Elysia project structure, plugin/module layout, lifecycle hook order, TypeBox schemas or…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить elysia-architecture в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Elysia Architecture

Purpose

Structure Elysia.js applications with plugin-based architecture — lifecycle hooks, type-safe schema, Eden Treaty client generation, and production middleware configuration.

Agent Protocol

Trigger

User request includes: elysia app structure, elysia project layout, elysia plugin, elysia lifecycle, elysia architecture, elysia folder structure, elysia config.

Input Context

  • Bun version (1.0+)
  • Elysia version (1.x)
  • Plugins used (cors, swagger, websocket, auth)
  • Database (Bun SQLite, Drizzle, Prisma)

Output Artifact

Project structure, plugin layout, lifecycle hook order, configuration, Eden Treaty client setup.

Response Format

Produce artifact directly. No preamble, no postamble, no explanations. No filler, no hedging.

Completion Criteria

  • Plugin-based architecture with clear separation
  • Lifecycle hooks in correct order
  • Type-safe schemas with Elysia t (TypeBox) for body, query, params and response
  • Eden Treaty client typed from the exported App type
  • Environment validated at startup

Max Response Length

4096 tokens

Architecture Decision Trees

Plugin Architecture vs Monolithic

Criterion Plugin Architecture Monolithic
Feature count 5+ features 1-3 features
Team size 2+ developers Solo
Reuse Multiple apps share plugins Single app
Testing Isolated per plugin End-to-end
Bundle size Lazy-loaded plugins Single bundle

Decision: Multi-feature app or shared modules → Plugin Architecture. Simple CRUD → Monolithic.

Lifecycle Hook Strategy

Hook / API Runs Use Case
state / decorate Once at setup (not per request) DB clients, config, singletons
onRequest First, before routing Request ID, rate limiting, CORS preflight
onParse Body parsing Custom content types
onTransform / derive Before validation Add context values from headers (derive runs in the transform phase)
(validation) Schema check of body/query/params/headers TypeBox schemas
resolve After validation, before beforeHandle Values that need validated input, e.g. load user from verified token
beforeHandle Before handler; returning a value short-circuits Auth guards, permission checks
afterHandle / mapResponse After handler Transform or wrap response
onError On any thrown error Global error mapping
onAfterResponse After response is sent (named onResponse before 1.1) Metrics, logging

Order: onRequest → onParse → onTransform/derive → validation → resolve → beforeHandle → handler → afterHandle → mapResponse → onAfterResponse (onError whenever something throws). Hooks apply only to routes registered after them.

Workflow

Step 1: Project Structure

src/
  index.ts                    # Entry point — create app, register plugins
  app.ts                      # Elysia app factory
  config/
    env.ts                    # Environment config
    database.ts               # DB connection
  plugins/
    auth.ts                   # Auth plugin (resolve user, guard)
    cors.ts                   # CORS config plugin
    swagger.ts                # Swagger/OpenAPI plugin
    error-handler.ts          # Global error handler
  modules/
    users/
      index.ts                # User module plugin
      routes.ts               # User routes
      schema.ts               # Validation schemas
      service.ts              # Business logic
      repository.ts           # Data access
    orders/
      index.ts
      routes.ts
      schema.ts
      service.ts
  shared/
    response.ts               # Response helpers
    logger.ts                 # Logger setup
    pagination.ts             # Pagination types

Step 2: App Factory

// src/app.ts
import { Elysia } from 'elysia'
import { cors } from '@elysiajs/cors'
import { swagger } from '@elysiajs/swagger' // newer projects: @elysiajs/openapi
import { authPlugin } from './plugins/auth'
import { errorHandlerPlugin } from './plugins/error-handler'
import { userModule } from './modules/users'
import { orderModule } from './modules/orders'

export const createApp = () => new Elysia()
  .use(cors({ origin: Bun.env.CORS_ORIGIN }))
  .use(swagger({ path: '/docs' }))
  .use(errorHandlerPlugin)
  .use(authPlugin)
  .use(userModule)
  .use(orderModule)
  .get('/health', () => ({ status: 'ok', uptime: process.uptime() }))

export type App = ReturnType<typeof createApp> // consumed by Eden Treaty

// src/index.ts
import { createApp } from './app'

const app = createApp()
const port = parseInt(Bun.env.PORT || '3000')
app.listen(port, () => console.log(`Server running on port ${port}`))

Step 3: Auth Plugin (Resolver Pattern)

// src/plugins/auth.ts
import { Elysia, t } from 'elysia'
import { jwt } from '@elysiajs/jwt'

export const authPlugin = new Elys
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/elysia-custom-plugins.md
  • references/elysia-deployment.md
  • references/elysia-lifecycle.md
  • references/elysia-plugins-ecosystem.md
  • references/elysia-plugins.md
  • references/elysia-routing-validation.md
  • references/elysia-testing.md
  • references/elysia-type-safety-patterns.md

FAQ

Что делает скилл elysia-architecture?

Use when the user asks about an Elysia API on Bun with typed routes, Elysia project structure, plugin/module layout, lifecycle hook order, TypeBox schemas or auth macros. Produces an Elysia app structure with fail-fast config. Not for Eden Treaty, WebSocket or macro recipes (use elysia-patterns).

Как установить скилл elysia-architecture?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл elysia-architecture запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить elysia-architecture с