本文へ移動
cccskills
無料GitHub で公開

nestjs-best-practices

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.

インストール方法を見る

含まれるファイル(44)

  • SKILL.md6.0 KB
  • references/upstream.md1.5 KB
  • rules/_sections.md2.1 KB
  • rules/_template.md633 B
  • rules/api-use-dto-serialization.md4.3 KB
  • rules/api-use-interceptors.md5.4 KB
  • rules/api-use-pipes.md5.3 KB
  • rules/api-versioning.md4.9 KB
  • rules/arch-avoid-circular-deps.md2.0 KB
  • rules/arch-feature-modules.md2.3 KB
  • rules/arch-module-sharing.md3.8 KB
  • rules/arch-single-responsibility.md2.9 KB
  • rules/arch-use-events.md3.0 KB
  • rules/arch-use-repository-pattern.md2.8 KB
  • rules/db-avoid-n-plus-one.md3.8 KB
  • rules/db-use-migrations.md3.8 KB
  • rules/db-use-transactions.md4.0 KB
  • rules/devops-graceful-shutdown.md5.8 KB
  • rules/devops-use-config-module.md4.5 KB
  • rules/devops-use-logging.md5.6 KB
  • rules/di-avoid-service-locator.md2.9 KB
  • rules/di-interface-segregation.md5.1 KB
  • rules/di-liskov-substitution.md7.1 KB
  • rules/di-prefer-constructor-injection.md2.3 KB
  • rules/di-scope-awareness.md2.6 KB
  • rules/di-use-interfaces-tokens.md2.5 KB
  • rules/error-handle-async-errors.md3.4 KB
  • rules/error-throw-http-exceptions.md3.1 KB
  • rules/error-use-exception-filters.md3.6 KB
  • rules/micro-use-health-checks.md5.8 KB
  • rules/micro-use-patterns.md5.0 KB
  • rules/micro-use-queues.md6.1 KB
  • rules/perf-async-hooks.md2.8 KB
  • rules/perf-lazy-loading.md3.7 KB
  • rules/perf-optimize-database.md3.2 KB
  • rules/perf-use-caching.md3.4 KB
  • rules/security-auth-jwt.md4.3 KB
  • rules/security-rate-limiting.md3.5 KB
  • rules/security-sanitize-output.md3.7 KB
  • rules/security-use-guards.md3.6 KB
  • rules/security-validate-all-input.md3.3 KB
  • rules/test-e2e-supertest.md4.7 KB
  • rules/test-mock-external-services.md4.5 KB
  • rules/test-use-testing-module.md4.3 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

NestJS Best Practices

<!-- CORE-OVERLAY-START -->

This repository (Asymmetric-al/core)

These repo-owned sections are intentionally kept on top of the vendored NestJS skill. If upstream refreshes replace this file, reconcile this overlay before running bun run skills:sync. Core is a Bun + Next.js monorepo, not a NestJS application. Do not introduce NestJS modules, controllers, TypeORM, or a Nest runtime into this repository.

Triggers

  • Reviewing NestJS patterns in third-party or vendored NestJS code.
  • Explicit NestJS architecture, DI, or security questions.

Workflow

  1. Confirm the files under edit are actually NestJS, not Core Next.js / packages/api.
  2. Prefer docs/ai/rules/backend.md and the data-access boundary for product work.
  3. Use this skill only as NestJS reference; do not restyle Core around NestJS examples.

Checklist

  • Confirmed the task is NestJS reference, not a Core stack change.
  • Did not add NestJS, TypeORM, or Nest modules to this monorepo.
  • Kept tenant, auth, and data-access rules authoritative for product code.
<!-- CORE-OVERLAY-END -->

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

PriorityCategoryImpactPrefix
1ArchitectureCRITICALarch-
2Dependency InjectionCRITICALdi-
3Error HandlingHIGHerror-
4SecurityHIGHsecurity-
5PerformanceHIGHperf-
6TestingMEDIUM-HIGHtest-
7Database & ORMMEDIUM-HIGHdb-
8API DesignMEDIUMapi-
9MicroservicesMEDIUMmicro-
10DevOps & DeploymentLOW-MEDIUMdevops-

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.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Audit and fix accessibility in Core UI. Use when changing or reviewing buttons, links, forms, validation, dialogs, menus, tabs, tables, keyboard interactions, focus management, accessible names, announcements, contrast, touch targets, reduced motion, or WCAG/a11y behavior.

日本語の概要は準備中です。原文の説明を表示しています。

Asymmetric-al/core3812026年10月12日 更新

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

日本語の概要は準備中です。原文の説明を表示しています。

Asymmetric-al/core3812026年10月12日 更新

Use when building any system where email content triggers actions — AI agent inboxes, automated support handlers, email-to-task pipelines, or any workflow processing untrusted inbound email. Always use this skill when the user wants to receive emails and act on them programmatically, even if they don't mention "agent" — the skill contains critical security patterns (sender allowlists, content filtering, sandboxed processing) that prevent untrusted email from controlling your system.

日本語の概要は準備中です。原文の説明を表示しています。

Asymmetric-al/core3812026年10月12日 更新

anim

無料

Tasteful, subtle web UI animation following Emil Kowalski / animations.dev principles. Use when adding or reviewing interface motion — hover and press feedback, entrances and exits, modals, toasts, menus, loading and skeleton states, staggered reveals, page or view transitions — so motion stays refined and purposeful, not decorative. Covers CSS, Web Animations, and React timing/easing. Pair with the motion skill for motion/react API specifics.

日本語の概要は準備中です。原文の説明を表示しています。

Asymmetric-al/core3812026年10月12日 更新

animate

無料

Build an animation from scratch, making the decisions in the order that determines whether it feels right — should it animate at all, what purpose, which tool, which properties, which curve and duration, how it interrupts, how it exits. Writes the implementation. Use when asked to animate something, add motion, make a component feel alive, or build a transition. For critiquing existing motion use review-animations; for auditing a whole codebase use improve-animations. Only runs when explicitly invoked; it does not trigger on its own.

日本語の概要は準備中です。原文の説明を表示しています。

Asymmetric-al/core3812026年10月12日 更新

Build animations for Expo and React Native only, using Reanimated, Gesture Handler, Expo Router, and expo-haptics. Use when the target runtime is an Expo or React Native app. Do not use it for Core Next.js web motion; use `animate` for web. Only runs when explicitly invoked; it does not trigger on its own.

日本語の概要は準備中です。原文の説明を表示しています。

Asymmetric-al/core3812026年10月12日 更新

Asymmetric-al のスキルをすべて見る

このスキルの問題を報告する