nestjs-provider-review
Skill7 starsChanged 4 months agoMITView on GitHub
Review NestJS module / provider / dependency-injection code before you PR for common regressions. Injection scope misuse (DEFAULT vs REQUEST vs TRANSIENT), circular module dependencies masked by `forwardRef`, missing `exports` in module definitions, exception filter / interceptor / pipe / guard ordering, and async-provider typing gaps. Triggers include "review this NestJS code", "check my module wiring", "why is my provider undefined", "nest DI review".
In this repository14 other files it gives its agents.
- ai-tell-cleanupSkill
- branch-guardSkill
- frontend-perf-impact-scanSkill
- jvm-memory-leak-reviewSkill
- kotlin-coroutine-reviewSkill
- nextjs-app-router-reviewSkill
- parallel-devSkill
- parallel-dispatchSkill
- parallel-prSkill
- pr-impact-scanSkill
- react-hooks-reviewSkill
- review-loopSkill
- reviewSkill
- spring-kafka-listener-reviewSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Default scope is singleton.
- Very specific: line 22
Every forwardRef is a smell.
- Distinctive: line 31
Use it only for cross-cutting infra (config, logging, tracing).
- Distinctive: line 43
Always annotate the factory return type explicitly.
- Very specific: line 47
If you swap adapters mid-project, re-audit every filter, interceptor, and manual response.
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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-provider-review
Catches regressions in the DI graph and request-lifecycle layer of a NestJS app. These bugs pass unit tests (which build their own module) and fail only in the full app boot. Runs before you PR.
What to check
1. Injection scope
- Default scope is singleton. A REQUEST-scoped provider injected into a DEFAULT-scoped provider silently upgrades the whole graph to request-scoped, degrading throughput.
- TRANSIENT-scoped providers create a new instance per consumer. If the provider holds a connection or timer, you leak one per consumer.
- Grep for
scope: Scope.REQUESTand confirm every consumer up the chain understands the cost.
2. Circular deps and forwardRef
- Every
forwardRefis a smell. It usually means the two modules should be one, or one dependency should be inverted. - A cycle that "works" today can fail at boot after a refactor because the eager-init order changed. Prefer restructuring the graph.
3. Module exports
- A provider works in
providersfor internal use but is invisible to importing modules until it is inexports. - Common failure: fixed a service in tests (module has its own
providers), broke in prod (importing module has no access).
4. Global module overuse
@Global()hides the dep graph and makes module refactoring painful.- Use it only for cross-cutting infra (config, logging, tracing). Not for business services.
5. Exception filter chain
- Filters registered globally, at controller level, and at method level all apply. The most specific wins for the same error type. Confirm the intended catch order.
- A filter that returns without calling
response.send(or without returning a value under the fastify adapter) hangs the request.
6. Pipe / Guard / Interceptor order
- Runtime order: middleware, then guards, then interceptors (pre), then pipes, then handler, then interceptors (post), then filters.
- A DTO transformation done in a pipe is not visible to a guard. If a guard needs the transformed value, move that logic into the guard or into an interceptor.
7. Async providers
useFactorywith an async function returns a Promise. TypeScript infers the token as the awaited type, but if theinject:array is wrong, the factory receivesundefinedat boot and Nest throws only when the first consumer resolves.- Always annotate the factory return type explicitly.
8. Fastify vs Express adapter differences
- Return value semantics differ. A handler returning a plain object works in both, but streaming, cookies, and header manipulation differ.
- If you swap adapters mid-project, re-audit every filter, interceptor, and manual
response.call.
Common failure patterns to grep for
forwardRef(() =>appearing in imports across more than two modules.scope: Scope.REQUESTon a provider whose consumers are DEFAULT-scoped controllers.useFactory: async (...)with no explicit return type annotation.- Providers listed in
providers:but missing fromexports:in the same module.
When to invoke
Trigger when the user asks for a NestJS review, mentions DI confusion, or opens a PR touching *.module.ts, *.service.ts, or the app bootstrap file.
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.

