Skip to content
Back to skills

Architecture

ASecurity

Request pipeline design with a fixed order — request id, CORS, rate limit, authentication, authorization, parsing, validation, error handler. Use when adding or reviewing middleware for a web API.

  • 24 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added October 14, 2026
ai-agentsrustgosqlreactexpressfastapiapibackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned November 22, 2026

npx -y skills add andreibesleaga/GABBE --skill architecture --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Architecture?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Architecture
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-architecture-20852ef9/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-architecture-20852ef9)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: middleware-design
description: Request pipeline design with a fixed order — request id, CORS, rate limit, authentication, authorization, parsing, validation, error handler. Use when adding or reviewing middleware for a web API.
triggers: [middleware design, request pipeline, rate limiting middleware, auth middleware, error handler middleware]
tags: [architecture]
role: eng-backend
context_cost: low
---
# middleware-design Skill

## Goal
This skill guides the creation of the request processing pipeline ("The Onion Architecture").

## Steps
## 1. The Standard Pipeline (Order Matters)

1.  **Request ID**: Generate `trace_id` immediately. (Before logs).
2.  **CORS**: Allow/Block origins. (Before processing).
3.  **Rate Limiter**: Token Bucket algorithm. (Stop abuse cheaply).
4.  **Authentication**: Verify JWT/Session. (Who is it?).
5.  **Authorization**: Check Roles/Scopes. (Can they do it?).
6.  **Body Parser**: JSON/Form parsing. (Limit size to prevent DoS; runs only after the checks above).
7.  **Validation**: Zod/Pydantic schema check. (Is input valid?).
8.  **Controller**: Business Logic.
9.  **Error Handler**: Catch exceptions, format JSON, scrub sensitive data.

## 2. Implementation Rules
- **Fail Fast**: If Rate Limit check fails, return 429 immediately. Do not parse body.
- **Context Passing**: Pass `user` and `trace_id` via Context (Go/React) or Request Object (Express/FastAPI).
- **No Business Logic**: Middleware should be generic. Don't query `SELECT * FROM orders` in middleware.

## 3. Specific Patterns

### Rate Limiting
- **Global**: 1000 req/min/IP.
- **Route-Specific**: Login = 5 req/min/IP.
- **Storage**: Use Redis. Local memory rate limiting doesn't work in clustered apps.

### Response Interceptors
- Use for consistent response formatting.
- `data: { ... }`, `meta: { trace_id: ... }`.

### Error Handling Middleware
- **NEVER** return raw stack trace to client in Production.
- **ALWAYS** log raw stack trace to logger.

## Constraints
- Middleware stays generic: no business queries.
- Pipeline order is fixed as in section 1.

## Output Format
The middleware order list and the middleware code or configuration for the project's framework.

## Limits and safety
- Rate limiting, authentication and authorization run before the body is parsed.
- The final error handler catches everything and strips stack traces, SQL errors and internal addresses.
- Strip or overwrite forwarded headers (`X-Forwarded-For`, `X-User-Role`) from outside unless a trusted proxy sets them.
- Authentication checks expiry and not-before claims, and the revocation list where logout or revocation exists.
- One concern per middleware; with more than one instance, keep rate-limit counters in shared storage, not process memory.

Files in this skill

  • adaptive-architecture.skill.md3.7 KB
  • api-design.skill.md4.7 KB
  • api-standards.skill.md1.7 KB
  • arch-debt.skill.md8.2 KB
  • arch-design.skill.md12.6 KB
  • arch-patterns.skill.md3.9 KB
  • arch-review.skill.md14.1 KB
  • architecture-governance.skill.md3.6 KB
  • attribute-driven-design.skill.md7.5 KB
  • blockchain-dlt.skill.md1.9 KB
  • compatibility-design.skill.md3.6 KB
  • critical-systems-arch.skill.md2 KB
  • design-patterns.skill.md4.3 KB
  • diagramming.skill.md13.9 KB
  • domain-model.skill.md12.1 KB
  • enterprise-migration-scenario.skill.md2 KB
  • enterprise-patterns.skill.md1.9 KB
  • error-handling-strategy.skill.md3.9 KB
  • event-driven-architecture.skill.md1.8 KB
  • event-governance.skill.md3.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.