Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ronaldjdev/forge/llms.txt

Use this file to discover all available pages before exploring further.

Dependency Injection is the foundation of testable, loosely-coupled backend code. When classes resolve their own dependencies — by calling container.resolve() mid-logic, or by instantiating collaborators with new — they become impossible to unit-test without spinning up the full runtime, and the hidden coupling they create is invisible to static analysis and architectural audits. forge temper automates the remediation: it walks your project, identifies classes that violate DI discipline, and applies the correct injection pattern for your active technology profile — whether that is tsyringe decorators, NestJS’s built-in DI system, or manual constructor injection.

Usage

# Via agent natural language: "templar", "endurecer", "mejorar"
# Direct invocation:
forge temper

What temper Does

temper adapts its behaviour to the DI strategy associated with your active technology profile (detected by forge profile):
Applies to: express-mongodb, express-prisma, express-drizzle, and fastify-prisma profiles that use tsyringe.
  • Adds @injectable() to every class that has injected dependencies
  • Adds @inject(TOKEN) to each constructor parameter, using class tokens — never plain strings
  • Removes container.resolve() calls from use cases, domain objects, and adapters (resolving is only allowed in bootstrap files such as app.ts or routes)
// Before
import { container } from "tsyringe";

export class CreateUserUseCase {
  execute(dto: CreateUserDto) {
    const repo = container.resolve(UserRepository); // ← service locator
    return repo.save(dto);
  }
}

// After
import { injectable, inject } from "tsyringe";
import { IUserRepository } from "../../domain/repositories/IUser.repository.js";
import { TOKENS } from "../../../platform/di/Tokens.js";

@injectable()
export class CreateUserUseCase {
  constructor(
    @inject(TOKENS.UserRepository)
    private readonly userRepository: IUserRepository,
  ) {}

  execute(dto: CreateUserDto) {
    return this.userRepository.save(dto);
  }
}

DI Rules Enforced

Regardless of profile, temper enforces these universal rules:
RuleSeverity
Always use constructor injectionERROR
No service locators (container.resolve() outside bootstrap)ERROR
No global singletons shared across featuresWARNING
No new Dependency() inside injected classesWARNING

What is prohibited

  • container.resolve() inside use cases, entities, or adapters
  • new UseCase(dep1, dep2) in features that use a DI container
  • ❌ Importing tsyringe in domain files
  • ❌ Mixing manual DI and container DI within the same feature
Run forge quench after temper to verify that the Decorators category improves in the audit report (Decorators contributes 20 points to the total 180-point score). A clean temper pass should move this category toward full marks.
temper detects your active technology profile automatically via forge profile. If the detected profile does not match your intended DI strategy, run forge profile first to confirm it and adjust if necessary.

Build docs developers (and LLMs) love