Install any skill in seconds. Free to start, no credit card required.
Get Started Free →NestJS architecture patterns for modules, controllers, providers, DTO validation, guards, interceptors, config, and production-grade TypeScript backends.
.claude/skills/affaan-m-nestjs-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 6% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 66% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 72% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 92% | 0% |
| case-09 | ✓→✓ | = Same ✓ | 22% | 0% |
适用于模块化 TypeScript 后端的生产级 NestJS 模式。
textsrc/ ├── app.module.ts ├── main.ts ├── common/ │ ├── filters/ │ ├── guards/ │ ├── interceptors/ │ └── pipes/ ├── config/ │ ├── configuration.ts │ └── validation.ts ├── modules/ │ ├── auth/ │ │ ├── auth.controller.ts │ │ ├── auth.module.ts │ │ ├── auth.service.ts │ │ ├── dto/ │ │ ├── guards/ │ │ └── strategies/ │ └── users/ │ ├── dto/ │ ├── entities/ │ ├── users.controller.ts │ ├── users.module.ts │ └── users.service.ts └── prisma/ or database/
common/ 中。tsasync function bootstrap() { const app = await NestFactory.create(AppModule, { bufferLogs: true }); app.useGlobalPipes( new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true, transformOptions: { enableImplicitConversion: true }, }), ); app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector))); app.useGlobalFilters(new HttpExceptionFilter()); await app.listen(process.env.PORT ?? 3000); } bootstrap();
whitelist 和 forbidNonWhitelisted。ts@Module({ controllers: [UsersController], providers: [UsersService], exports: [UsersService], }) export class UsersModule {} @Controller('users') export class UsersController { constructor(private readonly usersService: UsersService) {} @Get(':id') getById(@Param('id', ParseUUIDPipe) id: string) { return this.usersService.getById(id); } @Post() create(@Body() dto: CreateUserDto) { return this.usersService.create(dto); } } @Injectable() export class UsersService { constructor(private readonly usersRepo: UsersRepository) {} async create(dto: CreateUserDto) { return this.usersRepo.create(dto); } }
tsexport class CreateUserDto { @IsEmail() email!: string; @IsString() @Length(2, 80) name!: string; @IsOptional() @IsEnum(UserRole) role?: UserRole; }
class-validator 验证每个请求 DTO。ts@UseGuards(JwtAuthGuard, RolesGuard) @Roles('admin') @Get('admin/report') getAdminReport(@Req() req: AuthenticatedRequest) { return this.reportService.getForUser(req.user.id); }
ts@Catch() export class HttpExceptionFilter implements ExceptionFilter { catch(exception: unknown, host: ArgumentsHost) { const response = host.switchToHttp().getResponse<Response>(); const request = host.switchToHttp().getRequest<Request>(); if (exception instanceof HttpException) { return response.status(exception.getStatus()).json({ path: request.url, error: exception.getResponse(), }); } return response.status(500).json({ path: request.url, error: 'Internal server error', }); } }
tsConfigModule.forRoot({ isGlobal: true, load: [configuration], validate: validateEnv, });
tsdescribe('UsersController', () => { let app: INestApplication; beforeAll(async () => { const moduleRef = await Test.createTestingModule({ imports: [UsersModule], }).compile(); app = moduleRef.createNestApplication(); app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); await app.init(); }); });
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-15 | fail→fail | 11,858 | 9,094 | -23% | 1 | 1 | 0% | 2,237 | 3,296 | +47% | 0 | 0 | — |
case-01 | fail→pass | 12,785 | 6,033 | -53% | 1 | 1 | 0% | 2,810 | 2,985 | +6% | 0 | 0 | — |
case-02 | pass→pass | 10,549 | 11,052 | +5% | 1 | 1 | 0% | 2,385 | 3,968 | +66% | 0 | 0 | — |
case-03 | pass→pass | 8,204 | 6,407 | -22% | 1 | 1 | 0% | 1,650 | 2,835 | +72% | 0 | 0 | — |
case-04 | pass→pass | 6,250 | 4,666 | -25% | 1 | 1 | 0% | 1,314 | 2,529 | +92% | 0 | 0 | — |
case-09 | pass→pass | 14,937 | 10,388 | -30% | 1 | 1 | 0% | 3,310 | 4,047 | +22% | 0 | 0 | — |
case-05 | pass→pass | 10,658 | 5,918 | -44% | 1 | 1 | 0% | 1,807 | 2,722 | +51% | 0 | 0 | — |
case-06 | pass→pass | 8,463 | 6,386 | -25% | 1 | 1 | 0% | 1,773 | 2,803 | +58% | 0 | 0 | — |
case-07 | pass→pass | 12,681 | 10,454 | -18% | 1 | 1 | 0% | 2,300 | 3,670 | +60% | 0 | 0 | — |
case-08 | pass→pass | 12,303 | 10,433 | -15% | 1 | 1 | 0% | 2,382 | 3,683 | +55% | 0 | 0 | — |
case-10 | pass→pass | 10,333 | 9,671 | -6% | 1 | 1 | 0% | 1,959 | 3,352 | +71% | 0 | 0 | — |
case-11 | pass→pass | 10,154 | 9,396 | -7% | 1 | 1 | 0% | 1,948 | 3,348 | +72% | 0 | 0 | — |
case-12 | pass→pass | 11,306 | 5,818 | -49% | 1 | 1 | 0% | 2,063 | 2,780 | +35% | 0 | 0 | — |
case-13 | pass→pass | 8,442 | 9,269 | +10% | 1 | 1 | 0% | 1,717 | 3,563 | +108% | 0 | 0 | — |
case-14 | pass→pass | 11,387 | 7,452 | -35% | 1 | 1 | 0% | 1,948 | 3,023 | +55% | 0 | 0 | — |
case-16 | pass→pass | 7,075 | 5,288 | -25% | 1 | 1 | 0% | 1,548 | 2,719 | +76% | 0 | 0 | — |
case-17 | pass→pass | 16,840 | 15,674 | -7% | 1 | 1 | 0% | 3,444 | 4,833 | +40% | 0 | 0 | — |
case-18 | pass→pass | 12,811 | 9,649 | -25% | 1 | 1 | 0% | 2,446 | 3,526 | +44% | 0 | 0 | — |
case-19 | pass→pass | 16,943 | 6,334 | -63% | 1 | 1 | 0% | 3,189 | 2,723 | -15% | 0 | 0 | — |
case-20 | pass→pass | 7,940 | 7,080 | -11% | 1 | 1 | 0% | 1,639 | 3,051 | +86% | 0 | 0 | — |
case-21 | pass→pass | 4,645 | 5,605 | +21% | 1 | 1 | 0% | 1,004 | 2,818 | +181% | 0 | 0 | — |
case-22 | pass→pass | 12,706 | 10,186 | -20% | 1 | 1 | 0% | 2,796 | 3,890 | +39% | 0 | 0 | — |
case-23 | pass→pass | 3,313 | 2,517 | -24% | 1 | 1 | 0% | 658 | 2,125 | +223% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.