AgentSkillsCN

add-dependency

为KMP项目新增一项多平台依赖。只需提供库名称(例如“ktor-client”或“koin”),即可确保使用最新稳定版本,并实现跨平台兼容性。

SKILL.md
--- frontmatter
name: add-dependency
description: Add a new multiplatform dependency to the KMP project. Provide the library name (e.g. "ktor-client" or "koin"). Ensures latest stable version and multiplatform compatibility.
allowed-tools: Bash, Read, Edit, WebSearch, Grep
user-invocable: true

Add KMP dependency: $ARGUMENTS

Steps:

  1. Search the web for the latest stable version of the library and confirm it supports Kotlin Multiplatform (Android + iOS targets).

  2. Read gradle/libs.versions.toml to understand the current version catalog structure.

  3. Add the dependency to gradle/libs.versions.toml:

    • Add version under [versions]
    • Add library entry under [libraries]
    • Add plugin under [plugins] if needed
  4. Read composeApp/build.gradle.kts to understand the current dependency setup.

  5. Add the dependency in composeApp/build.gradle.kts under the correct source set:

    • commonMain if the library is multiplatform
    • androidMain/iosMain only if platform-specific
  6. Sync and verify:

    code
    ./gradlew :composeApp:dependencies
    

Rules:

  • Always use the latest stable version (no RC/alpha/beta unless explicitly requested)
  • Never hardcode versions in build.gradle.kts — use the version catalog
  • Confirm the library supports all project targets before adding to commonMain