nestjs-import-enforcerlisted
Install: claude install-skill smicolon/ai-kit
# Import Convention Enforcer (NestJS)
Auto-enforces absolute imports from barrel exports for clean, maintainable NestJS code.
## When This Skill Activates
I automatically run when:
- User writes or modifies TypeScript files
- User creates entities, DTOs, services, controllers
- User imports from other modules
- User mentions "import", "NestJS", "module"
- User organizes project structure
## Required Import Pattern (MANDATORY)
**✅ CORRECT - Absolute imports from barrel exports:**
```typescript
// Absolute path from src/
import { User, Profile } from 'src/users/entities'
import { UsersService } from 'src/users/services'
import { CreateUserDto, UpdateUserDto } from 'src/users/dto'
import { JwtAuthGuard } from 'src/auth/guards'
// NestJS/Third-party - standard imports
import { Injectable, NotFoundException } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
```
**❌ WRONG - Relative imports:**
```typescript
import { User } from './entities/user.entity'
import { UsersService } from '../services/users.service'
import { JwtAuthGuard } from '../../auth/guards/jwt-auth.guard'
```
**❌ WRONG - Import from specific files (not barrel):**
```typescript
import { User } from 'src/users/entities/user.entity'
```
## Auto-Fix Process
### Step 1: Detect Violations
```typescript
// ❌ User writes
import { User } from './entities/user.entity'
import { CreateUserDto } from '../dto/create-user.dto'
import { AuthService } from '../../auth/services/auth.service'
```
##