ahmed3elshaer/everything-claude-code-mobile/koin-patterns

Claude Code and agent skill by ahmed3elshaer/everything-claude-code-mobile

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Koin dependency injection patterns for Android with modules, scopes, and ViewModel injection.

Install

npx vskill@latest install ahmed3elshaer/everything-claude-code-mobile/koin-patterns

SKILL.md

Koin Dependency Injection

Pragmatic DI for Kotlin with Koin.

Module Setup

kotlin
// AppModule.kt
val appModule = module {
// Singletons
single<AppDatabase> { Room.databaseBuilder(...).build() }
single { get<AppDatabase>().userDao() }
// Factories (new instance each time)
factory { DateFormatter() }
}
// NetworkModule.kt
val networkModule = module {
single<HttpClient> {
HttpClient(OkHttp) {
install(ContentNegotiation) {
json(Json { ignoreUnknownKeys = true })
}
}
}
single<AuthApi> { AuthApiImpl(get()) }
single<UserApi> { UserApiImpl(get()) }
}
// FeatureModule.kt
val homeModule = module {
// Repository
single<HomeRepository> { HomeRepositoryImpl(get(), get()) }
// Use Cases
factory { GetItemsUseCase(get()) }
factory { GetItemUseCase(get()) }
// ViewModel
viewModel { HomeViewModel(get()) }
}

Application Setup

kotlin
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
startKoin {
androidContext(this@MyApp)
modules(
appModule,
networkModule,
homeModule,
detailModule
)
}
}
}

ViewModel Injection

kotlin
// In Compose
@Composable
fun HomeScreen(viewModel: HomeViewModel = koinViewModel()) {
val state by viewModel.state.collectAsStateWithLifecycle()
// ...
}
// With parameters
@Composable
fun DetailScreen(itemId: String) {
val viewModel: DetailViewModel = koinViewModel { parametersOf(itemId) }
// ...
}
// ViewModel definition with params
viewModel { params ->
DetailViewModel(
itemId = params.get(),
repository = get()
)
}

Scopes

kotlin
// Activity scope
val activityModule = module {
scope<MainActivity> {
scoped { NavigationController() }
}
}
// Usage
class MainActivity : AppCompatActivity(), KoinScopeComponent {
override val scope: Scope by activityScope()
val nav: NavigationController by inject()
}

Qualifiers

kotlin
val networkModule = module {
single(named("auth")) { createAuthClient() }
single(named("default")) { createDefaultClient() }
}
// Usage
class UserApi(
@Named("auth") private val client: HttpClient
)

Testing

kotlin
class HomeViewModelTest : KoinTest {
@get:Rule
val koinRule = KoinTestRule.create {
modules(testModule)
}
private val testModule = module {
single<HomeRepository> { mockk() }
viewModel { HomeViewModel(get()) }
}
private val viewModel: HomeViewModel by inject()
private val repository: HomeRepository by inject()
@Test
fun `loads items`() = runTest {
coEvery { repository.getItems() } returns Result.success(listOf())
// ...
}
}

Remember: Koin is pragmatic. Keep modules organized, use scopes for lifecycle.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
43
Repository forks
8
7-day trend score
19

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 5 May 2026, 6 months ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ahmed3elshaer/everything-claude-code-mobile/koin-patterns/badge)](https://verified-skill.com/skills/ahmed3elshaer/everything-claude-code-mobile/koin-patterns)

Something wrong with this skill or its page? Tell us.