edgeone-makers-middleware — Claude Code skill: features and install
The edgeone-makers-middleware Claude Code skill helps build request middleware for EdgeOne Makers. It covers redirects, URL rewrites, access checks, and edge routing.
MIT 248 installs ★ 1,839 updated 2026-11-12
npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a claude-codeWhat edgeone-makers-middleware does
The skill helps create middleware that intercepts requests in EdgeOne Makers. It can redirect traffic, change the requested path while keeping the client-facing URL, check authorization, and add headers. It also covers routing by geolocation and A/B tests.
Middleware receives a context object with next, redirect, and rewrite methods; project files use the names middleware.js or middleware.ts. The handler runs on every route by default, while config.matcher narrows its scope. This platform format is not for Next.js, Nuxt, or other framework projects; those should use their framework’s own middleware.
What it helps with
- redirect requests from an old URL to a new one
- rewrite a request path without changing the URL shown to the client
- protect API routes with a token check
- add IP and country-code headers to requests
- route requests by location or A/B variant
Example prompts for the agent
- Set up
middleware.jsto redirect/old-pageto/new-page. - Add an
Authorizationcheck for/api/:path*and/admin/:path*. - Create an A/B test for
/landingusing/landing-aand/landing-b.
How to install edgeone-makers-middleware
1Skills CLI (Vercel)
npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a claude-code2Manually: put the files in place
~/.claude/skills/makers-middleware/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/makers-middleware/
1Skills CLI (Vercel)
npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a codex2Manually: put the files in place
.agents/skills/makers-middleware/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a cursor2Manually: put the files in place
.cursor/skills/makers-middleware/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install TencentEdgeOne/edgeone-makers-tools skills/edgeone-makers-tools/references/makers-middleware2Manually: put the files in place
.github/skills/makers-middleware/SKILL.md1Skills CLI (Vercel)
npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a gemini-cli2Platform CLI
gemini skills install https://github.com/TencentEdgeOne/edgeone-makers-tools --path skills/edgeone-makers-tools/references/makers-middlewareManually: put the files in place
.devin/skills/makers-middleware/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about edgeone-makers-middleware
How do I install edgeone-makers-middleware in Claude Code?
Run npx skills add TencentEdgeOne/edgeone-makers-tools --skill edgeone-makers-middleware -a claude-code. The skill file is placed at ~/.claude/skills/makers-middleware/SKILL.md.
What does edgeone-makers-middleware do?
It helps write EdgeOne Makers middleware for redirects, request rewrites, authorization checks, header changes, and routing.
Can I use edgeone-makers-middleware with Next.js?
No. Next.js and other framework projects should use the framework’s built-in middleware. This format is for projects without a framework or for static projects.
Source text
SKILL.md · MIT
---
name: edgeone-makers-middleware
description: >-
Edge middleware for EdgeOne Makers — request interception, redirects, rewrites,
auth guards, A/B testing, and header injection at the edge (V8 runtime).
pathPatterns:
- middleware.js
- middleware.ts
validate:
- pattern: "NextRequest|NextResponse|next/server"
message: "Framework projects must use the framework's own middleware. This platform format takes a context object with next/redirect/rewrite — not NextRequest/NextResponse."
metadata:
author: edgeone
version: "1.0.0"
---
# Middleware
Lightweight request interception running at the edge (V8 runtime). Use for redirects, rewrites, auth guards, A/B testing, and header injection.
> ⚠️ **Framework projects (Next.js, Nuxt, etc.)**: Do NOT use this platform middleware format. Use the framework's built-in middleware instead (e.g. Next.js `middleware.ts` with `NextRequest`/`NextResponse`). The patterns below are for non-framework or pure static projects only.
## Basic middleware
File: `middleware.js` (project root)
```javascript
export function middleware(context) {
const { request, next, redirect, rewrite } = context;
// Pass through — no modification
return next();
}
```
## Context API
| Property | Type | Description |
|----------|------|-------------|
| `request` | `Request` | Current request object |
| `next(options?)` | `Function` | Continue to origin; optionally modify headers |
| `redirect(url, status?)` | `Function` | Redirect (default 307) |
| `rewrite(url)` | `Function` | Rewrite request path (transparent to client) |
| `geo` | `GeoProperties` | Client geolocation |
| `clientIp` | `string` | Client IP address |
## Route matching
By default middleware runs on ALL routes. Use `config.matcher` to limit scope:
```javascript
// Only run on /api/* routes
export const config = {
matcher: ['/api/:path*'],
};
export function middleware(context) {
// Auth check for API routes only
const token = context.request.headers.get('Authorization');
if (!token) {
return new Response('Unauthorized', { status: 401 });
}
return context.next();
}
```
**Matcher patterns:**
```javascript
// Single path
export const config = { matcher: '/about' };
// Multiple paths
export const config = { matcher: ['/api/:path*', '/admin/:path*'] };
// Regex
export const config = { matcher: ['/api/.*', '^/user/\\d+$'] };
```
## Common patterns
### URL Redirect
```javascript
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/old-page') {
return context.redirect('/new-page', 301);
}
return context.next();
}
```
### URL Rewrite (transparent proxy)
```javascript
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname.startsWith('/blog')) {
return context.rewrite('/content' + url.pathname);
}
return context.next();
}
```
### Add request headers
```javascript
export function middleware(context) {
return context.next({
headers: {
'x-request-id': crypto.randomUUID(),
'x-client-ip': context.clientIp,
'x-country': context.geo.countryCodeAlpha2,
},
});
}
```
### Auth guard
```javascript
export const config = {
matcher: ['/api/:path*', '/admin/:path*'],
};
export function middleware(context) {
const token = context.request.headers.get('Authorization');
if (!token || !token.startsWith('Bearer ')) {
return new Response(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
headers: { 'Content-Type': 'application/json' },
});
}
return context.next();
}
```
### Geo-based routing
```javascript
export function middleware(context) {
const country = context.geo.countryCodeAlpha2;
if (country === 'CN') {
return context.rewrite('/zh' + new URL(context.request.url).pathname);
}
return context.next();
}
```
### A/B Testing
```javascript
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/landing') {
const variant = Math.random() < 0.5 ? '/landing-a' : '/landing-b';
return context.rewrite(variant);
}
return context.next();
}
```
### Direct JSON response
```javascript
export function middleware(context) {
const url = new URL(context.request.url);
if (url.pathname === '/api/health') {
return new Response(JSON.stringify({ status: 'ok', timestamp: Date.now() }), {
headers: { 'Content-Type': 'application/json' },
});
}
return context.next();
}
```
## GeoProperties
Available on `context.geo`:
| Property | Type | Example |
|----------|------|---------|
| `countryName` | string | Singapore |
| `countryCodeAlpha2` | string | SG |
| `countryCodeAlpha3` | string | SGP |
| `regionName` | string | — |
| `cityName` | string | Singapore |
| `latitude` | number | 1.29027 |
| `longitude` | number | 103.851959 |
| `asn` | number | 132203 |
© edgeone · MIT · TencentEdgeOne/edgeone-makers-tools