본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)12k · #11520

nestjs-best-practices

하는 일

AI에게 우선순위가 정해진 NestJS 모범 사례를 제공해 서버 애플리케이션을 만들고 검토하게 합니다. 실서비스용 NestJS 백엔드를 개발하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓새 NestJS 모듈, 컨트롤러 또는 서비스를 작성할 때.
  • ✓NestJS 코드베이스를 아키텍처나 보안 문제 관점에서 검토하거나 리팩터링할 때.
  • ✓NestJS의 데이터베이스 접근이나 성능을 개선해야 할 때.

스킬 링크

https://github.com/trycompai/crm/blob/release/.agents/skills/nestjs-best-practices/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/trycompai/crm/blob/release/.agents/skills/nestjs-best-practices/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 NestJS 모듈 구조를 검토하고, 순환 의존성이나 보안 문제가 있으면 알려 주실 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI가 영향이 큰 순서대로 규칙을 적용합니다. 아키텍처와 의존성 주입을 먼저 확인하고, 그다음 오류 처리, 보안, 성능을 살핍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

NestJS Best Practices

Comprehensive best practices guide for NestJS applications. Contains 40 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new NestJS modules, controllers, or services
  • Implementing authentication and authorization
  • Reviewing code for architecture and security issues
  • Refactoring existing NestJS codebases
  • Optimizing performance or database queries
  • Building microservices architectures

Rule Categories by Priority

Priority Category Impact Prefix
1 Architecture CRITICAL arch-
2 Dependency Injection CRITICAL di-
3 Error Handling HIGH error-
4 Security HIGH security-
5 Performance HIGH perf-
6 Testing MEDIUM-HIGH test-
7 Database & ORM MEDIUM-HIGH db-
8 API Design MEDIUM api-
9 Microservices MEDIUM micro-
10 DevOps & Deployment LOW-MEDIUM devops-

Quick Reference

1. Architecture (CRITICAL)

  • arch-avoid-circular-deps - Avoid circular module dependencies
  • arch-feature-modules - Organize by feature, not technical layer
  • arch-module-sharing - Proper module exports/imports, avoid duplicate providers
  • arch-single-responsibility - Focused services over "god services"
  • arch-use-repository-pattern - Abstract database logic for testability
  • arch-use-events - Event-driven architecture for decoupling

2. Dependency Injection (CRITICAL)

  • di-avoid-service-locator - Avoid service locator anti-pattern
  • di-interface-segregation - Interface Segregation Principle (ISP)
  • di-liskov-substitution - Liskov Substitution Principle (LSP)
  • di-prefer-constructor-injection - Constructor over property injection
  • di-scope-awareness - Understand singleton/request/transient scopes
  • di-use-interfaces-tokens - Use injection tokens for interfaces

3. Error Handling (HIGH)

  • error-use-exception-filters - Centralized exception handling
  • error-throw-http-exceptions - Use NestJS HTTP exceptions
  • error-handle-async-errors - Handle async errors properly

4. Security (HIGH)

  • security-auth-jwt - Secure JWT authentication
  • security-validate-all-input - Validate with class-validator
  • security-use-guards - Authentication and authorization guards
  • security-sanitize-output - Prevent XSS attacks
  • security-rate-limiting - Implement rate limiting

5. Performance (HIGH)

  • perf-async-hooks - Proper async lifecycle hooks
  • perf-use-caching - Implement caching strategies
  • perf-optimize-database - Optimize database queries
  • perf-lazy-loading - Lazy load modules for faster startup

6. Testing (MEDIUM-HIGH)

  • test-use-testing-module - Use NestJS testing utilities
  • test-e2e-supertest - E2E testing with Supertest
  • test-mock-external-services - Mock external dependencies

7. Database & ORM (MEDIUM-HIGH)

  • db-use-transactions - Transaction management
  • db-avoid-n-plus-one - Avoid N+1 query problems
  • db-use-migrations - Use migrations for schema changes

8. API Design (MEDIUM)

  • api-use-dto-serialization - DTO and response serialization
  • api-use-interceptors - Cross-cutting concerns
  • api-versioning - API versioning strategies
  • api-use-pipes - Input transformation with pipes

9. Microservices (MEDIUM)

  • micro-use-patterns - Message and event patterns
  • micro-use-health-checks - Health checks for orchestration
  • micro-use-queues - Background job processing

10. DevOps & Deployment (LOW-MEDIUM)

  • devops-use-config-module - Environment configuration
  • devops-use-logging - Structured logging
  • devops-graceful-shutdown - Zero-downtime deployments

How to Use

Read individual rule files for detailed explanations and code examples:

rules/arch-avoid-circular-deps.md
rules/security-validate-all-input.md
rules/_sections.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Full Compiled Document

For the complete guide with all rules expanded in a single document, see AGENTS.md in the repository.

자주 묻는 질문

규칙이 몇 개인가요?

10개 범주에 걸쳐 40개 규칙이 있으며, 영향이 큰 순서로 정리되어 있습니다.

어느 영역이 가장 중요한가요?

아키텍처와 의존성 주입이 영향이 가장 큰 범주로 꼽힙니다.

테스트와 배포도 다루나요?

네, 테스트, 데이터베이스 접근, API 설계, 마이크로서비스, DevOps 범주가 포함되어 있습니다.

상세 정보

작성자의 원본 설명

NestJS best practices and architecture patterns for building production-ready applications. This skill should be used when writing, reviewing, or refactoring NestJS code to ensure proper patterns for modules, dependency injection, security, and performance.

repo: trycompai/crm

인기도

GitHub 스타
12k
순위
#11520
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬