NestJS
Avoid common NestJS mistakes — DI scoping, circular dependencies, validation pipes, and module organization traps.
от clawic★ 23 звезды на GitHub
Установить NestJS в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Dependency Injection
- Provider not available — must be in
providersarray ANDexportsif used by other modules - Circular dependency crashes — use
forwardRef(() => Module)in both modules - Default scope is singleton — same instance across requests, careful with state
- Request-scoped provider —
@Injectable({ scope: Scope.REQUEST }), propagates to dependents
Module Organization
- Import module, not provider directly —
imports: [UserModule]notproviders: [UserService] exportsmakes providers available to importers — without it, provider stays private- Global modules need
@Global()decorator — only for truly shared (config, logger) forRoot()vsforRootAsync()— async for when config depends on other providers
Validation
ValidationPipeneedsclass-validatordecorators — plain classes won't validate- Enable
transform: truefor auto-transformation — string"1"to number1 whitelist: truestrips unknown properties —forbidNonWhitelisted: trueto error instead- Nested objects need
@ValidateNested()AND@Type(() => NestedDto)— both required
Execution Order
- Middleware → Guards → Interceptors (pre) → Pipes → Handler → Interceptors (post) → Filters
- Guards can't access transformed body — run before pipes
- Global pipes run before route pipes — but after guards
- Exception filters catch errors from entire chain — including guards and pipes
Exception Handling
throw new HttpException()notreturn— must throw for filter to catch- Custom exceptions extend
HttpException— or implementExceptionFilter - Unhandled exceptions become 500 — wrap external calls in try/catch
- Built-in exceptions:
BadRequestException,NotFoundException, etc. — use these, not generic HttpException
Testing
createTestingModuledoesn't auto-mock — provide mocks explicitly inproviders- Override with
.overrideProvider(X).useValue(mock)— before.compile() - E2E tests need
app.init()— andapp.close()in afterAll - Request-scoped providers complicate unit tests — consider making them singleton when possible
Common Mistakes
@Body()without DTO returns plain object — no validation, no transformation@Param('id')is always string — useParseIntPipefor number:@Param('id', ParseIntPipe)- Guards returning false gives 403 — throw specific exception for better error messages
- Async providers need factory —
useFactory: async () => await createConnection() - Forgetting
awaiton async service methods — returns Promise, not value
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- _meta.json
FAQ
Что делает скилл NestJS?
Avoid common NestJS mistakes — DI scoping, circular dependencies, validation pipes, and module organization traps.
Как установить скилл NestJS?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл NestJS запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…