---
name: "nestjs-custom-decorators-metadata"
description: "Create clean parameter decorators to extract authenticated users, IP addresses, and metadata."
metadata:
  author: "NestJS"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "create custom decorator nestjs"
  - "@currentuser decorator nestjs"
  - "createparamdecorator nestjs"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# NestJS Custom Decorators & Execution Context Extraction

Authors NestJS custom parameter decorators with createParamDecorator: extracting current user (@CurrentUser), tenant ID (@CurrentTenant), user IP, and creating custom method metadata decorators using Reflector.

## When to Invoke
Invoke this skill whenever you need to:
- create custom decorator nestjs
- @currentuser decorator nestjs
- createparamdecorator nestjs

## Execution SOP & Rules
1. Use createParamDecorator((data: unknown, ctx: ExecutionContext) => { const req = ctx.switchToHttp().getRequest(); return req.user; }).
2. Consume in controller: @Get('profile') getProfile(@CurrentUser() user: UserEntity) { return user; }.
3. For metadata decorators: export const IS_PUBLIC_KEY = 'isPublic'; export const Public = () => SetMetadata(IS_PUBLIC_KEY, true);.
4. In global guards, check metadata with reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [...]).

## 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.
