nestjs-cqrs-setup

Automate CQRS installation and configuration in NestJS applications.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/cromesdk/ai-skills --skill nestjs-cqrs-setup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nestjs-cqrs-setup
Source: https://github.com/cromesdk/ai-skills/tree/main/skills/nestjs/nestjs-cqrs-setup
Command: npx skills add https://github.com/cromesdk/ai-skills --skill nestjs-cqrs-setup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill automates the setup and verification of CQRS (Command Query Responsibility Segregation) in NestJS applications, ensuring modules are correctly wired and conditionally loaded based on environment variables.

Core Features & Use Cases

  • CQRS Installation: Installs @nestjs/cqrs and @nestjs/config dependencies.
  • Environment Gating: Configures CQRS_ENABLED in .env to conditionally load CQRS modules and dependent features.
  • Module Wiring: Correctly wires ConfigModule and CqrsModule using ConditionalModule.registerWhen.
  • Handler Setup: Guides the setup of command, query, and event handlers.
  • Verification: Verifies successful application startup and functional execution of CQRS flows in both enabled and disabled states.
  • Use Case: When starting a new NestJS project or refactoring an existing one, use this Skill to integrate CQRS robustly, ensuring it can be easily enabled or disabled for different environments without causing DI failures.

Quick Start

Use the nestjs-cqrs-setup skill to install and configure CQRS in your NestJS project.

Frequently Asked Questions about nestjs-cqrs-setup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up CQRS in a NestJS application without dependency injection failures?

To set up NestJS CQRS without DI failures, use `ConditionalModule.registerWhen` to gate CqrsModule loading via the `CQRS_ENABLED` environment variable, ensuring modules only wire when explicitly enabled in `.env`.

What is the best way to conditionally load CQRS modules in NestJS based on environment variables?

The best way to conditionally load NestJS CQRS modules is using `ConditionalModule.registerWhen` combined with `@nestjs/config` and a `CQRS_ENABLED` environment variable to safely toggle module wiring per environment.

How do I install and wire command, query, and event buses with NestJS CQRS?

Installing and wiring NestJS CQRS buses requires adding `@nestjs/cqrs` and `@nestjs/config` dependencies, then configuring CqrsModule to register command, query, and event handlers within your module structure.

Can I disable CQRS in certain NestJS environments without breaking the application startup?

Yes, you can disable CQRS in specific NestJS environments by setting `CQRS_ENABLED` to false, which prevents CqrsModule from loading via ConditionalModule and avoids dependency injection failures during startup.

Does NestJS CQRS support verification for both enabled and disabled module states?

NestJS CQRS setup supports verification for both enabled and disabled states by checking application startup success and functional execution of CQRS flows when `CQRS_ENABLED` is toggled in the environment configuration.