koin

Installation
SKILL.md

Koin Skill

Comprehensive assistance with koin development, generated from official documentation.

When to Use This Skill

This skill should be triggered when:

  • Working with koin
  • Asking about koin features or APIs
  • Implementing koin solutions
  • Debugging koin code
  • Learning koin best practices

Quick Reference

Common Patterns

Pattern 1: Koin Annotations InventoryThis document provides a comprehensive inventory of all Koin annotations, their parameters, behaviors, and usage examples.Table of Contents​Definition Annotations@Single@Factory@ScopedScope Annotations@Scope@ViewModelScope@ActivityScope@ActivityRetainedScope@FragmentScope@ScopeIdViewModel & Android-Specific Annotations@KoinViewModel@KoinWorkerQualifier Annotations@Named@QualifierProperty Annotations@Property@PropertyValueModule & Application Annotations@Module@ComponentScan@Configuration@KoinApplicationMonitoring Annotations@MonitorMeta Annotations (Internal)@ExternalDefinition@MetaDefinition@MetaModule@MetaApplicationDefinition Annotations​@Single​Package: org.koin.core.annotationTarget: CLASS, FUNCTIONDescription: Declares a type or function as a single (singleton) definition in Koin. A single instance is created and shared across the application.Parameters:binds: Array<KClass<>> = [Unit::class] - Explicit types to bind to this definition. Supertypes are automatically detected.createdAtStart: Boolean = false - If true, the instance is created when Koin starts.Behavior: All dependencies are filled by constructor injection.Example:@Singleclass MyClass(val d : MyDependency)Generated Koin DSL:single { MyClass(get()) }With explicit binding:@Single(binds = [MyInterface::class])class MyClass(val d : MyDependency) : MyInterfaceWith creation at start:@Single(createdAtStart = true)class MyClass(val d : MyDependency)@Factory​Package: org.koin.core.annotationTarget: CLASS, FUNCTIONDescription: Declares a type or function as a factory definition in Koin. A new instance is created each time it is requested.Parameters:binds: Array<KClass<>> = [Unit::class] - Explicit types to bind to this definition. Supertypes are automatically detected.Behavior: All dependencies are filled by constructor injection. Each request creates a new instance.Example:@Factoryclass MyClass(val d : MyDependency)Generated Koin DSL:factory { MyClass(get()) }@Scoped​Package: org.koin.core.annotationTarget: CLASS, FUNCTIONDescription: Declares a type or function as a scoped definition in Koin. Must be associated with @Scope annotation. Instance is shared within a specific scope.Parameters:binds: Array<KClass<>> = [Unit::class] - Explicit types to bind to this definition. Supertypes are automatically detected.Behavior: Creates a scoped instance that lives within the defined scope's lifetime.Example:@Scope(MyScope::class)@Scopedclass MyClass(val d : MyDependency)See Also: @ScopeScope Annotations​@Scope​Package: org.koin.core.annotationTarget: CLASS, FUNCTIONDescription: Declares a class in a Koin scope. Scope name is described by either value (class) or name (string). By default, declares a scoped definition. Can be overridden with @Scoped, @Factory, @KoinViewModel annotations for explicit bindings.Parameters:value: KClass<> = Unit::class - Scope class valuename: String = "" - Scope string valueBehavior: Creates a scope definition associated with the specified scope type or name.Example with class:@Scope(MyScope::class)class MyClass(val d : MyDependency)Generated Koin DSL:scope { scoped { MyClass(get()) }}Example with string name:@Scope(name = "my_custom_scope")class MyClass(val d : MyDependency)@ViewModelScope​Package: org.koin.core.annotationTarget: CLASS, FUNCTIONDescription: Declares a class in a ViewModelScope Koin scope. This is a scope archetype for components that should live within a ViewModel's lifecycle.Parameters: NoneBehavior: Creates a scoped definition within the viewModelScope.Example:@ViewModelScopeclass MyClass(val d : MyDependency)Generated Koin DSL:viewModelScope { scoped { MyClass(get()) }}Usage: The tagged class is meant to be used with ViewModel and viewModelScope function to activate the scope.@ActivityScope​Package: org.koin.android.annotationTarget: CLASS, FUNCTIONDescription: Declares a class in an Activity Koin Scope.Parameters: NoneBehavior: Creates a scoped definition within the activityScope.Example:@ActivityScopeclass MyClass(val d : MyDependency)Generated Koin DSL:activityScope { scoped { MyClass(get()) }}Usage: The tagged class is meant to be used with Activity and activityScope function to activate the scope.@ActivityRetainedScope​Package: org.koin.android.annotationTarget: CLASS, FUNCTIONDescription: Declares a class in an Activity Koin scope, but retained across configuration changes.Parameters: NoneBehavior: Creates a scoped definition within the activityRetainedScope.Example:@ActivityRetainedScopeclass MyClass(val d : MyDependency)Generated Koin DSL:activityRetainedScope { scoped { MyClass(get()) }}Usage: The tagged class is meant to be used with Activity and activityRetainedScope function to activate the scope.@FragmentScope​Package: org.koin.android.annotationTarget: CLASS, FUNCTIONDescription: Declares a class in a Fragment Koin scope.Parameters: NoneBehavior: Creates a scoped definition within the fragmentScope.Example:@FragmentScopeclass MyClass(val d : MyDependency)Generated Koin DSL:fragmentScope { scoped { MyClass(get()) }}Usage: The tagged class is meant to be used with Fragment and fragmentScope function to activate the scope.@ScopeId​Package: org.koin.core.annotationTarget: VALUE_PARAMETERDescription: Annotates a parameter from class constructor or function to request resolution for a given scope with Scope ID.Parameters:value: KClass<> = Unit::class - Scope typename: String = "" - Scope string identifierBehavior: Resolves the dependency from a specific scope identified by type or name.Example with string name:@Factoryclass MyClass(@ScopeId(name = "my_scope_id") val d : MyDependency)Generated Koin DSL:factory { MyClass(getScope("my_scope_id").get()) }Example with type:@Factoryclass MyClass(@ScopeId(MyScope::class) val d : MyDependency)ViewModel & Android-Specific Annotations​@KoinViewModel​Package: org.koin.android.annotationTarget: CLASS, FUNCTIONDescription: ViewModel annotation for Koin definition. Declares a type or function as a viewModel definition in Koin.Platform Support:✅ Android✅ Kotlin Multiplatform (KMP)✅ Compose Multiplatform (CMP)Parameters:binds: Array<KClass<>> = [] - Explicit types to bind to this definition. Supertypes are automatically detected.Behavior: All dependencies are filled by constructor injection. Creates a ViewModel instance managed by Koin. Works across all platforms including Android, iOS, Desktop, and Web when using Compose Multiplatform.Example (Android/CMP):@KoinViewModelclass MyViewModel(val d : MyDependency) : ViewModel()Example (KMP/CMP shared):@KoinViewModelclass SharedViewModel( val repository: Repository, val analytics: Analytics) : ViewModel()Generated Koin DSL:viewModel { MyViewModel(get()) }@KoinWorker​Package: org.koin.android.annotationTarget: CLASS, FUNCTIONDescription: Worker annotation for Koin Definition. Declares a type as a worker definition for WorkManager workers.Parameters:binds: Array<KClass<>> = [] - Explicit types to bind to this definition.Behavior: Creates a worker definition for Android WorkManager integration.Example:@KoinWorkerclass MyWorker() : Worker()Qualifier Annotations​@Named​Package: org.koin.core.annotationTarget: CLASS, FUNCTION, VALUE_PARAMETERDescription: Defines a qualifier for a given definition. Generates StringQualifier("...") or type-based qualifier.Parameters:value: String = "" - String qualifiertype: KClass<> = Unit::class - Class qualifierBehavior: Used to distinguish between multiple definitions of the same type.Example with string:@Single@Named("special")class MyClass(val d : MyDependency)Usage in parameter:@Singleclass Consumer(@Named("special") val myClass: MyClass)Example with type:@Single@Named(type = MyType::class)class MyClass(val d : MyDependency)@Qualifier​Package: org.koin.core.annotationTarget: CLASS, FUNCTION, VALUE_PARAMETERDescription: Defines a qualifier for a given definition. Similar to @Named but with reversed parameter priority.Parameters:value: KClass<> = Unit::class - Class qualifiername: String = "" - String qualifierBehavior: Used to distinguish between multiple definitions of the same type.Example:@Single@Qualifier(name = "special")class MyClass(val d : MyDependency)Property Annotations​@Property​Package: org.koin.core.annotationTarget: VALUE_PARAMETERDescription: Annotates a constructor parameter or function parameter to resolve as a Koin property.Parameters:value: String - Property nameBehavior: Resolves the parameter value from Koin properties instead of dependency injection.Example:@Factoryclass MyClass(@Property("name") val name : String)Generated Koin DSL:factory { MyClass(getProperty("name")) }With default value:@PropertyValue("name")val defaultName = "MyName"@Factoryclass MyClass(@Property("name") val name : String)Generated Koin DSL:factory { MyClass(getProperty("name", defaultName)) }@PropertyValue​Package: org.koin.core.annotationTarget: FIELDDescription: Annotates a field value that will be a Property default value.Parameters:value: String - Property nameBehavior: Defines a default value for a property that can be used when the property is not found.Example:@PropertyValue("name")val defaultName = "MyName"@Factoryclass MyClass(@Property("name") val name : String)Generated Koin DSL:factory { MyClass(getProperty("name", defaultName)) }Module & Application Annotations​@Module​Package: org.koin.core.annotationTarget: CLASSDescription: Class annotation to help gather definitions inside a Koin module. Each function can be annotated with a Koin definition annotation.Parameters:includes: Array<KClass<>> = [] - Module classes to includecreatedAtStart: Boolean = false - If true, module instances are created at startBehavior: Gathers all annotated functions and classes within the module.Example:@Moduleclass MyModule { @Single fun myClass(d : MyDependency) = MyClass(d)}Generated Koin DSL:val MyModule.module = module { val moduleInstance = MyModule() single { moduleInstance.myClass(get()) }}With includes:@Module(includes = [OtherModule::class])class MyModule { // definitions}@ComponentScan​Package: org.koin.core.annotationTarget: CLASS, FIELDDescription: Gathers definitions declared with Koin definition annotations. Scans current package or explicit package names.Parameters:value: vararg String = [] - Packages to scan (supports glob patterns)Behavior: Scans specified packages for annotated classes. Supports both exact package names and glob patterns.Glob Pattern Support:Exact package names (no wildcards):com.example.service - Scans package and all subpackages (equivalent to com.example**)Multi-level scan including root:com.example** - Scans com.example and all subpackagesMulti-level scan excluding root:com.example.** - Scans only subpackages of com.example, excludes rootSingle-level wildcard:com.example..service - Matches exactly one level (e.g., com.example.user.service)Combined wildcards:com..service.data - Complex pattern matchingcom..service. - Scans subpackages under patternExample - scan current package:@ComponentScanclass MyAppExample - scan specific packages:@ComponentScan("com.example.services", "com.example.repositories")class MyAppExample - with glob patterns:@ComponentScan("com.example.**", "org.app..services")class MyApp@Configuration​Package: org.koin.core.annotationTarget: CLASS, FIELDDescription: Applied to @Module class to associate it with one or more configurations (tags/flavors).Parameters:value: vararg String = [] - Configuration namesBehavior: Modules can be grouped into configurations for conditional loading.Default Configuration:@Module@Configurationclass MyModuleThis module is part of the "default" configuration.Multiple Configurations:@Module@Configuration("prod", "test")class MyModuleThis module is available in both "prod" and "test" configurations.With Default:@Module@Configuration("default", "test")class MyModuleAvailable in default and test configurations.Note: @Configuration("default") is equivalent to @Configuration@KoinApplication​Package: org.koin.core.annotationTarget: CLASSDescription: Tags a class as a Koin application entry point. Generates Koin application bootstrap with startKoin() or koinApplication() functions.Parameters:configurations: Array = [] - List of configuration names to scanmodules: Array<KClass<*>> = [Unit::class] - List of modules to load besides configurationsBehavior: Generates bootstrap functions that scan for configurations and included modules.Example - default configuration:@KoinApplicationclass MyAppGenerated functions:MyApp.startKoin()MyApp.koinApplication()Example - specific configurations:@KoinApplication(configurations = ["default", "prod"])class MyAppExample - with modules:@KoinApplication( configurations = ["default"], modules = [CoreModule::class, ApiModule::class])class MyAppUsage with custom configuration:MyApp.startKoin { printLogger() // additional configuration}Monitoring Annotations​@Monitor​Package: org.koin.core.annotationTarget: CLASS, FUNCTIONDescription: Marks a class or function for automatic monitoring and performance tracing through Kotzilla Platform, the official tooling platform for Koin.Parameters: NoneBehavior:When applied to a class: Generates a Koin proxy that monitors all public method callsWhen applied to a function: Monitors that specific method within a Koin-managed componentAutomatically captures performance metrics, error rates, and usage patternsSends data to Kotzilla workspace for real-time analysisRequirements:implementation 'io.kotzilla:kotzilla-core:latest.version'Valid Kotzilla Platform account and API keyExample:@Monitorclass UserService(private val userRepository: UserRepository) { fun findUser(id: String): User? = userRepository.findById(id)}Resources:Kotzilla PlatformComplete DocumentationLatest VersionSince: Kotzilla 1.2.1Meta Annotations (Internal)​These annotations are for internal use only by the Koin compiler and code generation.@ExternalDefinition​Package: org.koin.meta.annotationsTarget: CLASS, FIELD, FUNCTIONDescription: Internal usage for components discovery in generated package.Parameters:value: String = "" - Package of declared definition@MetaDefinition​Package: org.koin.meta.annotationsTarget: CLASS, FUNCTION, PROPERTYDescription: Meta Definition annotation to help represent definition metadata.Parameters:value: String = "" - Definition full pathmoduleTagId: String = "" - Module Tag + ID (format: "module_id:module_tag")dependencies: Array = [] - Parameters tags to checkbinds: Array = [] - Bound typesqualifier: String = "" - Qualifierscope: String = "" - Scope where it's declared@MetaModule​Package: org.koin.meta.annotationsTarget: CLASSDescription: Meta Module annotation to help represent module metadata.Parameters:value: String = "" - Module full pathid: String = "" - Module IDincludes: Array = [] - Includes Module Tags to checkconfigurations: Array = [] - Module Configurations to checkisObject: Boolean = false - Whether the module is an object@MetaApplication​Package: org.koin.meta.annotationsTarget: CLASSDescription: Meta Application annotation to help represent application metadata.Parameters:value: String = "" - Application full pathincludes: Array = [] - Used Module Tags to checkconfigurations: Array = [] - Used Configurations modules to checkDeprecated Annotations​@Singleton​Package: org.koin.core.annotationStatus: DEPRECATED - ERROR levelReplacement: Use @Singleton from koin-jsr330 package insteadDescription: Same as @Single but deprecated in favor of JSR-330 compliance.Summary Table​AnnotationPackagePurposeCommon Use Case@Singleorg.koin.core.annotationSingleton definitionShared application services@Factoryorg.koin.core.annotationFactory definitionPer-request instances@Scopedorg.koin.core.annotationScoped definitionScope-specific instances@Scopeorg.koin.core.annotationScope declarationCustom scopes@ViewModelScopeorg.koin.core.annotationViewModel scopeViewModel-scoped dependencies@ActivityScopeorg.koin.android.annotationActivity scopeActivity-scoped dependencies@ActivityRetainedScopeorg.koin.android.annotationRetained activity scopeConfig-change surviving deps@FragmentScopeorg.koin.android.annotationFragment scopeFragment-scoped dependencies@ScopeIdorg.koin.core.annotationScope resolutionResolve from specific scope@KoinViewModelorg.koin.android.annotationViewModel definitionAndroid/KMP/CMP ViewModels@KoinWorkerorg.koin.android.annotationWorker definitionWorkManager workers@Namedorg.koin.core.annotationString/type qualifierDistinguish same-type beans@Qualifierorg.koin.core.annotationType/string qualifierDistinguish same-type beans@Propertyorg.koin.core.annotationProperty injectionConfiguration values@PropertyValueorg.koin.core.annotationProperty defaultDefault config values@Moduleorg.koin.core.annotationModule declarationGroup definitions@ComponentScanorg.koin.core.annotationPackage scanningAuto-discover definitions@Configurationorg.koin.core.annotationModule configurationBuild variants/flavors@KoinApplicationorg.koin.core.annotationApp entry pointBootstrap Koin@Monitororg.koin.core.annotationPerformance monitoringProduction monitoringDocument Version: 1.0 Last Updated: 20-10-2025 Koin Annotations Version: 2.2.x+

Related skills
Installs
17
GitHub Stars
1
First Seen
Jan 23, 2026