Agent skill

Nestjs Patterns

by affaan-m in affaan-m/ECC

NestJS 架构模式,涵盖模块、控制器、提供者、DTO 验证、守卫、拦截器、配置以及生产级 TypeScript 后端。

MITAuto-check passedBackend & APIs

Install Nestjs Patterns

skills CLI
$ npx skills add affaan-m/ECC --skill nestjs-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install affaan-m/ECC nestjs-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs/zh-CN/skills/nestjs-patterns .claude/skills/nestjs-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
nestjs-patterns
GitHub stars
276k
Token cost
~1.1k tokens
SKILL.md length
91 words
Files
1
Skills in repo
683
Repo updated
First seen
Licence
MIT

At a glance

NestJS 架构模式,涵盖模块、控制器、提供者、DTO 验证、守卫、拦截器、配置以及生产级 TypeScript 后端。

  • Backend & APIs work in your project
  • SKILL.md covers 何时启用, 项目结构, 启动与全局验证 and 模块、控制器和提供者, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Nestjs Patterns is an agent skill from affaan-m/ECC. NestJS 架构模式,涵盖模块、控制器、提供者、DTO 验证、守卫、拦截器、配置以及生产级 TypeScript 后端。

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Backend & APIs. It works with NestJS and TypeScript. The repository describes itself as: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. The licence is MIT.

When your agent uses it

  • Backend & APIs work in your project

Example prompts

  • “Use the nestjs-patterns skill to nestj 架构模式,涵盖模块、控制器、提供者、DTO 验证、守卫、拦截器、配置以及生产级 TypeScript 后端”
  • “/nestjs-patterns”

What it can do on your machine

Read from SKILL.md and the folder at commit 4eb71d9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Nestjs Patterns loads about 1.1k tokens when it runs. Until then it costs about 19 tokens; SKILL.md has 91 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~19
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from affaan-m/ECC at commit 4eb71d9, republished under its MIT licence (© affaan-m). 91 words, ~1,102 tokens.

Download SKILL.mdSave it as .claude/skills/nestjs-patterns/SKILL.md (or your agent's skills folder).
name
nestjs-patterns
description
NestJS 架构模式,涵盖模块、控制器、提供者、DTO 验证、守卫、拦截器、配置以及生产级 TypeScript 后端。
origin
ECC

NestJS 开发模式

适用于模块化 TypeScript 后端的生产级 NestJS 模式。

何时启用

  • 构建 NestJS API 或服务时
  • 组织模块、控制器和提供者时
  • 添加 DTO 验证、守卫、拦截器或异常过滤器时
  • 配置环境感知设置和数据库集成时
  • 测试 NestJS 单元或 HTTP 端点时

项目结构

text
src/
├── 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/ 中。
  • 将 DTO 保留在所属模块附近。

启动与全局验证

ts
async 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();
  • 始终在公共 API 上启用 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);
  }
}
  • 控制器应保持精简:解析 HTTP 输入、调用提供者、返回响应 DTO。
  • 将业务逻辑放在可注入的服务中,而不是控制器中。
  • 仅导出其他模块真正需要的提供者。

DTO 与验证

ts
export class CreateUserDto {
  @IsEmail()
  email!: string;

  @IsString()
  @Length(2, 80)
  name!: string;

  @IsOptional()
  @IsEnum(UserRole)
  role?: UserRole;
}
  • 使用 class-validator 验证每个请求 DTO。
  • 使用专用的响应 DTO 或序列化器,而不是直接返回 ORM 实体。
  • 避免泄露内部字段,如密码哈希、令牌或审计列。

认证、守卫与请求上下文

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',
    });
  }
}
  • 在整个 API 中保持一致的错误封装格式。
  • 对预期的客户端错误抛出框架异常;集中记录并包装意外的失败。

配置与环境验证

ts
ConfigModule.forRoot({
  isGlobal: true,
  load: [configuration],
  validate: validateEnv,
});
  • 在启动时验证环境变量,而不是在首次请求时惰性验证。
  • 将配置访问限制在类型化辅助函数或配置服务之后。
  • 在配置工厂中拆分开发/预发布/生产关注点,而不是在功能代码中到处分支。

持久化与事务

  • 将仓库/ORM 代码保留在提供者之后,这些提供者使用领域语言进行通信。
  • 对于 Prisma 或 TypeORM,将事务工作流隔离在拥有工作单元的服务中。
  • 不要让控制器直接协调多步写入操作。

测试

ts
describe('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();
  });
});
  • 使用模拟依赖项对提供者进行单元测试。
  • 为守卫、验证管道和异常过滤器添加请求级测试。
  • 在测试中复用与生产环境相同的全局管道/过滤器。

生产默认设置

  • 启用结构化日志和请求关联 ID。
  • 在环境/配置无效时终止,而不是部分启动。
  • 优先使用异步提供者初始化数据库/缓存客户端,并附带显式健康检查。
  • 将后台任务和事件消费者放在自己的模块中,而不是 HTTP 控制器内。
  • 对公共端点明确启用速率限制、认证和审计日志。

© affaan-m, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in docs/zh-CN/skills/nestjs-patterns of affaan-m/ECC.

Open the folder on GitHubat commit 4eb71d9

Compare with similar skills

Nestjs Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Nestjs Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Nestjs Patterns this skillaffaan-m/ECC276k—~1.1kAutomated safety check: PassMIT
Twenty Syncable Entity Validationtwentyhq/twenty58k—~3.3kAutomated safety check: PassCustom licence
Twenty Syncable Entity Wiringtwentyhq/twenty58k—~2.9kAutomated safety check: PassCustom licence
Twenty Entity Runner Actionstwentyhq/twenty58k—~3.1kAutomated safety check: PassCustom licence
Projectsamchon/nestia2.2k—~3kAutomated safety check: PassMIT
NestJS ExpertJeffallan/claude-skills12k—~2kAutomated safety check: PassMIT

Similar skills

  • Contributor guide for step three of adding a syncable entity to the Twenty server: write the validator, the migration action builder and the orchestrator wiring.

    58k GitHub stars~3.3k tokensUpdated today
    Backend & APIsAuto-check passed
  • Registers a new syncable entity in three NestJS modules and adds its service and GraphQL resolver layers when contributing to the Twenty server.

    58k GitHub stars~2.9k tokensUpdated today
    Backend & APIsAuto-check passed
  • Step four of adding a syncable entity in the Twenty server: write create, update and delete action handlers that run workspace migrations against the database.

    58k GitHub stars~3.1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Project

    samchon/nestia

    Defines the nestia product contract, workspace layout, package boundaries, the Go plugin composition model, and canonical commands.

    2.2k GitHub stars~3k tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • NestJS Expert

    Jeffallan/claude-skills

    Scaffolds NestJS modules, controllers, services, DTOs and guards for TypeScript backends, with validation, JWT and Passport auth, Swagger docs and unit and E2E tests.

    12k GitHub stars~2k tokensUpdated 6 days ago
    Backend & APIsAuto-check passed
  • Fishjam JS Server SDK

    software-mansion-labs/skills

    Node.js / TypeScript server SDK for Fishjam — backends that create rooms, mint peer tokens, listen to server notifications, and run agents.

    291 GitHub stars~1.4k tokensUpdated 12 days ago
    Backend & APIsAuto-check passed

More from affaan-m/ECC

All 683 skills in this repo
  • Skill Stocktake

    affaan-m/ECC

    Audits your installed Claude skills and commands for quality, with a quick mode for recently changed skills and a full mode that evaluates all of them through subagents.

    276k GitHub starsUsed in 5 repos~3.1k tokens
    Auto-check passed
  • Ingests, indexes, searches, edits and monitors video, audio and live streams through the VideoDB Python SDK, returning stream links, clips and timestamps.

    276k GitHub starsUsed in 3 repos~3.5k tokens
    Auto-check: notes
  • Docs Governance

    affaan-m/ECC

    Route broad documentation-governance requests to existing ECC skills and run an opt-in, read-only audit of mapped documentation roles, links, ADR indexes, and evidence references.

    276k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Rules Distillation

    affaan-m/ECC

    Scans installed skills for principles that recur across them and proposes rule-file changes: append, revise, add a section, create a file or leave as covered.

    276k GitHub starsUsed in 2 repos~2.3k tokens
    Auto-check passed
  • Builds DRAFT counterparty agreements from one markdown template and a small JSON spec per party, with clauses picked by the party's role.

    276k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Measures whether agents actually follow a skill, rule or agent definition by generating scenarios at three strictness levels and scoring tool-call traces.

    276k GitHub starsUsed in 1 repo~623 tokens
    Auto-check passed

Categories

Questions about Nestjs Patterns

What does Nestjs Patterns do?

NestJS 架构模式,涵盖模块、控制器、提供者、DTO 验证、守卫、拦截器、配置以及生产级 TypeScript 后端。. Nestjs Patterns is an agent skill from affaan-m/ECC.

When should I use Nestjs Patterns?

Nestjs Patterns fits situations like: backend & APIs work in your project.

How do I install Nestjs Patterns in Claude Code?

Run `npx skills add affaan-m/ECC --skill nestjs-patterns -a claude-code`. Or copy the skill folder (docs/zh-CN/skills/nestjs-patterns in affaan-m/ECC) into .claude/skills/nestjs-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Nestjs Patterns in Codex?

Run `npx skills add affaan-m/ECC --skill nestjs-patterns -a codex`. Or copy the skill folder (docs/zh-CN/skills/nestjs-patterns in affaan-m/ECC) into .agents/skills/nestjs-patterns in your project. Codex loads it when a task matches its description.

Can I use Nestjs Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add affaan-m/ECC --skill nestjs-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/nestjs-patterns, .gemini/skills/nestjs-patterns, .github/skills/nestjs-patterns and .opencode/skills/nestjs-patterns in your project.

What does Nestjs Patterns need to run?

SKILL.md names no scripts, command-line tools or credentials: Nestjs Patterns is instructions for the agent only.

Does Nestjs Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Nestjs Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Nestjs Patterns use?

Nestjs Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Nestjs Patterns use?

About 1.1k tokens (SKILL.md is roughly 4.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Nestjs Patterns?

Skills that share tags, products or a category with Nestjs Patterns: Twenty Syncable Entity Validation (twentyhq/twenty, 58k stars), Twenty Syncable Entity Wiring (twentyhq/twenty, 58k stars), Twenty Entity Runner Actions (twentyhq/twenty, 58k stars) and Project (samchon/nestia, 2.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Nestjs Patterns?

affaan-m (a GitHub user) maintains it in affaan-m/ECC, which has 276,111 GitHub stars. The repository holds 683 skills in this directory. The repository was last updated on October 10, 2026.

Source: affaan-m/ECC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.