decorator-patterns

Select and compose NestJS built-in decorators for controllers, guards, and interceptors.

9|1|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/AratKruglik/antigravity-sdlc --skill decorator-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: decorator-patterns
Source: https://github.com/AratKruglik/antigravity-sdlc/tree/main/plugins/nestjs-plugin/skills/decorator-patterns
Command: npx skills add https://github.com/AratKruglik/antigravity-sdlc --skill decorator-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

NestJS projects often suffer from unclear decorator usage and tangled metadata when composing guards, interceptors, routes, and custom decorators. This skill clarifies which built-in decorators to use, how to create custom parameter decorators with createParamDecorator, and how to compose decorators with applyDecorators to reduce boilerplate and avoid common pitfalls.

Core Features & Use Cases

  • Built-in class-, method-, and parameter-level decorators and how to apply them to controllers, services, and routes.
  • Custom param decorators via createParamDecorator and integration with Reflector to read metadata at runtime.
  • Metadata composition with applyDecorators and example meta-decorators to reduce boilerplate.
  • Guidance on common patterns and anti-patterns to avoid misconfigurations and DI/routing bugs.

Quick Start

Review the examples and implement a small NestJS demo with a custom @CurrentUser decorator and a Roles guard applied to a controller.

Frequently Asked Questions about decorator-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom param decorators in NestJS?

Create custom param decorators in NestJS using the createParamDecorator function, integrating with Reflector to read metadata at runtime. This approach clarifies which built-in decorators to use for controllers, services, and routes.

What's the best way to compose multiple NestJS decorators to reduce boilerplate?

Compose multiple NestJS decorators using applyDecorators to reduce boilerplate. This method combines class, method, and parameter-level decorators, preventing misconfigurations and routing bugs while keeping controller code clean and scalable.

How does SetMetadata work with Reflector in NestJS guards and interceptors?

SetMetadata attaches custom metadata to routes, which Reflector retrieves at runtime in guards and interceptors. This mechanism enables role-based access control and route-specific configurations without hardcoding logic into controllers.

Can I combine custom NestJS decorators with built-in guards and interceptors?

Yes, you can combine custom NestJS decorators with built-in guards and interceptors. Custom decorators like @CurrentUser integrate with roles guards, applying metadata that guards read to enforce access control across routes.

What are common anti-patterns when using decorators in NestJS controllers?

Common NestJS decorator anti-patterns include misconfiguring dependency injection, tangling metadata composition, and incorrect route parameter binding. Avoid these by following established patterns for custom decorators and Reflector usage.