/harness-claude:nestjs-middleware-patternfrom harness-claude
Applies NestMiddleware and functional middleware with consumer.forRoutes binding. Covers class-based, functional, global Express middleware, route exclusion, and chaining.
Claude never picks this skill on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /harness-claude:nestjs-middleware-pattern still runs it.
What the skill costs in Claude's context, stage by stage
No description Claude Code can read, so Claude's list leaves it out: only you can start it.
SKILL.md joins the conversation and stays.
Apply NestMiddleware and functional middleware with consumer.forRoutes binding
helmet, compression, cors) into a NestJS appNestMiddleware:@Injectable()
export class CorrelationIdMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction): void {
req['correlationId'] = req.headers['x-correlation-id'] ?? randomUUID();
res.setHeader('X-Correlation-ID', req['correlationId']);
next();
}
}
export function requestLogger(req: Request, res: Response, next: NextFunction): void {
console.log(`${req.method} ${req.url}`);
next();
}
configure(consumer: MiddlewareConsumer):@Module({ controllers: [UsersController] })
export class UsersModule implements NestModule {
configure(consumer: MiddlewareConsumer): void {
consumer.apply(CorrelationIdMiddleware).forRoutes(UsersController); // apply to entire controller
consumer.apply(requestLogger).forRoutes({ path: 'users', method: RequestMethod.GET }); // specific method
}
}
consumer
.apply(AuthMiddleware)
.exclude({ path: 'auth/login', method: RequestMethod.POST })
.forRoutes(UsersController);
main.ts (no NestJS wiring needed):import helmet from 'helmet';
app.use(helmet());
app.use(compression());
.apply(Middleware1, Middleware2).forRoutes(...) — they execute in order.NestJS middleware is equivalent to Express middleware — it receives (req, res, next) and must call next() or terminate the response. It runs before any NestJS-specific pipeline elements (guards, interceptors, pipes).
Middleware vs Guards: Middleware runs before routing. Guards run after routing with handler/controller metadata available. For authentication, use guards (they have ExecutionContext). For infrastructure concerns (logging, tracing, rate limiting), use middleware.
forRoutes() target types:
{ path, method } object — applies to specific HTTP method + path combinationsClass vs functional: Class middleware can inject providers (e.g., LoggerService, ConfigService) through the constructor. Functional middleware is simpler and slightly faster but cannot use DI. Choose functional when no injection is needed.
Execution order: Middleware declared in a module applies only to routes in that module (unless applied globally via app.use()). Import order in AppModule determines middleware execution order across modules.
Async middleware: Both class and functional middleware can be async. Errors thrown (or passed to next(err)) propagate to NestJS exception filters.
https://docs.nestjs.com/middleware
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeRead when SKILL.md points to them.
793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job