dependency-injection-architecture

Design Koin or Spring dependency injection wiring for Kotlin clean architecture projects.

Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Astrumon/Spovishun --skill dependency-injection-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dependency-injection-architecture
Source: https://github.com/Astrumon/Spovishun/tree/main/.claude/skills/dependency-injection-architecture
Command: npx skills add https://github.com/Astrumon/Spovishun --skill dependency-injection-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides clear guidance and patterns for designing and implementing dependency injection in Kotlin projects following clean architecture, reducing coupling, improving testability, and ensuring consistent wiring across environments.

Core Features & Use Cases

  • Layered Wiring Rules: Defines allowed dependency directions between presentation, domain, data, and common layers to prevent architectural drift.
  • Koin & Spring Patterns: Recommends module organization, profile-based module selection, and idiomatic bindings for services and repositories.
  • Best Practices: Encourages constructor injection, interface-based contracts, singletons for shared resources, factories for transient objects, and naming conventions for implementations.
  • Use Case: Convert an existing Kotlin Telegram bot into a production-ready wiring by replacing in-memory repositories with database-backed implementations and adding dev/prod modules.

Quick Start

Ask the assistant to generate a Koin module that binds your repository and service interfaces to their implementations following the presentation → domain → data layer rules.

Frequently Asked Questions about dependency-injection-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up dependency injection in Kotlin clean architecture apps?

Set up dependency injection in Kotlin by defining explicit module wiring for presentation, domain, data, and common layers using Koin or Spring. This enforces constructor injection and interface-based bindings to create testable dependency graphs while preventing cross-layer architectural drift.

What's the best way to organize Koin modules for dev and prod profiles?

Organize Koin modules using profile-based module selection to separate dev and prod environments. Bind repository and service interfaces to specific implementations per profile, applying singleton scope for expensive resources and factory scope for stateless objects.

How do I replace in-memory repositories with database-backed implementations in a Kotlin DI graph?

Replace in-memory repositories by defining interface-based contracts in the domain layer and binding database-backed implementations in the data layer modules. This clean architecture wiring allows swapping repository implementations without modifying presentation or domain layer logic.

Does this dependency injection approach work with both Koin and Spring in Kotlin?

Yes, this dependency injection approach provides idiomatic patterns for both Koin and Spring in Kotlin. It recommends module organization, profile-based selection, and constructor injection rules that apply seamlessly whether you choose Koin's DSL or Spring's annotation-based bean configuration.

Why should I prohibit cross-layer SDK or DB imports in domain layers?

Prohibit cross-layer SDK or DB imports in domain layers to prevent architectural drift and maintain testability. Defining allowed dependency directions between presentation, domain, data, and common layers ensures that core business logic remains decoupled from external infrastructure frameworks.

When should I use singleton scope vs factory scope for Kotlin DI bindings?

Use singleton scope for expensive shared resources like database connections, and factory scope for stateless transient objects. Applying these dependency injection scopes correctly in Koin or Spring modules optimizes resource management and prevents unintended state sharing across requests.