micro
Expert guidance for micro — asynchronous HTTP microservices framework by Vercel. Use when building lightweight HTTP servers, API endpoints, or microservices using the micro library.
- License 许可
- MIT
- 最近更新
- 2026-09-22
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- micro
- metadata
- { "docs": [ "https://github.com/vercel/micro" ], "priority": 4, "bashPatterns": [ "\\bnpm\\s+(install|i|add)\\s+[^\\n]*\\bmicro\\b", "\\bpnpm\\s+(install|i|add)\\s+[^\\n]*\\bmicro\\b", "\\bbun\\s+(install|i|add)\\s+[^\\n]*\\bmicro\\b", "\\byarn\\s+add\\s+[^\\n]*\\bmicro\\b", "\\bnpx\\s+micro\\b", "\\bnpx\\s+micro-dev\\b" ], "pathPatterns": [], "importPatterns": [ "micro", "micro-dev" ] }
- description
- Expert guidance for micro — asynchronous HTTP microservices framework by Vercel. Use when building lightweight HTTP servers, API endpoints, or microservices using the micro library.
02 资源文件 1
- 参考文档agents/openai.yaml140 B
03 SKILL.md 正文
micro — Asynchronous HTTP Microservices
You are an expert in micro, Vercel's lightweight framework for building asynchronous HTTP microservices in Node.js. micro makes it easy to write single-purpose HTTP endpoints with minimal boilerplate.
Installation
npm install micro
Basic Usage
Create a module that exports a request handler:
// index.ts
import { serve } from 'micro'
const handler = (req: Request) => {
return new Response('Hello, World!')
}
serve(handler)
Or use the classic API:
import { IncomingMessage, ServerResponse } from 'http'
export default (req: IncomingMessage, res: ServerResponse) => {
res.end('Hello, World!')
}
Run with:
npx micro
Core API
json(req) — Parse JSON Body
import { json } from 'micro'
export default async (req: IncomingMessage, res: ServerResponse) => {
const body = await json(req)
return { received: body }
}
text(req) — Parse Text Body
import { text } from 'micro'
export default async (req: IncomingMessage, res: ServerResponse) => {
const body = await text(req)
return `You said: ${body}`
}
buffer(req) — Parse Raw Body
import { buffer } from 'micro'
export default async (req: IncomingMessage, res: ServerResponse) => {
const raw = await buffer(req)
return `Received ${raw.length} bytes`
}
send(res, statusCode, data) — Send Response
import { send } from 'micro'
export default (req: IncomingMessage, res: ServerResponse) => {
send(res, 200, { status: 'ok' })
}
createError(statusCode, message) — HTTP Errors
import { createError } from 'micro'
export default (req: IncomingMessage, res: ServerResponse) => {
if (!req.headers.authorization) {
throw createError(401, 'Unauthorized')
}
return { authorized: true }
}
Development with micro-dev
micro-dev provides hot-reloading for development:
npm install --save-dev micro-dev
# Run in dev mode
npx micro-dev index.js
Composition
Chain multiple handlers with function composition:
import { IncomingMessage, ServerResponse } from 'http'
const cors = (fn: Function) => async (req: IncomingMessage, res: ServerResponse) => {
res.setHeader('Access-Control-Allow-Origin', '*')
return fn(req, res)
}
const handler = async (req: IncomingMessage, res: ServerResponse) => {
return { hello: 'world' }
}
export default cors(handler)
package.json Setup
{
"main": "index.js",
"scripts": {
"start": "micro",
"dev": "micro-dev"
},
"dependencies": {
"micro": "^10.0.0"
},
"devDependencies": {
"micro-dev": "^3.0.0"
}
}
Key Points
- Return values are sent as responses — return strings, objects (auto-serialized to JSON), or Buffers
- Async by default — handlers can be async functions, errors are caught automatically
- Thrown errors become HTTP errors — use
createError()for proper status codes - No routing built-in — micro is a single-endpoint server; use a router like
micro-routerfor multi-route services - Body parsing is explicit — use
json(),text(), orbuffer()to parse request bodies - Composable — wrap handlers with higher-order functions for middleware-like behavior
Official Resources
04 同仓库更多 Skills
skill-installer
Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).
skill-creator
Create or update a Codex skill with appropriately scoped instructions and any needed supporting resources.
review-agent
Perform a read-only, defect-first review of a specified code change and return every actionable finding. Use when another agent delegates review of uncommitted changes, a base-branch diff, a commit, or custom review instructions.
plugin-creator
Create and scaffold plugin directories for Codex with a required `.codex-plugin/plugin.json`, optional plugin folders/files, valid manifest defaults, and personal-marketplace entries by default. Use when Codex needs to create a new personal plugin, add optional plugin structure, generate or update marketplace entries for plugin ordering and availability metadata, or update an existing local plugin during development with the CLI-driven cachebuster and reinstall flow.
openai-docs
Use for Codex models/pricing, scheduled tasks, skills, settings, setup, troubleshooting, customization, automations, and self-knowledge—including 'you,' 'your,' 'this app,' or 'this coding agent' when they refer to Codex—and for OpenAI APIs/products and ChatGPT Work. Also use for model choice/migration, prompting, SDKs, Responses, Realtime, agents, evals, and Chat/Work/Codex comparisons. Do not use for generic app/software tasks that merely mention Codex.
imagegen
Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas.