[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75FEEXYCG98T0FM5AF4ZXG2":3,"skill-same:01M75FEEXYCG98T0FM5AF4ZXG2":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M75FEEXYCG98T0FM5AF4ZXG2","nestjs-patterns",null,"NestJS architecture patterns for modules, controllers, providers, DTO validation, guards, interceptors, config, and production-grade TypeScript backends.","agisota\u002Fold-one","agisota","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121413592?v=4","01M75B4BRNT67EC1NDRT8QZEP2","01M75B4BS7QR9VP580MSCPTS3X",3,"MIT","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fnestjs-patterns\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: nestjs-patterns\ndescription: NestJS architecture patterns for modules, controllers, providers, DTO validation, guards, interceptors, config, and production-grade TypeScript backends.\norigin: ECC\n---\n\n# NestJS Development Patterns\n\nProduction-grade NestJS patterns for modular TypeScript backends.\n\n## When to Activate\n\n- Building NestJS APIs or services\n- Structuring modules, controllers, and providers\n- Adding DTO validation, guards, interceptors, or exception filters\n- Configuring environment-aware settings and database integrations\n- Testing NestJS units or HTTP endpoints\n\n## Project Structure\n\n```text\nsrc\u002F\n├── app.module.ts\n├── main.ts\n├── common\u002F\n│   ├── filters\u002F\n│   ├── guards\u002F\n│   ├── interceptors\u002F\n│   └── pipes\u002F\n├── config\u002F\n│   ├── configuration.ts\n│   └── validation.ts\n├── modules\u002F\n│   ├── auth\u002F\n│   │   ├── auth.controller.ts\n│   │   ├── auth.module.ts\n│   │   ├── auth.service.ts\n│   │   ├── dto\u002F\n│   │   ├── guards\u002F\n│   │   └── strategies\u002F\n│   └── users\u002F\n│       ├── dto\u002F\n│       ├── entities\u002F\n│       ├── users.controller.ts\n│       ├── users.module.ts\n│       └── users.service.ts\n└── prisma\u002F or database\u002F\n```\n\n- Keep domain code inside feature modules.\n- Put cross-cutting filters, decorators, guards, and interceptors in `common\u002F`.\n- Keep DTOs close to the module that owns them.\n\n## Bootstrap and Global Validation\n\n```ts\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule, { bufferLogs: true });\n\n  app.useGlobalPipes(\n    new ValidationPipe({\n      whitelist: true,\n      forbidNonWhitelisted: true,\n      transform: true,\n      transformOptions: { enableImplicitConversion: true },\n    }),\n  );\n\n  app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));\n  app.useGlobalFilters(new HttpExceptionFilter());\n\n  await app.listen(process.env.PORT ?? 3000);\n}\nbootstrap();\n```\n\n- Always enable `whitelist` and `forbidNonWhitelisted` on public APIs.\n- Prefer one global validation pipe instead of repeating validation config per route.\n\n## Modules, Controllers, and Providers\n\n```ts\n@Module({\n  controllers: [UsersController],\n  providers: [UsersService],\n  exports: [UsersService],\n})\nexport class UsersModule {}\n\n@Controller('users')\nexport class UsersController {\n  constructor(private readonly usersService: UsersService) {}\n\n  @Get(':id')\n  getById(@Param('id', ParseUUIDPipe) id: string) {\n    return this.usersService.getById(id);\n  }\n\n  @Post()\n  create(@Body() dto: CreateUserDto) {\n    return this.usersService.create(dto);\n  }\n}\n\n@Injectable()\nexport class UsersService {\n  constructor(private readonly usersRepo: UsersRepository) {}\n\n  async create(dto: CreateUserDto) {\n    return this.usersRepo.create(dto);\n  }\n}\n```\n\n- Controllers should stay thin: parse HTTP input, call a provider, return response DTOs.\n- Put business logic in injectable services, not controllers.\n- Export only the providers other modules genuinely need.\n\n## DTOs and Validation\n\n```ts\nexport class CreateUserDto {\n  @IsEmail()\n  email!: string;\n\n  @IsString()\n  @Length(2, 80)\n  name!: string;\n\n  @IsOptional()\n  @IsEnum(UserRole)\n  role?: UserRole;\n}\n```\n\n- Validate every request DTO with `class-validator`.\n- Use dedicated response DTOs or serializers instead of returning ORM entities directly.\n- Avoid leaking internal fields such as password hashes, tokens, or audit columns.\n\n## Auth, Guards, and Request Context\n\n```ts\n@UseGuards(JwtAuthGuard, RolesGuard)\n@Roles('admin')\n@Get('admin\u002Freport')\ngetAdminReport(@Req() req: AuthenticatedRequest) {\n  return this.reportService.getForUser(req.user.id);\n}\n```\n\n- Keep auth strategies and guards module-local unless they are truly shared.\n- Encode coarse access rules in guards, then do resource-specific authorization in services.\n- Prefer explicit request types for authenticated request objects.\n\n## Exception Filters and Error Shape\n\n```ts\n@Catch()\nexport class HttpExceptionFilter implements ExceptionFilter {\n  catch(exception: unknown, host: ArgumentsHost) {\n    const response = host.switchToHttp().getResponse\u003CResponse>();\n    const request = host.switchToHttp().getRequest\u003CRequest>();\n\n    if (exception instanceof HttpException) {\n      return response.status(exception.getStatus()).json({\n        path: request.url,\n        error: exception.getResponse(),\n      });\n    }\n\n    return response.status(500).json({\n      path: request.url,\n      error: 'Internal server error',\n    });\n  }\n}\n```\n\n- Keep one consistent error envelope across the API.\n- Throw framework exceptions for expected client errors; log and wrap unexpected failures centrally.\n\n## Config and Environment Validation\n\n```ts\nConfigModule.forRoot({\n  isGlobal: true,\n  load: [configuration],\n  validate: validateEnv,\n});\n```\n\n- Validate env at boot, not lazily at first request.\n- Keep config access behind typed helpers or config services.\n- Split dev\u002Fstaging\u002Fprod concerns in config factories instead of branching throughout feature code.\n\n## Persistence and Transactions\n\n- Keep repository \u002F ORM code behind providers that speak domain language.\n- For Prisma or TypeORM, isolate transactional workflows in services that own the unit of work.\n- Do not let controllers coordinate multi-step writes directly.\n\n## Testing\n\n```ts\ndescribe('UsersController', () => {\n  let app: INestApplication;\n\n  beforeAll(async () => {\n    const moduleRef = await Test.createTestingModule({\n      imports: [UsersModule],\n    }).compile();\n\n    app = moduleRef.createNestApplication();\n    app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));\n    await app.init();\n  });\n});\n```\n\n- Unit test providers in isolation with mocked dependencies.\n- Add request-level tests for guards, validation pipes, and exception filters.\n- Reuse the same global pipes\u002Ffilters in tests that you use in production.\n\n## Production Defaults\n\n- Enable structured logging and request correlation ids.\n- Terminate on invalid env\u002Fconfig instead of booting partially.\n- Prefer async provider initialization for DB\u002Fcache clients with explicit health checks.\n- Keep background jobs and event consumers in their own modules, not inside HTTP controllers.\n- Make rate limiting, auth, and audit logging explicit for public endpoints.\n","# NestJS Development Patterns\n\nProduction-grade NestJS patterns for modular TypeScript backends.\n\n## When to Activate\n\n- Building NestJS APIs or services\n- Structuring modules, controllers, and providers\n- Adding DTO validation, guards, interceptors, or exception filters\n- Configuring environment-aware settings and database integrations\n- Testing NestJS units or HTTP endpoints\n\n## Project Structure\n\n```text\nsrc\u002F\n├── app.module.ts\n├── main.ts\n├── common\u002F\n│   ├── filters\u002F\n│   ├── guards\u002F\n│   ├── interceptors\u002F\n│   └── pipes\u002F\n├── config\u002F\n│   ├── configuration.ts\n│   └── validation.ts\n├── modules\u002F\n│   ├── auth\u002F\n│   │   ├── auth.controller.ts\n│   │   ├── auth.module.ts\n│   │   ├── auth.service.ts\n│   │   ├── dto\u002F\n│   │   ├── guards\u002F\n│   │   └── strategies\u002F\n│   └── users\u002F\n│       ├── dto\u002F\n│       ├── entities\u002F\n│       ├── users.controller.ts\n│       ├── users.module.ts\n│       └── users.service.ts\n└── prisma\u002F or database\u002F\n```\n\n- Keep domain code inside feature modules.\n- Put cross-cutting filters, decorators, guards, and interceptors in `common\u002F`.\n- Keep DTOs close to the module that owns them.\n\n## Bootstrap and Global Validation\n\n```ts\nasync function bootstrap() {\n  const app = await NestFactory.create(AppModule, { bufferLogs: true });\n\n  app.useGlobalPipes(\n    new ValidationPipe({\n      whitelist: true,\n      forbidNonWhitelisted: true,\n      transform: true,\n      transformOptions: { enableImplicitConversion: true },\n    }),\n  );\n\n  app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));\n  app.useGlobalFilters(new HttpExceptionFilter());\n\n  await app.listen(process.env.PORT ?? 3000);\n}\nbootstrap();\n```\n\n- Always enable `whitelist` and `forbidNonWhitelisted` on public APIs.\n- Prefer one global validation pipe instead of repeating validation config per route.\n\n## Modules, Controllers, and Providers\n\n```ts\n@Module({\n  controllers: [UsersController],\n  providers: [UsersService],\n  exports: [UsersService],\n})\nexport class UsersModule {}\n\n@Controller('users')\nexport class UsersController {\n  constructor(private readonly usersService: UsersService) {}\n\n  @Get(':id')\n  getById(@Param('id', ParseUUIDPipe) id: string) {\n    return this.usersService.getById(id);\n  }\n\n  @Post()\n  create(@Body() dto: CreateUserDto) {\n    return this.usersService.create(dto);\n  }\n}\n\n@Injectable()\nexport class UsersService {\n  constructor(private readonly usersRepo: UsersRepository) {}\n\n  async create(dto: CreateUserDto) {\n    return this.usersRepo.create(dto);\n  }\n}\n```\n\n- Controllers should stay thin: parse HTTP input, call a provider, return response DTOs.\n- Put business logic in injectable services, not controllers.\n- Export only the providers other modules genuinely need.\n\n## DTOs and Validation\n\n```ts\nexport class CreateUserDto {\n  @IsEmail()\n  email!: string;\n\n  @IsString()\n  @Length(2, 80)\n  name!: string;\n\n  @IsOptional()\n  @IsEnum(UserRole)\n  role?: UserRole;\n}\n```\n\n- Validate every request DTO with `class-validator`.\n- Use dedicated response DTOs or serializers instead of returning ORM entities directly.\n- Avoid leaking internal fields such as password hashes, tokens, or audit columns.\n\n## Auth, Guards, and Request Context\n\n```ts\n@UseGuards(JwtAuthGuard, RolesGuard)\n@Roles('admin')\n@Get('admin\u002Freport')\ngetAdminReport(@Req() req: AuthenticatedRequest) {\n  return this.reportService.getForUser(req.user.id);\n}\n```\n\n- Keep auth strategies and guards module-local unless they are truly shared.\n- Encode coarse access rules in guards, then do resource-specific authorization in services.\n- Prefer explicit request types for authenticated request objects.\n\n## Exception Filters and Error Shape\n\n```ts\n@Catch()\nexport class HttpExceptionFilter implements ExceptionFilter {\n  catch(exception: unknown, host: ArgumentsHost) {\n    const response = host.switchToHttp().getResponse\u003CResponse>();\n    const request = host.switchToHttp().getRequest\u003CRequest>();\n\n    if (exception instanceof HttpException) {\n      return response.status(exception.getStatus()).json({\n        path: request.url,\n        error: exception.getResponse(),\n      });\n    }\n\n    return response.status(500).json({\n      path: request.url,\n      error: 'Internal server error',\n    });\n  }\n}\n```\n\n- Keep one consistent error envelope across the API.\n- Throw framework exceptions for expected client errors; log and wrap unexpected failures centrally.\n\n## Config and Environment Validation\n\n```ts\nConfigModule.forRoot({\n  isGlobal: true,\n  load: [configuration],\n  validate: validateEnv,\n});\n```\n\n- Validate env at boot, not lazily at first request.\n- Keep config access behind typed helpers or config services.\n- Split dev\u002Fstaging\u002Fprod concerns in config factories instead of branching throughout feature code.\n\n## Persistence and Transactions\n\n- Keep repository \u002F ORM code behind providers that speak domain language.\n- For Prisma or TypeORM, isolate transactional workflows in services that own the unit of work.\n- Do not let controllers coordinate multi-step writes directly.\n\n## Testing\n\n```ts\ndescribe('UsersController', () => {\n  let app: INestApplication;\n\n  beforeAll(async () => {\n    const moduleRef = await Test.createTestingModule({\n      imports: [UsersModule],\n    }).compile();\n\n    app = moduleRef.createNestApplication();\n    app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));\n    await app.init();\n  });\n});\n```\n\n- Unit test providers in isolation with mocked dependencies.\n- Add request-level tests for guards, validation pipes, and exception filters.\n- Reuse the same global pipes\u002Ffilters in tests that you use in production.\n\n## Production Defaults\n\n- Enable structured logging and request correlation ids.\n- Terminate on invalid env\u002Fconfig instead of booting partially.\n- Prefer async provider initialization for DB\u002Fcache clients with explicit health checks.\n- Keep background jobs and event consumers in their own modules, not inside HTTP controllers.\n- Make rate limiting, auth, and audit logging explicit for public endpoints.\n",{"name":5,"origin":23,"description":7},"ECC","main","f37de8f681f0c0ca0e0ebab6e5fddf764ca7553d","skills\u002Fnestjs-patterns",1,"https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one","https:\u002F\u002Fagisota.github.io\u002Fold-one\u002F","https:\u002F\u002Fgithub.com\u002Fagisota","pzd.world","2026-07-04 22:32:06",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add agisota\u002Fold-one --skill nestjs-patterns",{"tool":39,"command":40},"bunx","bunx skills add agisota\u002Fold-one --skill nestjs-patterns",{"tool":42,"command":43},"pnpm","pnpm dlx skills add agisota\u002Fold-one --skill nestjs-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fnestjs-patterns\u002FSKILL.md",true,[],[48,55,62,71,78,85],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":18},"01M75KRGZWQWE9JDBS6RX42NWV","zoom-out","Tell the agent to zoom out and give broader context or a higher-level perspective. Use when you're unfamiliar with a section of code or need to understand how it fits into the bigger picture.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzoom-out\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M75KRCZHKE0ZYAQFFYHS0YNP","zeroize-audit","Detects missing zeroization of sensitive data in source code and identifies zeroization removed by compiler optimizations, with assembly-level analysis, and control-flow verification. Use for auditing C\u002FC++\u002FRust code handling secrets, keys, passwords, or other sensitive data.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fzeroize-audit\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":66,"licenseFileUrl":67,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":18},"01M75KR94KYQ30DTE1P9WNDAE0","yeet","Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyeet\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":18},"01M75KR3H13YJ9QHMD49818FA1","yara-rule-authoring","Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fyara-rule-authoring\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M75KQMPY8A4Y8XTDD2DT0M9T","x-twitter-growth","X\u002FTwitter growth engine for building audience, crafting viral content, and analyzing engagement. Use when the user wants to grow on X\u002FTwitter, write tweets or threads, analyze their X profile, research competitors on X, plan a posting strategy, or optimize engagement. Complements social-content (generic multi-platform) with X-specific depth: algorithm mechanics, thread engineering, reply strategy, profile optimization, and competitive intelligence via web search.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-twitter-growth\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M75KQHNZ0ANZNJGZY6M8MDAK","x-api","X\u002FTwitter API integration for posting tweets, threads, reading timelines, search, and analytics. Covers OAuth auth patterns, rate limits, and platform-native content posting. Use when the user wants to interact with X programmatically.","https:\u002F\u002Fgithub.com\u002Fagisota\u002Fold-one\u002Fblob\u002Fmain\u002Fskills\u002Fx-api\u002FSKILL.md",[],[]]