Token导航 LogoToken导航TokenDH.com
开发敏感数据github未标认证来源可访问许可证需确认审计通过

elysiaelysia 命令行

Agent Skill

elysia 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,248

周安装

50

GitHub Stars

4,474

下载量

404
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:elysia(elysia 命令行)
来源仓库:https://github.com/epicenterhq/epicenter
仓库路径:skills/elysia
安装命令:
npx skills add https://github.com/epicenterhq/epicenter --skill elysia
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/epicenterhq/epicenter --skill elysia

简介

Elysia.js 模式提供 status() 响应助手和 Eden Treaty 类型安全方案,统一错误码返回格式。

  • 适合需要将旧式 set.status + error-object 迁移到新风格 handler 的项目重构任务。
  • 每个 handler 应明确定义各状态码的响应 Schema,提升接口契约的可读性和可靠性。
  • 安装命令为 npx skills add https://github.com/epicenterhq/epicenter --skill elysia。
  • 插件化认证中间件应集中管理,避免在每个路由重复编写身份校验逻辑。

SKILL.md

Elysia.js Patterns (v1.2+)

Reference Repositories

  • Hono — Ultrafast web framework for Cloudflare Workers
  • Cloudflare Docs — Cloudflare Workers, Durable Objects, KV documentation

When to Apply This Skill

Use this pattern when you need to:

  • Write or refactor Elysia handlers to use status() responses.
  • Define per-status response schemas for Eden Treaty type safety.
  • Migrate handlers away from set.status plus error-object returns.
  • Compose Elysia plugins/guards for shared auth and route behavior.
  • Choose between return status(...) and throw status(...) by control-flow context.

The status() Helper (ALWAYS use this)

Never use set.status + return object. Always destructure status from the handler context and use it for all non-200 responses. This gives you:

  • Typesafe string literals with full IntelliSense (e.g. "Bad Request" instead of 400)
  • Automatic response type inference per status code
  • Eden Treaty end-to-end type safety on error responses

Basic Usage

import { Elysia, t } from 'elysia';

new Elysia().post(
	'/chat',
	async ({ body, headers, status }) => {
		//                       ^^^^^^ destructure status from context

		if (!isValid(body.provider)) {
			// Use string literal for self-documenting, typesafe status codes
			return status('Bad Request', 'Unsupported provider');
		}

		if (!apiKey) {
			return status('Unauthorized', 'Missing API key');
		}

		return doWork(body);
	},
	{
		// Define response schemas per status code for full type safety
		response: {
			200: t.Any(),
			400: t.String(),
			401: t.String(),
		},
	},
);

return status() vs throw status()

Both work. The framework handles either. The difference is purely control flow:

PatternBehaviorUse when
return status(...)Normal return, continues to response pipelineYou're at a natural return point (validation guards, end of handler)
throw status(...)Short-circuits execution immediatelyYou're deep in nested logic or inside a try/catch and want to bail out

This codebase convention: prefer return status(...). It matches the existing early-return-on-error pattern used everywhere else (see error-handling skill). Reserve throw status(...) for catch blocks or deeply nested code where return would be awkward.

// GOOD: return for validation guards (matches codebase style)
async ({ body, status }) => {
	if (!isValid(body.provider)) {
		return status('Bad Request', `Unsupported provider: ${body.provider}`);
	}

	const apiKey = resolveApiKey(body.provider, headerApiKey);
	if (!apiKey) {
		return status('Unauthorized', 'Missing API key');
	}

	// happy path
	return doWork(body);
};

// GOOD: throw inside catch blocks
async ({ body, status }) => {
	try {
		return await streamResponse(body);
	} catch (error) {
		if (isAbortError(error)) {
			throw status(499, 'Client closed request');
		}
		throw status('Bad Gateway', `Provider error: ${error.message}`);
	}
};

Type inference is identical for both

Both return status(...) and throw status(...) produce the same ElysiaCustomStatusResponse object. Elysia's type system infers response types from the response schema in route options, not from how you invoke status(). Eden Treaty type safety works equally with either approach.

Available String Status Codes (StatusMap)

Use these string literals instead of numeric codes for better readability:

String LiteralCodeCommon Use
'Bad Request'400Validation failures, malformed input
'Unauthorized'401Missing/invalid auth credentials
'Forbidden'403Valid auth but insufficient permissions
'Not Found'404Resource doesn't exist
'Conflict'409State conflict (duplicate, already exists)
'Unprocessable Content'422Semantically invalid input
'Too Many Requests'429Rate limiting
'Internal Server Error'500Unexpected server failure
'Bad Gateway'502Upstream provider error
'Service Unavailable'503Temporary overload/maintenance

For non-standard codes (e.g. nginx's 499), use the numeric literal directly: status(499, 'Client closed request').

Response Schemas for Eden Treaty Type Safety

Define response schemas per status code in route options. This is what makes Eden Treaty infer error types on the client:

new Elysia().post(
	'/chat',
	async ({ body, status }) => {
		if (!isValid(body.provider)) {
			return status('Bad Request', `Unsupported provider: ${body.provider}`);
		}
		return streamResult;
	},
	{
		body: t.Object({
			provider: t.String(),
			model: t.String(),
		}),
		response: {
			200: t.Any(), // Success type
			400: t.String(), // Bad Request body type
			401: t.String(), // Unauthorized body type
			502: t.String(), // Bad Gateway body type
		},
	},
);

Eden Treaty then infers:

const { data, error } = await api.chat.post({
	provider: 'openai',
	model: 'gpt-4',
});

if (error) {
	// error.status is typed as 400 | 401 | 502
	// error.value is typed per status code (string in this case)
	switch (error.status) {
		case 400: // error.value: string
		case 401: // error.value: string
		case 502: // error.value: string
	}
}

Error Response Body: Strings vs Objects

Prefer plain strings as error bodies. The status code already communicates the error class. A descriptive string message is sufficient and keeps the API simple.

// GOOD: Plain string - status code provides the category
return status('Bad Request', `Unsupported provider: ${provider}`);
return status('Unauthorized', 'Missing API key: set x-provider-api-key header');

// AVOID: Wrapping in { error: "..." } object - redundant with status code
set.status = 400;
return { error: `Unsupported provider: ${provider}` };

If you need structured error bodies (multiple fields, error codes, validation details), define a TypeBox schema:

const ErrorBody = t.Object({
  message: t.String(),
  code: t.Optional(t.String()),
});

// In route options:
response: {
  400: ErrorBody,
  401: ErrorBody,
}

Plugin Composition

Elysia plugins are just functions that return Elysia instances. Use new Elysia() inside the plugin, not new Elysia({prefix}) — let the consumer control mounting:

// GOOD: Plugin is prefix-agnostic
export function createMyPlugin() {
	return new Elysia().post('/endpoint', async ({ body, status }) => {
		// ...
	});
}

// Consumer controls the prefix
app.use(new Elysia({ prefix: '/api' }).use(createMyPlugin()));

Guards for Shared Auth

Use .guard() with beforeHandle for auth that applies to multiple routes:

const authed = new Elysia().guard({
	async beforeHandle({ headers, status }) {
		const token = extractBearerToken(headers.authorization);
		if (!isValid(token)) {
			return status('Unauthorized', 'Invalid or missing token');
		}
	},
});

// All routes under this guard require auth
return authed
	.get('/protected', () => 'secret')
	.post('/admin', () => 'admin stuff');

Migration Checklist: set.status to status()

When updating existing handlers:

  1. Replace set with status in the handler destructuring
  2. Replace set.status = N; return {error: msg}; with return status('String Literal', msg);
  3. In catch blocks, use throw status(...) instead of set.status = N; return {error: msg};
  4. Add response schemas to route options for Eden Treaty type inference
  5. Keep set in the destructuring ONLY if you still need set.headers for things like content-type
// BEFORE
async ({ body, headers, set }) => {
	if (!valid) {
		set.status = 400;
		return { error: 'Bad input' };
	}
};

// AFTER
async ({ body, headers, status }) => {
	if (!valid) {
		return status('Bad Request', 'Bad input');
	}
};

// AFTER (when you also need set.headers)
async ({ body, headers, set, status }) => {
	if (!valid) {
		return status('Bad Request', 'Bad input');
	}
	set.headers['content-type'] = 'application/octet-stream';
	return binaryData;
};

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.23%
按下载量换算150

Claude

28.86%
按下载量换算117

Cursor

19.37%
按下载量换算78

Gemini CLI

9.4%
按下载量换算38

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills