xiaohongshu
xiaohongshu
di-helper
Manage tsyringe DI container registration, scan injectable classes, detect missing registrations, validate injection patterns, and generate registration code. Use when registering repositories, fixing DI errors, or setting up new context (e.g., "Register ProductRepository", "Check DI setup").
Full skill instructions
Manage tsyringe dependency injection container registration. Scans for injectable classes, detects missing registrations, validates injection patterns, and generates ready-to-use registration code.
Comprehensive DI container management:
@injectable() decorated classesUse when you need to:
Examples:
// In /src/global/container/container.ts
import type { IUserRepository } from '@/contexts/user/domain';
import { UserRepository } from '@/contexts/user/infrastructure/repositories/user.repository';
container.registerSingleton<IUserRepository>(
'IUserRepository', // String token
UserRepository // Implementation class
);
Use cases are automatically registered by tsyringe when decorated with @injectable():
@injectable()
export class CreateUserUseCase {
// No explicit registration needed
}
Controllers are auto-registered like use cases:
@injectable()
export class UserController {
// No explicit registration needed
}
Listeners must be resolved and registered with event bus:
// In /src/main.ts
import { UserCreatedListener } from '@/contexts/user/application';
const listener = container.resolve(UserCreatedListener);
eventBus.on('UserCreated', listener.handle.bind(listener));
constructor(
@inject('IUserRepository')
private readonly userRepo: IUserRepository
) {}
constructor(
@inject(CreateUserUseCase)
private readonly createUser: CreateUserUseCase
) {}
@injectable() DecoratorScans for classes that should be injectable:
MISSING: @injectable() decorator
File: src/contexts/user/infrastructure/repositories/user.repository.ts:5
Issue: UserRepository missing @injectable() decorator
Fix: Add decorator:
import { injectable } from 'tsyringe';
@injectable()
export class UserRepository implements IUserRepository {
Compares found vs registered repositories:
MISSING: UserRepository not registered
File: src/contexts/user/infrastructure/repositories/user.repository.ts
Required: Add to /src/global/container/container.ts
import type { IUserRepository } from '@/contexts/user/domain';
import { UserRepository } from '@/contexts/user/infrastructure/repositories/user.repository';
container.registerSingleton<IUserRepository>(
'IUserRepository',
UserRepository
);
Checks constructor injection:
ERROR: Wrong repository injection pattern
File: src/contexts/user/application/usecases/create-user.usecase.ts:12
Issue: Repository injected by class instead of token
Current:
@inject(UserRepository)
private repo: IUserRepository
Fix:
@inject('IUserRepository')
private repo: IUserRepository
Checks main.ts for event listener setup:
MISSING: UserCreatedListener not registered
File: src/contexts/user/application/listeners/user-created.listener.ts
Required: Add to /src/main.ts
import { UserCreatedListener } from '@/contexts/user/application';
const userCreatedListener = container.resolve(UserCreatedListener);
eventBus.on('UserCreated', userCreatedListener.handle.bind(userCreatedListener));
Checks main.ts for route registration:
MISSING: User routes not registered
File: src/contexts/user/presentation/user.routes.ts
Required: Add to /src/main.ts
import { registerUserRoutes } from '@/contexts/user/presentation/user.routes';
app.use(registerUserRoutes());
Finds registrations without implementations:
WARNING: Unused registration
File: src/global/container/container.ts:15
Registration: 'IProductRepository' → ProductRepository
Issue: ProductRepository class not found
Action: Remove registration or implement the class
// /src/global/container/container.ts
import 'reflect-metadata';
import { container } from 'tsyringe';
// User context
import type { IUserRepository } from '@/contexts/user/domain';
import { UserRepository } from '@/contexts/user/infrastructure/repositories/user.repository';
// Product context
import type { IProductRepository } from '@/contexts/product/domain';
import { ProductRepository } from '@/contexts/product/infrastructure/repositories/product.repository';
// Order context
import type { IOrderRepository } from '@/contexts/order/domain';
import { OrderRepository } from '@/contexts/order/infrastructure/repositories/order.repository';
export const registerDependencies = (): void => {
// User repositories
container.registerSingleton<IUserRepository>(
'IUserRepository',
UserRepository
);
// Product repositories
container.registerSingleton<IProductRepository>(
'IProductRepository',
ProductRepository
);
// Order repositories
container.registerSingleton<IOrderRepository>(
'IOrderRepository',
OrderRepository
);
};
// Add to /src/main.ts after DI setup
// Event listener imports
import { UserCreatedListener } from '@/contexts/user/application';
import { UserUpdatedListener } from '@/contexts/user/application';
import { ProductCreatedListener } from '@/contexts/product/application';
import { OrderPlacedListener } from '@/contexts/order/application';
// Event listener registration
const userCreatedListener = container.resolve(UserCreatedListener);
eventBus.on('UserCreated', userCreatedListener.handle.bind(userCreatedListener));
const userUpdatedListener = container.resolve(UserUpdatedListener);
eventBus.on('UserUpdated', userUpdatedListener.handle.bind(userUpdatedListener));
const productCreatedListener = container.resolve(ProductCreatedListener);
eventBus.on('ProductCreated', productCreatedListener.handle.bind(productCreatedListener));
const orderPlacedListener = container.resolve(OrderPlacedListener);
eventBus.on('OrderPlaced', orderPlacedListener.handle.bind(orderPlacedListener));
// Add to /src/main.ts
// Route imports
import { registerUserRoutes } from '@/contexts/user/presentation/user.routes';
import { registerProductRoutes } from '@/contexts/product/presentation/product.routes';
import { registerOrderRoutes } from '@/contexts/order/presentation/order.routes';
// Route registration
app.use(registerUserRoutes());
app.use(registerProductRoutes());
app.use(registerOrderRoutes());
The skill checks:
@injectable()@injectable()@injectable()@injectable()// ❌ WRONG
export class UserRepository implements IUserRepository {
// Missing @injectable()
}
// ✅ CORRECT
import { injectable } from 'tsyringe';
@injectable()
export class UserRepository implements IUserRepository {
// ❌ WRONG - Using class as token
container.registerSingleton<IUserRepository>(
IUserRepository, // Wrong: class
UserRepository
);
// ✅ CORRECT - Using string token
container.registerSingleton<IUserRepository>(
'IUserRepository', // Correct: string
UserRepository
);
// ❌ WRONG - Repository by class
constructor(
@inject(UserRepository)
private repo: IUserRepository
) {}
// ✅ CORRECT - Repository by token
constructor(
@inject('IUserRepository')
private repo: IUserRepository
) {}
// ❌ WRONG - Not binding
eventBus.on('UserCreated', listener.handle);
// ✅ CORRECT - Binding
eventBus.on('UserCreated', listener.handle.bind(listener));
@injectable()After getting the generated code:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience