agentsclimarketplace

Nestjs interceptors

Skill dkmqflx/nestjs-best-practices-plugin/plugins/nestjs-best-practices/skills/nestjs-interceptors

Claude Code plugin: 12 NestJS best-practice skills (90 rules) grounded in the official NestJS docs

Install
npx -y skills add dkmqflx/nestjs-best-practices-plugin --skill nestjs-interceptors

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

NestJS interceptors best practices. Use when writing or reviewing NestJS interceptors — response transformation, logging, timeouts, or caching around handlers. Triggers on NestInterceptor, intercept(), CallHandler, map(), or @UseInterceptors.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

2.5 KB, as published. Nobody here has run it

NestJS Interceptors

Interceptors are @Injectable() classes implementing NestInterceptor. Their intercept(context: ExecutionContext, next: CallHandler) method runs logic before the route handler and transforms the response stream returned by next.handle() using RxJS operators. They are the idiomatic place for cross-cutting concerns — response shaping, logging, timeouts, caching — that should stay out of controllers and services.

When to Apply

Apply these rules when you are:

  • Writing or reviewing a class that implements NestInterceptor.
  • Wrapping handler responses in a consistent envelope.
  • Adding request/response logging or latency measurement.
  • Enforcing per-request timeouts.
  • Caching GET responses with CacheInterceptor.
  • Deciding whether to bind an interceptor globally, per-controller, or per-route.

Do not reach for an interceptor when the work is core business logic — that belongs in a service (see interceptors-not-for-mutation-logic).

Rules

RuleImpactSummary
response-transform-interceptorHIGHWrap responses in a consistent envelope via map().
logging-interceptorMEDIUMMeasure handler duration with tap(); log method/url/time.
timeout-interceptorHIGHFail slow requests with timeout() + RequestTimeoutException.
cache-interceptorMEDIUMCache GET responses with CacheInterceptor + CacheModule.
interceptors-not-for-mutation-logicHIGHKeep business logic in services; interceptors are cross-cutting only.
bind-globally-vs-scopedMEDIUMPrefer APP_INTERCEPTOR for DI-friendly global binding.

How to Use

  1. Identify the cross-cutting concern (transform, log, timeout, cache).
  2. Open the matching rule file and follow the Correct pattern.
  3. Keep intercept() thin — pipe RxJS operators onto next.handle(), never put domain logic inside.
  4. Choose a binding scope with bind-globally-vs-scoped: route, controller, or global via APP_INTERCEPTOR.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.