plugins/smedjen/skills/nestjs-patterns/SKILL.md
NestJS modules, providers, guards, interceptors, pipes, and testing patterns. Module organization, request lifecycle, decorator patterns, and test strategy.
npx skillsauth add hjemmesidekongen/ai nestjs-patternsInstall 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.
NestJS is Angular-influenced — modules, DI, and decorators are the core model. Work with the framework's conventions; fighting them creates unmaintainable code.
Feature modules own everything inside their boundary: controller, service, repository, DTOs. CoreModule handles app-wide singletons (config, logger, DB connection). SharedModule exports reusable utilities with no circular dependencies.
Keep AppModule thin — it imports feature modules and wires global middleware only.
Middleware → Guards → Interceptors (pre) → Pipes → Handler → Interceptors (post) → Exception Filters
Order matters. Guards run before pipes. Interceptors wrap the entire handler. Exception filters catch what escapes guards and handlers both.
Use custom decorators to extract repeated logic from handlers: @CurrentUser(), @Roles(), @Public(). Keep handlers thin — they should read like a spec, not an implementation.
Combine @UseGuards(), @UseInterceptors(), and @UsePipes() at the controller level when they apply to all routes. Route-level decorators only when behavior diverges.
Unit tests: Test.createTestingModule() with mocked providers. Mock at the service boundary, not inside services. Test one class per file.
E2E tests: @nestjs/testing with supertest. Spin up the full app, hit real endpoints, use a test DB or in-memory store. Cover auth flows and request validation end-to-end.
See references/process.md for module patterns, DI, guards, interceptors, pipes, exception filters, middleware, microservices basics, CQRS, and anti-patterns.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.