Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

nestjs-expert · jeffallan — Claude Code skill: modules, controllers, services

A skill for designing and building NestJS backends in TypeScript: modules, services, controllers, validation, authentication and testing. Use it when building REST APIs or GraphQL services with enterprise patterns.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add Jeffallan/claude-skills --skill nestjs-expert -a claude-code
Open on GitHub

What nestjs-expert does

nestjs-expert guides the creation of modular NestJS architecture: designs module relationships, generates services with dependency injection, configures controllers with class-validator validation and Swagger documentation. Supports guards, interceptors, pipes, JWT/Passport authentication, and TypeORM or Prisma integration.

Inside the skill are reference guides for controllers, services, DTOs, authentication, and testing. Code examples show how to use @Injectable(), constructor injection, typed HTTP exceptions, and unit tests with Test.createTestingModule. The skill works in Node.js projects with npm or yarn across Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode.

Scope: the skill covers core NestJS patterns but does not fully address microservices, WebSocket, or message queues—you'll need manual input for complex integrations. All configuration (databases, keys) should flow through ConfigModule and environment variables.

What it helps with

  • design module structure for large NestJS projects
  • create a validated controller with Swagger documentation
  • organize services with dependency injection and error handling
  • set up JWT authentication with guards and Passport
  • write unit and E2E tests for controllers and services

Example prompts for the agent

  • Help me design a users module with a controller, service, and class-validator validation
  • Create an authentication controller with JWT guard and Passport strategy
  • Write unit tests for UsersService with a mocked TypeORM repository

How to install nestjs-expert

1Skills CLI (Vercel)

npx skills add Jeffallan/claude-skills --skill nestjs-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/nestjs-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/nestjs-expert/

From the same set61

The whole set →
laravel-specialist https://github.com/Jeffallan Configures the agent for Laravel 10+ and PHP 8.2+ development. It guides Eloquent modeling, Horizon queues, API resources, and Pest testing. Claude Code CX Codex Cursor +1 23,300installs golang-pro https://github.com/Jeffallan A Go skill for concurrent code, microservices, performance profiling, and idiomatic interfaces. Use it for goroutines, gRPC, benchmarks, and table-driven tests. Claude Code CX Codex Cursor +1 18,900installs php-pro https://github.com/Jeffallan Enforces PHP 8.3+ standards across Laravel and Symfony projects with strict typing, PHPStan level 9 checks, and automated Pest tests. Claude Code CX Codex Cursor +1 15,500installs flutter-expert https://github.com/Jeffallan Skill for building cross-platform apps with Flutter 3+ and Dart. Covers widgets, state management via Riverpod or Bloc, GoRouter navigation, and performance optimization. Claude Code CX Codex Cursor +1 14,300installs typescript-pro https://github.com/Jeffallan Implements advanced TypeScript type systems, branded types, and tRPC configurations. Use it when building type-first APIs or complex discriminated unions. Claude Code CX Codex Cursor +1 14,200installs kubernetes-specialist https://github.com/Jeffallan This skill helps create and validate Kubernetes manifests, set workload security, and troubleshoot failing pods. Use it for deployment and cluster operations. Claude Code CX Codex Cursor +1 14,100installs devops-engineer https://github.com/Jeffallan This skill creates Dockerfiles, CI/CD configs, Kubernetes manifests, and IaC templates. Use it for deployments, platform work, and incident response. Claude Code CX Codex Cursor +1 11,200installs wordpress-pro https://github.com/Jeffallan This skill builds WordPress themes, plugins, Gutenberg blocks, and WooCommerce features. Use it for REST API work, hooks, security checks, and performance tuning. Claude Code CX Codex Cursor +1 9,700installs

Other versions of nestjs-expert

Similar

bfl-api Black Forest Labs This skill helps connect BFL FLUX API for image generation and editing. It covers async requests, polling, rate limits, and webhooks. Claude Code CX Codex Cursor +1 1,000installs woocommerce-code-review woocommerce Checks WooCommerce changes against PHP, JS/TS, testing, and UI copy conventions. Useful for local reviews and automated PR checks. Claude Code CX Codex Cursor +1 1,800installs cf-cli cloudflare Cloudflare's official CLI for the public API and Workers projects, now available in your editor. Search for commands by task description, manage DNS, storage, and deployments. Claude Code CX Codex Cursor +1 10,700installs popbill NomaDamas Prepares the agent to interact with South Korean Popbill services for tax invoices, cash receipts, and business checks in test and live setups. Claude Code CX Codex Cursor +1 4,300installs senior-architect sickn33 A skill for designing and reviewing system architecture based on explicit requirements, tradeoffs and evidence. Helps you choose an approach by examining current state, alternatives and risks. Claude Code CX Codex Cursor +1 2,200installs mcp-builder official anthropics This skill walks through building an MCP server in TypeScript or Python, from reading the protocol spec to writing tests and evaluation questions. Claude Code Claude.ai 130,949installs google-agents-cli-adk-code official Google A reference skill for building ADK agents with tools, callbacks, state, and workflows. Use it when an agent project needs concrete API patterns or code examples. Claude Code CX Codex Cursor +1 511,400installs lark-im larksuite This skill lets an agent work with Lark IM messages, chats, files, and interactive cards. Use it when coding tasks need access to team conversations. Claude Code CX Codex Cursor +1 472,300installs

Questions about nestjs-expert

How do I install nestjs-expert in Claude Code?

Run npx skills add Jeffallan/claude-skills --skill nestjs-expert -a claude-code, then the skill loads at ~/.claude/skills/nestjs-expert/SKILL.md.

What does nestjs-expert do?

It helps create NestJS modules, controllers, services, DTOs, and guards with dependency injection, validation, authentication, and testing. The skill includes architecture reference guides, code examples, and best practices for constructor injection, error handling, and Swagger documentation.

What platforms does nestjs-expert support?

Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. Each platform has its own install command.

Source text

SKILL.md · MIT
---
name: nestjs-expert
description: Creates and configures NestJS modules, controllers, services, DTOs, guards, and interceptors for enterprise-grade TypeScript backend applications. Use when building NestJS REST APIs or GraphQL services, implementing dependency injection, scaffolding modular architecture, adding JWT/Passport authentication, integrating TypeORM or Prisma, or working with .module.ts, .controller.ts, and .service.ts files. Invoke for guards, interceptors, pipes, validation, Swagger documentation, and unit/E2E testing in NestJS projects.
license: MIT
metadata:
  author: https://github.com/Jeffallan
  company: https://synergetic.solutions
  version: "1.1.0"
  domain: backend
  triggers: NestJS, Nest, Node.js backend, TypeScript backend, dependency injection, controller, service, module, guard, interceptor
  role: specialist
  scope: implementation
  output-format: code
  related-skills: fullstack-guardian, test-master, devops-engineer
---

# NestJS Expert

Senior NestJS specialist with deep expertise in enterprise-grade, scalable TypeScript backend applications.

## Core Workflow

1. **Analyze requirements** — Identify modules, endpoints, entities, and relationships
2. **Design structure** — Plan module organization and inter-module dependencies
3. **Implement** — Create modules, services, and controllers with proper DI wiring
4. **Secure** — Add guards, validation pipes, and authentication
5. **Verify** — Run `npm run lint`, `npm run test`, and confirm DI graph with `nest info`
6. **Test** — Write unit tests for services and E2E tests for controllers

## Reference Guide

Load detailed guidance based on context:

| Topic | Reference | Load When |
|-------|-----------|-----------|
| Controllers | `references/controllers-routing.md` | Creating controllers, routing, Swagger docs |
| Services | `references/services-di.md` | Services, dependency injection, providers |
| DTOs | `references/dtos-validation.md` | Validation, class-validator, DTOs |
| Authentication | `references/authentication.md` | JWT, Passport, guards, authorization |
| Testing | `references/testing-patterns.md` | Unit tests, E2E tests, mocking |
| Express Migration | `references/migration-from-express.md` | Migrating from Express.js to NestJS |

## Code Examples

### Controller with DTO Validation and Swagger

```typescript
// create-user.dto.ts
import { IsEmail, IsString, MinLength } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateUserDto {
  @ApiProperty({ example: '[email protected]' })
  @IsEmail()
  email: string;

  @ApiProperty({ example: '<password>', minLength: 8 })
  @IsString()
  @MinLength(8)
  password: string;
}

// users.controller.ts
import { Body, Controller, Post, HttpCode, HttpStatus } from '@nestjs/common';
import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger';
import { UsersService } from './users.service';
import { CreateUserDto } from './dto/create-user.dto';

@ApiTags('users')
@Controller('users')
export class UsersController {
  constructor(private readonly usersService: UsersService) {}

  @Post()
  @HttpCode(HttpStatus.CREATED)
  @ApiCreatedResponse({ description: 'User created successfully.' })
  create(@Body() createUserDto: CreateUserDto) {
    return this.usersService.create(createUserDto);
  }
}
```

### Service with Dependency Injection and Error Handling

```typescript
// users.service.ts
import { Injectable, ConflictException, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './entities/user.entity';
import { CreateUserDto } from './dto/create-user.dto';

@Injectable()
export class UsersService {
  constructor(
    @InjectRepository(User)
    private readonly usersRepository: Repository<User>,
  ) {}

  async create(createUserDto: CreateUserDto): Promise<User> {
    const existing = await this.usersRepository.findOneBy({ email: createUserDto.email });
    if (existing) {
      throw new ConflictException('Email already registered');
    }
    const user = this.usersRepository.create(createUserDto);
    return this.usersRepository.save(user);
  }

  async findOne(id: number): Promise<User> {
    const user = await this.usersRepository.findOneBy({ id });
    if (!user) {
      throw new NotFoundException(`User #${id} not found`);
    }
    return user;
  }
}
```

### Module Definition

```typescript
// users.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersController } from './users.controller';
import { UsersService } from './users.service';
import { User } from './entities/user.entity';

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  controllers: [UsersController],
  providers: [UsersService],
  exports: [UsersService], // export only when other modules need this service
})
export class UsersModule {}
```

### Unit Test for Service

```typescript
// users.service.spec.ts
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { ConflictException } from '@nestjs/common';
import { UsersService } from './users.service';
import { User } from './entities/user.entity';

const mockRepo = {
  findOneBy: jest.fn(),
  create: jest.fn(),
  save: jest.fn(),
};

describe('UsersService', () => {
  let service: UsersService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [
        UsersService,
        { provide: getRepositoryToken(User), useValue: mockRepo },
      ],
    }).compile();
    service = module.get<UsersService>(UsersService);
    jest.clearAllMocks();
  });

  it('throws ConflictException when email already exists', async () => {
    mockRepo.findOneBy.mockResolvedValue({ id: 1, email: '[email protected]' });
    await expect(
      service.create({ email: '[email protected]', password: '<test-password>' }),
    ).rejects.toThrow(ConflictException);
  });
});
```

## Constraints

### MUST DO
- Use `@Injectable()` and constructor injection for all services — never instantiate services with `new`
- Validate all inputs with `class-validator` decorators on DTOs and enable `ValidationPipe` globally
- Use DTOs for all request/response bodies; never pass raw `req.body` to services
- Throw typed HTTP exceptions (`NotFoundException`, `ConflictException`, etc.) in services
- Document all endpoints with `@ApiTags`, `@ApiOperation`, and response decorators
- Write unit tests for every service method using `Test.createTestingModule`
- Store all config values via `ConfigModule` and `process.env`; never hardcode them

### MUST NOT DO
- Expose passwords, secrets, or internal stack traces in responses
- Accept unvalidated user input — always apply `ValidationPipe`
- Use `any` type unless absolutely necessary and documented
- Create circular dependencies between modules — use `forwardRef()` only as a last resort
- Hardcode hostnames, ports, or credentials in source files
- Skip error handling in service methods

## Output Templates

When implementing a NestJS feature, provide in this order:
1. Module definition (`.module.ts`)
2. Controller with Swagger decorators (`.controller.ts`)
3. Service with typed error handling (`.service.ts`)
4. DTOs with `class-validator` decorators (`dto/*.dto.ts`)
5. Unit tests for service methods (`*.service.spec.ts`)

## Knowledge Reference

NestJS, TypeScript, TypeORM, Prisma, Passport, JWT, class-validator, class-transformer, Swagger/OpenAPI, Jest, Supertest, Guards, Interceptors, Pipes, Filters

Maintained by [@jeffallan](https://github.com/jeffallan), Principal Consultant at [Synergetic Solutions](https://synergetic.solutions)

[Documentation](https://jeffallan.github.io/claude-skills/skills/backend/nestjs-expert/)

© https://github.com/Jeffallan · MIT · Jeffallan/claude-skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor