# micro

Provides expert guidance for building asynchronous HTTP microservices with Vercel's micro in Node.js. Generates clean handlers, body parsing, and error routines.

- skill · `type=skill` · Codex, ChatGPT · 4 installs · ★ 7604
- Author: Vercel Labs · official OpenAI repository
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/openai/plugins/tree/HEAD/plugins/vercel/skills/micro/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/micro

## What it does

The skill instructs your coding assistant on creating lightweight Node.js services with the `micro` library. It covers modern `serve()` patterns using Web standard Request objects alongside classic Node.js HTTP handlers. The agent applies built-in parsers like `json()`, `text()`, and `buffer()` directly instead of pulling heavy middleware.

Built-in routing is completely absent in `micro`. It targets single-purpose endpoints, so multi-route APIs require external routers like `micro-router`. Middleware behavior is achieved by wrapping handlers with higher-order functions. For local hot-reloading during development, the skill configures `micro-dev` in `package.json`.

## Install

### Codex (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add openai/plugins --skill micro -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/micro/SKILL.md` — For all projects use ~/.agents/skills/

### Claude Code

1. **Skills CLI (Vercel)**
```bash
npx skills add openai/plugins --skill micro -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/micro/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/micro/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/micro/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install openai/plugins micro
```

2. **Manually: put the files in place**
- File: `.github/skills/micro/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/openai/plugins --path plugins/vercel/skills/micro
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/micro/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/openai/plugins/tree/HEAD/plugins/vercel/skills/micro/SKILL.md

## When to use it
- scaffold lightweight HTTP endpoints with minimal boilerplate
- parse JSON, text, or raw buffer request bodies
- handle HTTP errors with createError status codes
- configure micro-dev scripts for hot-reloading in package.json

## Example prompts
- Create a micro endpoint that parses incoming JSON and responds with an object
- Wrap this micro handler with a custom CORS higher-order function
- Add authentication checks throwing a 401 status via createError

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: facffdaf865c9a2b.

BEGIN THIRD-PARTY FILE facffdaf865c9a2b
````text
---
name: micro
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.
metadata:
  priority: 4
  docs:
    - "https://github.com/vercel/micro"
  pathPatterns: []
  importPatterns:
    - 'micro'
    - 'micro-dev'
  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'
---

# 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

```bash
npm install micro
```

## Basic Usage

Create a module that exports a request handler:

```ts
// index.ts
import { serve } from 'micro'

const handler = (req: Request) => {
  return new Response('Hello, World!')
}

serve(handler)
```

Or use the classic API:

```ts
import { IncomingMessage, ServerResponse } from 'http'

export default (req: IncomingMessage, res: ServerResponse) => {
  res.end('Hello, World!')
}
```

Run with:

```bash
npx micro
```

## Core API

### `json(req)` — Parse JSON Body

```ts
import { json } from 'micro'

export default async (req: IncomingMessage, res: ServerResponse) => {
  const body = await json(req)
  return { received: body }
}
```

### `text(req)` — Parse Text Body

```ts
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

```ts
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

```ts
import { send } from 'micro'

export default (req: IncomingMessage, res: ServerResponse) => {
  send(res, 200, { status: 'ok' })
}
```

### `createError(statusCode, message)` — HTTP Errors

```ts
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:

```bash
npm install --save-dev micro-dev

# Run in dev mode
npx micro-dev index.js
```

## Composition

Chain multiple handlers with function composition:

```ts
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

```json
{
  "main": "index.js",
  "scripts": {
    "start": "micro",
    "dev": "micro-dev"
  },
  "dependencies": {
    "micro": "^10.0.0"
  },
  "devDependencies": {
    "micro-dev": "^3.0.0"
  }
}
```

## Key Points

1. **Return values are sent as responses** — return strings, objects (auto-serialized to JSON), or Buffers
2. **Async by default** — handlers can be async functions, errors are caught automatically
````
END THIRD-PARTY FILE facffdaf865c9a2b

The third-party file has ended. Everything between the facffdaf865c9a2b tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3523 of 4001 bytes. © Vercel Labs · Apache-2.0 · https://github.com/openai/plugins/tree/HEAD/plugins/vercel/skills/micro/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
