> angular-dependency-injection
Best practices for DI, inject() usage, and providers. Use when configuring Angular dependency injection, using inject(), or defining providers. (triggers: **/*.service.ts, **/*.ts, angular inject, providedIn, injection token)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/angular-dependency-injection?format=md"Dependency Injection
Priority: P0 (CRITICAL)
Principles
inject()over Constructor: Use theinject()function for cleaner injection updates and type inference.- Tree Shaking: Always use
providedIn: 'root'for services unless specific scoping is required. - Tokens: Use
InjectionToken<T>for configuration, primitives, or interface abstraction.
Guidelines
- Providers: Prefer
provide*functions (e.g.,provideHttpClient()) inapp.config.tsover importing modules. - Factories: Use
useFactorystrictly when dependencies need runtime configuration.
Anti-Patterns
- Global State: Avoid
providedIn: 'platform'unless absolutely necessary (share between Micro Frontends). - Circular Deps: Use
forwardRefonly as a last resort; refactor architecture instead.
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)