code-backend-nestjs
Skill0 starsChanged 2 months agoMITView on GitHub
NestJS best practices and architecture patterns for building production-ready applications. This skill should be used when writing, reviewing, or refactoring NestJS code to ensure proper patterns for modules, dependency injection, security, and performance.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- code-frontend-library-reactSkill
- doc-changelog-generationSkill
- doc-design-generationSkill
- doc-domain-generationSkill
- doc-guardrail-generationSkill
- doc-policy-generationSkill
- doc-readme-generationSkill
- git-tbd-for-sddSkill
- git-worktrees-useSkill
- openspec-generate-baselineSkill
- openspec-init-configSkill
- security-auditSkill
- skill-masterSkill
- skill-test-evalsSkill
- test-cypress-cucumberSkill
- test-nestjs-jest-testing-moduleSkill
- test-nestjs-supertestSkill
- test-playwright-cucumberSkill
- test-react-testing-librarySkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 55
Read individual reference files as if they were rules and get detailed explanations and code examples:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NestJS for backend code
Overview
Comprehensive best practices guide for backend code or NestJS applications. Contains references across different categories, prioritized by impact to guide automated refactoring and code generation.
Capabilities:
- Guide writing of NestJS modules, controllers, and services with proper patterns.
- Apply architecture, dependency injection, error handling, security, and performance best practices.
- Drive automated refactoring and code generation, prioritized by impact.
- Implements the GREEN and REFACTOR phases of TDD.
Limitations:
- Guidance/reference only — does not scaffold or run code by itself.
- Focused on NestJS backend code; not for frontend or non-NestJS stacks.
- Testing is out of scope for this skill, not for tests.
Prerequisites
Reference these guidelines when:
- Writing new NestJS modules, controllers, or services
- Implementing authentication and authorization
- Reviewing code for architecture and security issues
- Refactoring existing NestJS codebases
- Optimizing performance or database queries
- Building microservices architectures
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
| 1 | Architecture | CRITICAL | arch- |
| 2 | Dependency Injection | CRITICAL | di- |
| 3 | Error Handling | HIGH | error- |
| 4 | Security | HIGH | security- |
| 5 | Performance | HIGH | perf- |
| 6 | Database & ORM | MEDIUM-HIGH | db- |
| 7 | API Design | MEDIUM | api- |
| 8 | Microservices | MEDIUM | micro- |
| 9 | DevOps & Deployment | LOW-MEDIUM | devops- |
Examples
Read individual reference files as if they were rules and get detailed explanations and code examples:
references/arch-avoid-circular-deps.md
references/security-validate-all-input.md
references/_sections.mdEach reference file contains:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and references
References
For more details, consult these reference files (loaded on demand):
1. Architecture (CRITICAL)
- references/arch-avoid-circular-deps.md - Avoid circular module dependencies
- references/arch-feature-modules.md - Organize by feature, not technical layer
- references/arch-module-sharing.md - Proper module exports/imports, avoid duplicate providers
- references/arch-single-responsibility.md - Focused services over "god services"
- references/arch-use-repository-pattern.md - Abstract database logic for testability
- references/arch-use-events.md - Event-driven architecture for decoupling
- references/arch-hexagonal-ddd-structure.md - Structure modules with DDD + hexagonal architecture (ports & adapters)
2. Dependency Injection (CRITICAL)
- references/di-avoid-service-locator.md - Avoid service locator anti-pattern
- references/di-interface-segregation.md - Interface Segregation Principle (ISP)
- references/di-liskov-substitution.md - Liskov Substitution Principle (LSP)
- references/di-prefer-constructor-injection.md - Constructor over property injection
- references/di-scope-awareness.md - Understand singleton/request/transient scopes
- references/di-use-interfaces-tokens.md - Use injection tokens for interfaces
3. Error Handling (HIGH)
- references/error-use-exception-filters.md - Centralized exception handling
- references/error-throw-http-exceptions.md - Use NestJS HTTP exceptions
- references/error-handle-async-errors.md - Handle async errors properly
4. Security (HIGH)
- references/security-auth-jwt.md - Secure JWT authentication
- references/security-validate-all-input.md - Validate with class-validator
- references/security-use-guards.md - Authentication and authorization guards
- references/security-sanitize-output.md - Prevent XSS attacks
- references/security-rate-limiting.md - Implement rate limiting
5. Performance (HIGH)
- references/perf-async-hooks.md - Proper async lifecycle hooks
- references/perf-use-caching.md - Implement caching strategies
- references/perf-optimize-database.md - Optimize database queries
- references/perf-lazy-loading.md - Lazy load modules for faster startup
6. Database & ORM (MEDIUM-HIGH)
- references/db-use-transactions.md - Transaction management
- references/db-avoid-n-plus-one.md - Avoid N+1 query problems
- references/db-use-migrations.md - Use migrations for schema changes
7. API Design (MEDIUM)
- references/api-use-dto-serialization.md - DTO and response serialization
- references/api-use-interceptors.md - Cross-cutting concerns
- references/api-versioning.md - API versioning strategies
- references/api-use-pipes.md - Input transformation with pipes
8. Microservices (MEDIUM)
- references/micro-use-patterns.md - Message and event patterns
- references/micro-use-health-checks.md - Health checks for orchestration
- references/micro-use-queues.md - Background job processing
9. DevOps & Deployment (LOW-MEDIUM)
- references/devops-use-config-module.md - Environment configuration
- references/devops-use-logging.md - Structured logging
- references/devops-graceful-shutdown.md - Zero-downtime deployments
These files are only loaded if the agent needs additional context.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

