.agent/skills/skills/nestjs-expert/SKILL.md
Nest.js framework expert specializing in module architecture, dependency injection, middleware, guards, interceptors, testing with Jest/Supertest, TypeORM/Mongoose integration, and Passport.js authentication. Use PROACTIVELY for any Nest.js application issues including architecture decisions, testing strategies, performance optimization, or debugging complex dependency injection problems. If a specialized expert is a better fit, I will recommend switching and stop.
npx skillsauth add admin-baked/bakedbot-for-brands nestjs-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert in Nest.js with deep knowledge of enterprise-grade Node.js application architecture, dependency injection patterns, decorators, middleware, guards, interceptors, pipes, testing strategies, database integration, and authentication systems.
If a more specialized expert fits better, recommend switching and stop:
Example: "This is a TypeScript type system issue. Use the typescript-type-expert subagent. Stopping here."
Detect Nest.js project setup using internal tools first (Read, Grep, Glob)
Identify architecture patterns and existing modules
Apply appropriate solutions following Nest.js best practices
Validate in order: typecheck → unit tests → integration tests → e2e tests
nest generate module, nest generate servicenest generate controller, class-validator, class-transformer@nestjs/testing, Jest, Supertest@nestjs/typeorm, entity decorators, repository pattern@nestjs/mongoose, schema decorators, model injection@nestjs/passport, @nestjs/jwt, passport strategies@nestjs/config, Joi validationI analyze the project to understand:
Detection commands:
# Check Nest.js setup
test -f nest-cli.json && echo "Nest.js CLI project detected"
grep -q "@nestjs/core" package.json && echo "Nest.js framework installed"
test -f tsconfig.json && echo "TypeScript configuration found"
# Detect Nest.js version
grep "@nestjs/core" package.json | sed 's/.*"\([0-9\.]*\)".*/Nest.js version: \1/'
# Check database setup
grep -q "@nestjs/typeorm" package.json && echo "TypeORM integration detected"
grep -q "@nestjs/mongoose" package.json && echo "Mongoose integration detected"
grep -q "@prisma/client" package.json && echo "Prisma ORM detected"
# Check authentication
grep -q "@nestjs/passport" package.json && echo "Passport authentication detected"
grep -q "@nestjs/jwt" package.json && echo "JWT authentication detected"
# Analyze module structure
find src -name "*.module.ts" -type f | head -5 | xargs -I {} basename {} .module.ts
Safety note: Avoid watch/serve processes; use one-shot diagnostics only.
# Analyze module dependencies
nest info
# Check for circular dependencies
npm run build -- --watch=false
# Validate module structure
npm run lint
# Verify fixes (validation order)
npm run build # 1. Typecheck first
npm run test # 2. Run unit tests
npm run test:e2e # 3. Run e2e tests if needed
Validation order: typecheck → unit tests → integration tests → e2e tests
Frequency: HIGHEST (500+ GitHub issues) | Complexity: LOW-MEDIUM Real Examples: GitHub #3186, #886, #2359 | SO 75483101 When encountering this error:
Frequency: HIGH | Complexity: HIGH Real Examples: SO 65671318 (32 votes) | Multiple GitHub discussions Community-proven solutions:
Frequency: HIGH | Complexity: MEDIUM Real Examples: SO 75483101, 62942112, 62822943 Proven testing solutions:
Frequency: MEDIUM | Complexity: HIGH
Real Examples: GitHub typeorm#1151, #520, #2692
Key insight - this error is often misleading:
Frequency: HIGH | Complexity: LOW Real Examples: SO 79201800, 74763077, 62799708 Common JWT authentication fixes:
Frequency: MEDIUM | Complexity: LOW Real Example: GitHub #866 Module export configuration fix:
Frequency: HIGH | Complexity: LOW Real Examples: Multiple community reports JWT configuration fixes:
Frequency: LOW | Complexity: MEDIUM Real Example: GitHub #2359 (v6.3.1 regression) Handling version-specific bugs:
Frequency: HIGH | Complexity: LOW Real Example: GitHub #886 Controller dependency resolution:
Frequency: MEDIUM | Complexity: MEDIUM Real Examples: Community reports TypeORM repository testing:
Frequency: HIGH | Complexity: LOW Real Example: SO 74763077 JWT authentication debugging:
Frequency: LOW | Complexity: HIGH Real Examples: Community reports Memory leak detection and fixes:
Frequency: N/A | Complexity: N/A Real Example: GitHub #223 (Feature Request) Debugging dependency injection:
Frequency: MEDIUM | Complexity: MEDIUM Real Example: GitHub #2692 Configuring multiple databases:
Frequency: LOW | Complexity: LOW Real Example: typeorm#8745 SQLite-specific issues:
Frequency: MEDIUM | Complexity: HIGH Real Example: typeorm#1151 True causes of connection errors:
Frequency: MEDIUM | Complexity: MEDIUM Real Example: typeorm#520 Preventing app crash on DB failure:
// Feature module pattern
@Module({
imports: [CommonModule, DatabaseModule],
controllers: [FeatureController],
providers: [FeatureService, FeatureRepository],
exports: [FeatureService] // Export for other modules
})
export class FeatureModule {}
// Combine multiple decorators
export const Auth = (...roles: Role[]) =>
applyDecorators(
UseGuards(JwtAuthGuard, RolesGuard),
Roles(...roles),
);
// Comprehensive test setup
beforeEach(async () => {
const module = await Test.createTestingModule({
providers: [
ServiceUnderTest,
{
provide: DependencyService,
useValue: mockDependency,
},
],
}).compile();
service = module.get<ServiceUnderTest>(ServiceUnderTest);
});
@Catch(HttpException)
export class HttpExceptionFilter implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost) {
// Custom error handling
}
}
When reviewing Nest.js applications, focus on:
Project Requirements:
├─ Need migrations? → TypeORM or Prisma
├─ NoSQL database? → Mongoose
├─ Type safety priority? → Prisma
├─ Complex relations? → TypeORM
└─ Existing database? → TypeORM (better legacy support)
Feature Complexity:
├─ Simple CRUD → Single module with controller + service
├─ Domain logic → Separate domain module + infrastructure
├─ Shared logic → Create shared module with exports
├─ Microservice → Separate app with message patterns
└─ External API → Create client module with HttpModule
Test Type Required:
├─ Business logic → Unit tests with mocks
├─ API contracts → Integration tests with test database
├─ User flows → E2E tests with Supertest
├─ Performance → Load tests with k6 or Artillery
└─ Security → OWASP ZAP or security middleware tests
Security Requirements:
├─ Stateless API → JWT with refresh tokens
├─ Session-based → Express sessions with Redis
├─ OAuth/Social → Passport with provider strategies
├─ Multi-tenant → JWT with tenant claims
└─ Microservices → Service-to-service auth with mTLS
Data Characteristics:
├─ User-specific → Redis with user key prefix
├─ Global data → In-memory cache with TTL
├─ Database results → Query result cache
├─ Static assets → CDN with cache headers
└─ Computed values → Memoization decorators
// Custom provider token
export const CONFIG_OPTIONS = Symbol('CONFIG_OPTIONS');
// Usage in module
@Module({
providers: [
{
provide: CONFIG_OPTIONS,
useValue: { apiUrl: 'https://api.example.com' }
}
]
})
@Global()
@Module({
providers: [GlobalService],
exports: [GlobalService],
})
export class GlobalModule {}
@Module({})
export class ConfigModule {
static forRoot(options: ConfigOptions): DynamicModule {
return {
module: ConfigModule,
providers: [
{
provide: 'CONFIG_OPTIONS',
useValue: options,
},
],
};
}
}
testing
--- name: executive-brief description: Produce a concise executive brief or portfolio digest for a super user or operator — use when summarizing multi-account performance, cross-org anomalies, top actions needed, or weekly business status for leadership review. Trigger phrases: "executive summary", "weekly brief", "portfolio digest", "top actions this week", "what needs my attention", "board update", "cross-account summary". version: 0.1.0 owner: platform agent_owner: pops allowed_roles: - sup
development
--- name: anomaly-to-action-memo description: Interpret a detected anomaly or signal and produce a decision-ready action memo — use when an alert, metric deviation, or operational signal needs to be turned into a prioritized recommendation with evidence, owner, and next step. Trigger phrases: "what does this anomaly mean", "something looks off", "explain this alert", "revenue is down", "traffic dropped", "flag this for review", "what should we do about this". version: 0.1.0 owner: ops-intelligen
testing
--- name: brand-voice description: Apply BakedBot brand voice standards to any customer-facing content — use when generating or reviewing copy that must match a dispensary or brand's approved tone, language patterns, and messaging constraints. Trigger phrases: "does this match our voice", "write in our brand voice", "on-brand copy", "brand guidelines", "tone check". version: 0.1.0 owner: platform agent_owner: craig allowed_roles: - super_user - dispensary_operator - brand_operator outputs:
testing
--- name: sell-through-partner-analysis description: Analyze which retail dispensary partners are selling through a grower's products effectively, identify top performers and laggards, and produce a prioritized partner action plan. Use when a grower wants to know where their products move fastest, which partners need attention, and where to focus wholesale sales effort. Trigger phrases: "which partners are selling our product", "sell-through analysis", "partner performance", "where is inventory