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…
by j4flmao★ 47 GitHub stars
Install oak-backend in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
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
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- 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
What does the oak-backend skill do?
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).
How do I install the oak-backend skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the oak-backend skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
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…