---
name: "nestjs-interceptors-logging-transform"
description: "Intercept execution flow to log execution timing, transform responses, and handle caching."
metadata:
  author: "NestJS"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "write nestjs interceptor"
  - "transform response nestjs interceptor"
  - "log execution time interceptor"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# NestJS Interceptors Request Transformation & Logging

Authors NestJS Interceptors implementing NestInterceptor: transforming response data with RxJS map, measuring endpoint latency with tap, overriding exceptions with catchError, and implementing Redis caching interceptors.

## When to Invoke
Invoke this skill whenever you need to:
- write nestjs interceptor
- transform response nestjs interceptor
- log execution time interceptor

## Execution SOP & Rules
1. Implement intercept(context: ExecutionContext, next: CallHandler): Observable<any> interface.
2. Transform response streams using RxJS pipe(): return next.handle().pipe(map(data => ({ data })))
3. Record execution duration: const now = Date.now(); return next.handle().pipe(tap(() => console.log(`${Date.now() - now}ms`))).
4. Apply interceptor via @UseInterceptors(TransformInterceptor) or globally via app.useGlobalInterceptors().

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
