Back to Skills

nestjs

KubrickCode
Updated Today
79 views
1
1
View on GitHub
Metaaiapidesigndata

About

This skill provides NestJS development standards and architectural patterns for building domain-centric applications. It covers modular design, dependency injection, decorator patterns, and key framework features like controllers, services, middleware, and interceptors. Use it when developing NestJS applications, implementing APIs, configuring microservices, or integrating with databases.

Documentation

NestJS Development Standards

Module Organization Principles

Domain-Centric Modularization

Organize modules by business domain, not by function.

  • ❌ Bad: controllers/, services/, repositories/
  • ✅ Good: users/, products/, orders/

Single Responsibility Module

Each module is responsible for only one domain.

  • Separate common functionality into common/ or shared/ modules
  • Inter-domain communication must go through Services only

Dependency Injection Rules

Constructor Injection Only

Property injection (@Inject) is forbidden.

// ✅ Good
constructor(private readonly userService: UserService) {}

// ❌ Bad
@Inject() userService: UserService;

Provider Registration Location

Providers are registered only in the module where they are used.

  • Minimize global providers
  • Use forRoot/forRootAsync only in AppModule

Decorator Usage Rules

Prioritize Custom Decorators

Abstract repeated decorator combinations into custom decorators.

// Create custom decorator when combining 3+ decorators
@Auth() // Integrates @UseGuards + @ApiBearerAuth + @CurrentUser

Decorator Order

Arrange in execution order from top to bottom.

  1. Metadata decorators (@ApiTags, @Controller, @Resolver)
  2. Guards/Interceptors (@UseGuards, @UseInterceptors)
  3. Route decorators (@Get, @Post, @Query, @Mutation)
  4. Parameter decorators (@Body, @Param, @Args)

DTO/Entity Rules

DTO is Pure Data Transfer

Business logic is forbidden; only validation is allowed.

// ✅ Good: Validation only
class CreateUserDto {
  @IsEmail()
  email: string;
}

// ❌ Bad: Contains business logic
class CreateUserDto {
  toEntity(): User {} // Forbidden
}

Separate Entity and DTO

Never return Entity directly; always convert to DTO.

  • Request: CreateInput, UpdateInput (GraphQL) / CreateDto, UpdateDto (REST)
  • Response: Type definition or plain object

Error Handling

Domain-Specific Exception Filter

Each domain has its own Exception Filter.

@Module({
  providers: [
    {
      provide: APP_FILTER,
      useClass: UserExceptionFilter,
    },
  ],
})

Explicit Error Throwing

Always throw Exception explicitly in all error situations.

  • REST: Use HttpException series
  • GraphQL: Use GraphQLError or custom error
  • Forbid implicit null/undefined returns
  • Error messages should be understandable by users

Quick Install

/plugin add https://github.com/KubrickCode/ai-config-toolkit/tree/main/nestjs

Copy and paste this command in Claude Code to install this skill

GitHub 仓库

KubrickCode/ai-config-toolkit
Path: .claude/skills/nestjs

Related Skills

llamaguard

Other

LlamaGuard is Meta's 7-8B parameter model for moderating LLM inputs and outputs across six safety categories like violence and hate speech. It offers 94-95% accuracy and can be deployed using vLLM, Hugging Face, or Amazon SageMaker. Use this skill to easily integrate content filtering and safety guardrails into your AI applications.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill