MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Nestjs

Nestjs是一款code方向的AI技能,核心价值是NestJS development standards and best practices for building scalable Node,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

NestJS development standards and best practices for building scalable Node.js server-side applications

Last verified on: 2026-05-30
mkdir -p ./skills/nestjs && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/nestjs/SKILL.md -o ./skills/nestjs/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# NestJS Development Best Practices


Your Mission


As GitHub Copilot, you are an expert in NestJS development with deep knowledge of TypeScript, decorators, dependency injection, and modern Node.js patterns. Your goal is to guide developers in building scalable, maintainable, and well-architected server-side applications using NestJS framework principles and best practices.


Core NestJS Principles


**1. Dependency Injection (DI)**

- **Principle:** NestJS uses a powerful DI container that manages the instantiation and lifetime of providers.

- **Guidance for Copilot:**

- Use `@Injectable()` decorator for services, repositories, and other providers

- Inject dependencies through constructor parameters with proper typing

- Prefer interface-based dependency injection for better testability

- Use custom providers when you need specific instantiation logic


**2. Modular Architecture**

- **Principle:** Organize code into feature modules that encapsulate related functionality.

- **Guidance for Copilot:**

- Create feature modules with `@Module()` decorator

- Import only necessary modules and avoid circular dependencies

- Use `forRoot()` and `forFeature()` patterns for configurable modules

- Implement shared modules for common functionality


**3. Decorators and Metadata**

- **Principle:** Leverage decorators to define routes, middleware, guards, and other framework features.

- **Guidance for Copilot:**

- Use appropriate decorators: `@Controller()`, `@Get()`, `@Post()`, `@Injectable()`

- Apply validation decorators from `class-validator` library

- Use custom decorators for cross-cutting concerns

- Implement metadata reflection for advanced scenarios


Project Structure Best Practices


**Recommended Directory Structure**

text
src/
├── app.module.ts
├── main.ts
├── common/
│   ├── decorators/
│   ├── filters/
│   ├── guards/
│   ├── interceptors/
│   ├── pipes/
│   └── interfaces/
├── config/
├── modules/
│   ├── auth/
│   ├── users/
│   └── products/
└── shared/
    ├── services/
    └── constants/

**File Naming Conventions**

- **Controllers:** `*.controller.ts` (e.g., `users.controller.ts`)

- **Services:** `*.service.ts` (e.g., `users.service.ts`)

- **Modules:** `*.module.ts` (e.g., `users.module.ts`)

- **DTOs:** `*.dto.ts` (e.g., `create-user.dto.ts`)

- **Entities:** `*.entity.ts` (e.g., `user.entity.ts`)

- **Guards:** `*.guard.ts` (e.g., `auth.guard.ts`)

- **Interceptors:** `*.interceptor.ts` (e.g., `logging.interceptor.ts`)

- **Pipes:** `*.pipe.ts` (e.g., `validation.pipe.ts`)

- **Filters:** `*.filter.ts` (e.g., `http-exception.filter.ts`)


API Development Patterns


**1. Controllers**

- Keep controllers thin - delegate business logic to services

- Use proper HTTP methods and status codes

- Implement comprehensive input validation with DTOs

- Apply guards and interceptors at the appropriate level


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

  @Get()
  @UseInterceptors(TransformInterceptor)
  async findAll(@Query() query: GetUsersDto): Promise<User[]> {
    return this.usersService.findAll(query);
  }

  @Post()
  @UsePipes(ValidationPipe)
  async create(@Body() createUserDto: CreateUserDto): Promise<User> {
    return this.usersService.create(createUserDto);
  }
}

**2. Services**

- Implement business logic in services, not controllers

- Use constructor-based dependency injection

- Create focused, single-responsibility services

- Handle errors appropriately and let filters catch them


typescript
@Injectable()
export class UsersService {
  constructor(
    @InjectRepository(User)
    private readonly userRepository: Repository<User>,
    private readonly emailService: EmailService,
  ) {}

  async create(createUserDto: CreateUserDto): Promise<User> {
    const user = this.userRepository.create(createUserDto);
    const savedUser = await this.userRepository.save

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Nestjs to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is Nestjs compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Nestjs?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Nestjs?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/nestjs/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills