nestjs-backend-dev
Expert patterns, scaffolding commands, and best practices for developing the NestJS backend API.
Install
mkdir -p .claude/skills/nestjs-backend-dev && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15792" && unzip -o skill.zip -d .claude/skills/nestjs-backend-dev && rm skill.zipInstalls to .claude/skills/nestjs-backend-dev
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Expert patterns, scaffolding commands, and best practices for developing the NestJS backend API.About this skill
NestJS Backend Development Skill
Use this skill when modifying or extending the apps/backend-api project.
1. Scaffolding Rules
When creating new features, always follow the Modular Monolith structure.
Generating a New Feature Module
Use the NestJS CLI to ensure proper wiring in app.module.ts.
# Example: Creating a 'plans' feature
cd apps/backend-api
npx nest g module modules/plans
npx nest g controller modules/plans --no-spec
npx nest g service modules/plans --no-spec
Note: We disable default spec files (--no-spec) because we prefer writing integration tests or focused unit tests later.
2. DTO & Validation Patterns
Every Controller Endpoint MUST have a dedicated DTO.
Template: Request DTO
import { IsString, IsOptional, IsInt, Min } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class CreateItemDto {
@ApiProperty({ description: 'The name of the item', example: 'My Item' })
@IsString()
name: string;
@ApiPropertyOptional({ description: 'Optional description' })
@IsOptional()
@IsString()
description?: string;
}
3. Prisma & Database Interactions
Accessing the DB
Always inject PrismaService.
constructor(private prisma: PrismaService) {}
Soft Delete Pattern
When "deleting" core business data (users, media), use update to set deletedAt.
async remove(id: number) {
return this.prisma.media.update({
where: { id },
data: { deletedAt: new Date() },
});
}
4. Queue (BullMQ) Integration
When sending jobs to the AI Engine:
- Inject the Queue using
@InjectQueue. - Ensure the payload matches the Python worker's expected schema.
// Constructor
constructor(@InjectQueue('transcription_queue') private transQueue: Queue) {}
// Method
async addToQueue(fileKey: string) {
await this.transQueue.add('transcribe', {
s3Key: fileKey,
// ...other params
});
}
5. Environment & Config
Access config via ConfigService, strict typed.
// BAD
const db = process.env.DATABASE_URL;
// GOOD
const db = this.configService.getOrThrow<string>('DATABASE_URL');