oak-backend
Use when the user asks about Oak, jsr:@oak/oak, Deno Oak router, Oak middleware, ctx.state or Oak body parsing. Produces Oak apps with router modules, ordered…
от j4flmao★ 47 звёзд на GitHub
Установить oak-backend в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Oak Backend
Purpose
Define Oak backend application architecture: Deno-native HTTP server, middleware composition, router pattern, and context management with typed state, composable middleware pipeline, and type-safe routing.
Agent Protocol
Trigger
User request includes: oak, oak backend, deno oak, oak middleware, oak router, deno http, oak context, oak typescript.
Input Context
- Deno version (2.x assumed)
- Oak version (17.x on JSR:
jsr:@oak/oak; v13+ changed the body API) - Language (TypeScript)
- Database (Deno KV, PostgreSQL via
npm:pgorjsr:@db/postgres, MongoDB vianpm:mongodb) - Templating (eta, deno mustache)
- Deployment (Deno Deploy, self-hosted)
Output Artifact
A markdown document containing:
- Project structure
- Router setup (Router class)
- Middleware composition (use, compose)
- Context (c.state, c.cookies, c.send)
- Error handling middleware
- State management (context state)
- Environment configuration (Deno.env)
- Testing (Deno.test with
app.handle(), or superoak)
Response Format
Produce the artifact directly. No preamble, no postamble, no explanations. No filler, no hedging. Compress output.
Completion Criteria
- Router separates route definitions from app setup
- Middleware pipeline composed with app.use()
- Error middleware catches all exceptions
- State typed via OakMiddleware type parameter
- Tests call
app.handle(new Request(...))or use superoak - Lockfile generated and committed
Max Response Length
4096 tokens
Architecture Decision Trees
Oak vs Hono vs std/http
| Criterion | Oak | Hono | std/http |
|---|---|---|---|
| Middleware ecosystem | Rich (cors, auth, rate-limit, static) | Growing (cors, etag, jwt) | Manual |
| TypeScript context typing | Generic State param |
c.req.valid() |
Manual |
| Router pattern | Router({ prefix }) |
Chained .get().post() |
Switch/match |
| File upload | await ctx.request.body.formData() |
c.req.parseBody() |
req.formData() |
| WebSocket | ctx.upgrade() |
upgradeWebSocket from hono/deno |
Deno.upgradeWebSocket |
| Multi-runtime | Deno first (also Node/Bun) | Deno, Node, Bun, Workers | Deno only |
Decision: existing Koa-style middleware stack → Oak. Typed validation and multi-runtime portability → Hono. Tiny single-purpose service → Deno.serve.
Route Organization Strategy
| Scale | Pattern | Structure |
|---|---|---|
| Small (<10 routes) | Single router file | src/router.ts |
| Medium (10-50 routes) | Resource modules | src/routes/{resource}.ts |
| Large (50+ routes) | Versioned sub-routers | src/routes/v1/{resource}.ts |
| Micro (3-5 routes) | Inline in app.ts | app.use(router.routes()) |
Workflow
Step 1: Project Setup
# Create project directory
mkdir -p order-service/src
cd order-service
# Initialize
deno init
# Add oak (writes to deno.json imports)
deno add jsr:@oak/oak jsr:@std/assert npm:zod
Step 2: Project Structure
order-service/
├── src/
│ ├── main.ts
│ ├── app.ts
│ ├── router/
│ │ ├── index.ts
│ │ ├── orders.ts
│ │ └── health.ts
│ ├── middleware/
│ │ ├── error.ts
│ │ ├── logger.ts
│ │ └── auth.ts
│ ├── controllers/
│ │ └── order.controller.ts
│ ├── services/
│ │ └── order.service.ts
│ ├── models/
│ │ └── order.ts
│ └── types/
│ └── index.ts
├── tests/
│ ├── app_test.ts
│ └── orders_test.ts
├── deno.json
└── deno.lock
Step 3: App Initialization
// src/app.ts
import { Application } from '@oak/oak'
import { errorMiddleware } from './middleware/error.ts'
import { loggerMiddleware } from './middleware/logger.ts'
import { router } from './router/index.ts'
import type { AppState } from './types/index.ts'
export function createApp(): Application<AppState> {
// state: initial app-wide state; each request gets a copy in ctx.state
const app = new Application<AppState>({ state: {} as AppState })
// Middleware pipeline (order matters)
app.use(errorMiddleware)
app.use(loggerMiddleware)
app.use(router.routes())
app.use(router.allowedMethods())
return app
}
// src/main.ts
import { createApp } from './app.ts'
const app = createApp()
const port = parseInt(Deno.env.get('PORT') ?? '8080')
console.log(`Server running on port ${port}`)
await app.listen({ port })
Step 4: Router and Controller
// src/router/orders.ts
import { Router } from '@oak/oak'
import { OrderController } from '../controllers/order.controller.ts'
const router = new Router({ prefix: '/api/orders' })
const controller = new OrderController()
router.get('/', controller.list)
router.get('/:id', controller.getById)
router.post('/', controller.create)
router.put('/:id', controller.update)
router.delete('/:id', controller.deleteById)
export { router as orderRouter }
// src/controllers/order.controller.ts
import type { RouterContext } from '@oak/oak'
import * as orderService from '../serv
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/deno-runtime-guide.md
- references/oak-middleware.md
- references/oak-performance.md
- references/oak-routing-deployment.md
- references/oak-setup.md
- references/oak-testing.md
FAQ
Что делает скилл oak-backend?
Use when the user asks about Oak, jsr:@oak/oak, Deno Oak router, Oak middleware, ctx.state or Oak body parsing. Produces Oak apps with router modules, ordered middleware, error handling and tests. Not for general Deno runtime setup (use deno).
Как установить скилл oak-backend?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл oak-backend запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…