mbc-net/mbc-cqrs-serverless/mbc-generate

Claude Code and agent skill by mbc-net/mbc-cqrs-serverless

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Generate MBC CQRS Serverless boilerplate code. Use this when the user wants to create a new module, service, controller, command, query, event handler, or data sync handler for MBC CQRS Serverless framework.

Install

npx vskill@latest install mbc-net/mbc-cqrs-serverless/mbc-generate

SKILL.md

Pre-flight Check (Version Update)

Before executing this skill, check for updates:

  1. Run mbc install-skills --check to check if a newer version is available
  2. If the output shows "Update available: X.Y.Z → A.B.C", ask the user:
  • "A newer version of MBC skills is available (X.Y.Z → A.B.C). Would you like to update before proceeding?"
  1. If the user agrees, run mbc install-skills --force to update
  2. If the user declines or skills are up-to-date, proceed with the skill

Note: Skip this check if the user explicitly says to skip updates or if you've already checked in this session.


MBC CQRS Serverless Code Generator

This skill generates boilerplate code following MBC CQRS Serverless best practices.

Usage

When the user requests code generation, follow these patterns:

Module Generation

When user says: "create a module for [Entity]" or "generate [Entity] module"

Generate the following files:

1. Module File ([entity].module.ts)
typescript
import { Module } from '@nestjs/common';
import { CommandModule } from '@mbc-cqrs-serverless/core';
import { [Entity]Controller } from './[entity].controller';
import { [Entity]Service } from './[entity].service';
import { [Entity]DataSyncRdsHandler } from './handler/[entity]-rds.handler';
@Module({
imports: [
CommandModule.register({
tableName: '[entity]',
dataSyncHandlers: [[Entity]DataSyncRdsHandler],
}),
],
controllers: [[Entity]Controller],
providers: [[Entity]Service],
exports: [[Entity]Service],
})
export class [Entity]Module {}
2. Controller File ([entity].controller.ts)
typescript
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
Query,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { [Entity]Service } from './[entity].service';
import { Create[Entity]Dto } from './dto/create-[entity].dto';
import { Update[Entity]Dto } from './dto/update-[entity].dto';
import { Search[Entity]Dto } from './dto/search-[entity].dto';
import { INVOKE_CONTEXT, IInvoke } from '@mbc-cqrs-serverless/core';
@ApiTags('[entity]')
@Controller('[entity]')
export class [Entity]Controller {
constructor(private readonly [entity]Service: [Entity]Service) {}
@Post()
async create(
@INVOKE_CONTEXT() invokeContext: IInvoke,
@Body() dto: Create[Entity]Dto,
) {
return this.[entity]Service.create(dto, invokeContext);
}
@Get()
async search(
@INVOKE_CONTEXT() invokeContext: IInvoke,
@Query() dto: Search[Entity]Dto,
) {
return this.[entity]Service.search(dto, invokeContext);
}
@Get(':pk/:sk')
async findOne(
@INVOKE_CONTEXT() invokeContext: IInvoke,
@Param('pk') pk: string,
@Param('sk') sk: string,
) {
return this.[entity]Service.findOne({ pk, sk }, invokeContext);
}
@Put(':pk/:sk')
async update(
@INVOKE_CONTEXT() invokeContext: IInvoke,
@Param('pk') pk: string,
@Param('sk') sk: string,
@Body() dto: Update[Entity]Dto,
) {
return this.[entity]Service.update({ pk, sk }, dto, invokeContext);
}
@Delete(':pk/:sk')
async remove(
@INVOKE_CONTEXT() invokeContext: IInvoke,
@Param('pk') pk: string,
@Param('sk') sk: string,
) {
return this.[entity]Service.remove({ pk, sk }, invokeContext);
}
}
3. Service File ([entity].service.ts)
typescript
import { Injectable } from '@nestjs/common';
import { basename } from 'path';
import {
CommandService,
DataService,
DetailKey,
generateId,
getCommandSource,
getUserContext,
IInvoke,
VERSION_FIRST,
} from '@mbc-cqrs-serverless/core';
import { Create[Entity]Dto } from './dto/create-[entity].dto';
import { Update[Entity]Dto } from './dto/update-[entity].dto';
import { Search[Entity]Dto } from './dto/search-[entity].dto';
import { [Entity]CommandDto } from './dto/[entity]-command.dto';
@Injectable()
export class [Entity]Service {
constructor(
private readonly commandService: CommandService,
private readonly dataService: DataService,
) {}
async create(dto: Create[Entity]Dto, invokeContext: IInvoke) {
const { tenantCode } = getUserContext(invokeContext);
const pk = `[ENTITY]#${tenantCode}`;
const sk = `[ENTITY]#${dto.code}`;
const command = new [Entity]CommandDto({
pk,
sk,
id: generateId(pk, sk),
tenantCode,
code: dto.code,
name: dto.name,
type: '[ENTITY]',
version: VERSION_FIRST,
attributes: dto.attributes,
});
const commandSource = getCommandSource(
basename(__dirname),
this.constructor.name,
'create',
);
return this.commandService.publishAsync(command, {
source: commandSource,
invokeContext,
});
}
async search(dto: Search[Entity]Dto, invokeContext: IInvoke) {
const { tenantCode } = getUserContext(invokeContext);
return this.dataService.listByPk({
pk: `[ENTITY]#${tenantCode}`,
limit: dto.limit,
cursor: dto.cursor,
});
}
async findOne(key: DetailKey, invokeContext: IInvoke) {
return this.dataService.getItem(key);
}
async update(key: DetailKey, dto: Update[Entity]Dto, invokeContext: IInvoke) {
const existingItem = await this.dataService.getItem(key);
const commandSource = getCommandSource(
basename(__dirname),
this.constructor.name,
'update',
);
return this.commandService.publishPartialUpdateAsync(
{
pk: key.pk,
sk: key.sk,
version: existingItem.version,
name: dto.name,
attributes: { ...existingItem.attributes, ...dto.attributes },
},
{
source: commandSource,
invokeContext,
},
);
}
async remove(key: DetailKey, invokeContext: IInvoke) {
const existingItem = await this.dataService.getItem(key);
const commandSource = getCommandSource(
basename(__dirname),
this.constructor.name,
'remove',
);
return this.commandService.publishPartialUpdateAsync(
{
pk: key.pk,
sk: key.sk,
version: existingItem.version,
isDeleted: true,
},
{
source: commandSource,
invokeContext,
},
);
}
}
4. DTOs (dto/ directory)

create-[entity].dto.ts:

typescript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';
export class Create[Entity]Dto {
@ApiProperty({ description: 'Unique code for the [entity]' })
@IsString()
@IsNotEmpty()
code: string;
@ApiProperty({ description: 'Name of the [entity]' })
@IsString()
@IsNotEmpty()
name: string;
@ApiPropertyOptional({ description: 'Additional attributes' })
@IsObject()
@IsOptional()
attributes?: Record<string, any>;
}

update-[entity].dto.ts:

typescript
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsObject, IsOptional, IsString } from 'class-validator';
export class Update[Entity]Dto {
@ApiPropertyOptional({ description: 'Name of the [entity]' })
@IsString()
@IsOptional()
name?: string;
@ApiPropertyOptional({ description: 'Additional attributes' })
@IsObject()
@IsOptional()
attributes?: Record<string, any>;
}

search-[entity].dto.ts:

typescript
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsNumber, IsOptional, IsString } from 'class-validator';
import { Type } from 'class-transformer';
export class Search[Entity]Dto {
@ApiPropertyOptional({ description: 'Maximum number of items to return' })
@IsNumber()
@IsOptional()
@Type(() => Number)
limit?: number;
@ApiPropertyOptional({ description: 'Cursor for pagination' })
@IsString()
@IsOptional()
cursor?: string;
}

[entity]-command.dto.ts:

typescript
import { CommandDto } from '@mbc-cqrs-serverless/core';
export class [Entity]CommandDto extends CommandDto {
constructor(partial: Partial<[Entity]CommandDto>) {
super();
Object.assign(this, partial);
}
}
5. Data Sync Handler (handler/[entity]-rds.handler.ts)
typescript
import { DataSyncHandler, IDataSyncHandler } from '@mbc-cqrs-serverless/core';
import { CommandModel, DataModel } from '@mbc-cqrs-serverless/core';
import { PrismaService } from '../../prisma/prisma.service';
@DataSyncHandler({ type: '[ENTITY]' })
export class [Entity]DataSyncRdsHandler implements IDataSyncHandler {
constructor(private readonly prismaService: PrismaService) {}
async up(cmd: CommandModel, data: DataModel): Promise<void> {
if (data.isDeleted) {
await this.prismaService.[entity].delete({
where: { id: data.id },
});
return;
}
await this.prismaService.[entity].upsert({
where: { id: data.id },
create: {
id: data.id,
tenantCode: data.tenantCode,
code: data.code,
name: data.name,
attributes: data.attributes,
createdAt: data.createdAt,
updatedAt: data.updatedAt,
},
update: {
name: data.name,
attributes: data.attributes,
updatedAt: data.updatedAt,
},
});
}
async down(cmd: CommandModel, data: DataModel): Promise<void> {
// Implement rollback logic if needed
}
}

Naming Conventions

When generating code, follow these naming conventions:

ItemConventionExample
ModulePascalCase + "Module"OrderModule
ControllerPascalCase + "Controller"OrderController
ServicePascalCase + "Service"OrderService
DTOPascalCase + "Dto"CreateOrderDto
HandlerPascalCase + "Handler"OrderDataSyncRdsHandler
File namekebab-caseorder.module.ts
DynamoDB PK/SKSCREAMING_SNAKE_CASEORDER#tenantCode
VariablecamelCaseorderService

Directory Structure

Generate files in this structure:

src/
└── [entity]/
├── [entity].module.ts
├── [entity].controller.ts
├── [entity].service.ts
├── dto/
│ ├── create-[entity].dto.ts
│ ├── update-[entity].dto.ts
│ ├── search-[entity].dto.ts
│ └── [entity]-command.dto.ts
└── handler/
└── [entity]-rds.handler.ts

Important Notes

  1. Always use `publishAsync` for command publishing (not publishSync) unless immediate consistency is required
  2. Include `tenantCode` from getUserContext() for multi-tenant support
  3. Use `VERSION_FIRST` (0) for new entities, existing version for updates
  4. Generate unique IDs using generateId(pk, sk)
  5. Use class-validator decorators for DTO validation
  6. Register DataSyncHandler in the module's CommandModule.register()

Additional Templates

Event Handler (handler/[entity]-event.handler.ts)

For custom event processing:

typescript
import { Injectable, Logger } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { CommandModel, DataModel } from '@mbc-cqrs-serverless/core';
@Injectable()
export class [Entity]EventHandler {
private readonly logger = new Logger([Entity]EventHandler.name);
@OnEvent('[ENTITY].created')
async handleCreated(payload: { command: CommandModel; data: DataModel }) {
this.logger.log(`[Entity] created: ${payload.data.id}`);
// Add custom logic here (e.g., send notification, update cache)
}
@OnEvent('[ENTITY].updated')
async handleUpdated(payload: { command: CommandModel; data: DataModel }) {
this.logger.log(`[Entity] updated: ${payload.data.id}`);
// Add custom logic here
}
@OnEvent('[ENTITY].deleted')
async handleDeleted(payload: { command: CommandModel; data: DataModel }) {
this.logger.log(`[Entity] deleted: ${payload.data.id}`);
// Add custom logic here
}
}
Custom Notification Transport (notifications/[name].transport.ts)

For adding a custom pub/sub transport alongside or instead of the built-in AppSync transports:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
30
Repository forks
6
7-day trend score
17

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 21 Mar 2026, 8 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mbc-net/mbc-cqrs-serverless/mbc-generate/badge)](https://verified-skill.com/skills/mbc-net/mbc-cqrs-serverless/mbc-generate)

Something wrong with this skill or its page? Tell us.