new-middleware

new-middleware is a skill for Claude Code from zuoyebang/aiweave. It costs 16 tokens per session (905 once invoked), scanned A, original, Apache-2.0.

A skill that generates Gin authentication middleware from a middleware design document. Gin is a Go web framework, and middleware is code that checks or changes a request before it reaches an endpoint.

In plain words
What is it for?
Use it to create middleware for private-network checks, request-signature validation, or role-based permissions. It also covers required documentation, Redis or helper dependencies, and route registration.
Why use it?
It connects the written middleware design with the expected Go files, dependencies, configuration, and error responses. This helps keep authentication behavior aligned with the project's routing and protocol rules.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is go build ./middleware/....

Good fit Use it to create middleware for private-network checks, request-signature validation, or role-based permissions. It also covers required documentation, Redis or helper dependencies, and route registration.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/zuoyebang/aiweave
agentmods
npx agentmods add skills/zuoyebang/aiweave/new-middleware

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for new-middleware

README.md
[![agentmods](https://agentmods.dev/badge/skills/zuoyebang/aiweave/new-middleware.svg)](https://agentmods.dev/skills/zuoyebang/aiweave/new-middleware)
Your own site
<a href="https://agentmods.dev/skills/zuoyebang/aiweave/new-middleware"><img src="https://agentmods.dev/badge/skills/zuoyebang/aiweave/new-middleware.svg" alt="Measured on agentmods" height="20"></a>
Per session 16 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 905 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00016 $0.00905
Opus 5 $0.00008 $0.00452
Sonnet 5 $0.00003 $0.00181
Haiku 4.5 $0.00002 $0.00090

Measured 8d ago against content hash e2d8fa2b4fb5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

new-middleware scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

templates/skills/new-middleware/SKILL.md · 93 lines

What it actually says

根据 $ARGUMENTS 生成认证中间件。

公共步骤模板见 skills-spec/01_skill_authoring_guide.md §A-§E。本 Skill 特定内容如下。

第 0 步:拒绝规则与依赖前置

  • ⛔ 拒绝(§A.1):N/A(中间件通常不触发暂不实现模块)
  • 状态检查(§A.2):读 BUILD_STATUS.md §2 中 middleware 行
  • 依赖(§A.3):依赖的 helpers / Redis Key / 配置项必须就绪

第 1 步:读取设计文档(公共必读见 §B)

  • 主文档:docs/architecture/middleware.md 对应中间件规格
  • 额外必读:
    • docs/architecture/routing.md §1 中间件链
    • 签名类中间件 → docs/architecture/{核心校验链}_flow.md §1 签名算法
    • docs/architecture/render_functions.md(错误响应格式)

第 2 步:识别中间件类型

类型 关键逻辑
内网 IP 白名单 检查 ctx.ClientIP() 是否属于内网段
签名校验 MD5 / HMAC + 时间窗口校验
角色权限 提取 X-{Actor}-Role + 接口权限矩阵

第 3 步:生成中间件文件

文件路径:middleware/{name}.go

package middleware

import (
    "{project}/components"
    "{project}/helpers"
    "{project}/pkg/gin"
    "{project}/pkg/golib/v2/tlog"
)

func {Name}() gin.HandlerFunc {
    return func(ctx *gin.Context) {
        // 1. {步骤 1}
        // 2. {步骤 2}
        // ...
        // N. ctx.Set("{key}", {value})
        ctx.Next()
    }
}

错误响应处理(关键)

  • 与外部协议对齐的路由组(Internal)→ ctx.AbortWithStatusJSON(200, gin.H{"status":...,"message":...,"data":nil})
  • 标准内部路由组(UserSelf/Admin)→ base.RenderJsonAbort(ctx, components.ErrorXxx)
  • 不要混用!

第 4 步:文档同步(公共项见 §C)

  • 确认 middleware.md 规格与实现一致
  • 确认 routing.md §1 中间件链描述一致
  • 更新 BUILD_STATUS 状态

第 5 步:测试同步(4 类用例标准见 §D)

中间件本身不对应单接口测试,必须通过覆盖该路由组的下游接口测试间接覆盖:

中间件类型 测试覆盖
签名校验类 test/cases/internal/{module}_{action}_test.go(含签名错误 / 时间过期 / 缺参数等)
调用方身份注入类 test/cases/operator/common_test.go(IP 白名单 / {actor-id} 注入)
角色权限校验类 test/cases/admin/common_test.go(多角色权限矩阵)

第 6 步:验证(公共格式见 §E)

go build ./middleware/...
go vet ./middleware/...
cd test && go test -v ./cases/{scope}/...

🧩 AIWeave 骨架 · 作者 XuRuibo [email protected] · Apache-2.0 · 模板文件,复制到工程后按业务语义填充

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 93 lines · 16 tokens per session scan A e2d8fa2b4fb5

Subscribe to this mod's changes

new-middleware is a skill published in the GitHub repository zuoyebang/aiweave (20 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 16 tokens to every session and 905 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

build-teaql-app

Build or change a TeaQL application in Java, Rust, Go, Swift, Python, C#/.NET, or TypeScript, including Kotlin/JVM applications that consume Java-generated libraries. Mandatory order: first draft and save a complete KSML model, then verify the client and evaluate that saved model, repair it through repeated evaluation…

teaql/teaql-agent-kit · 112 tokens

add-rpc

Guide for adding new RPC calls to Wave Terminal. Use when implementing new RPC commands, adding server-client communication methods, or extending the RPC interface with new functionality.

mits-pl/wove · 36 tokens

wps-events

Guide for working with Wave Terminal's WPS (Wave PubSub) event system. Use when implementing new event types, publishing events, subscribing to events, or adding asynchronous communication between components.

mits-pl/wove · 41 tokens

electron-api

Guide for adding new Electron APIs to Wave Terminal. Use when implementing new frontend-to-electron communications via preload/IPC.

mits-pl/wove · 27 tokens

compact-error-handling

How to eliminate verbose, repetitive try-catch blocks in generated code by using multi-exception tuples, contextlib.suppress, and functional Result types, cutting error boilerplate by 60%.

alivirgo/Major-AI-Skills · 43 tokens

api-runtime-verify

Verify an implemented backend HTTP surface at runtime: per route, record the request actually made, the HTTP status, the response content-type, and the observed body shape, assert each response against the slice's acceptance behavior, classify the findings, and decide a PASS/FAIL/BLOCKED runtime gate. The probe's real…

Mozurok/fhorja.dev · 216 tokens