add-dependency
Add a new third-party dependency to the project following the version catalog and approval workflow.
When & Why to Use This Skill
This Claude skill automates the end-to-end process of adding third-party dependencies to a software project. It streamlines dependency management by searching for the latest stable versions, updating the Gradle version catalog (libs.versions.toml), and ensuring all changes follow a strict approval workflow to maintain project stability and prevent version fragmentation.
Use Cases
- Integrating new libraries: Automatically find and add the latest stable version of a library (e.g., Retrofit, Coil) while ensuring it is correctly defined in the version catalog.
- Standardizing project configuration: Migrating hardcoded dependency versions from build.gradle files into a centralized TOML version catalog for better maintainability.
- Workflow enforcement: Ensuring that every new dependency is justified, approved by a developer, and verified through a successful build before being integrated into the codebase.
| name | add-dependency |
|---|---|
| description | Add a new third-party dependency to the project following the version catalog and approval workflow. |
Add Third-Party Dependency
This skill outlines the necessary steps to validly adding a new dependency to the project.
Workflow
Verify Necessity:
- Goal: Ensure the dependency is absolutely necessary.
- Action: Avoid adding new third-party dependencies unless there is no tailored solution available or implementing it manually helps the project significantly.
- Action: You MUST get user approval before adding any new third-party dependency. Explain why it is needed and what alternatives were considered.
Find Latest Version:
- Goal: Use the most up-to-date stable version.
- Action: Perform a web search to determine the latest stable version of the library.
- Example:
search_web(query="latest version of retrofit")
Update Version Catalog:
- Goal: Centralize dependency management.
- Action: Add the dependency to
gradle/libs.versions.toml. - Format:
[versions] libraryName = "1.2.3" [libraries] library-artifact = { group = "com.example", name = "library-artifact", version.ref = "libraryName" }
Sync and Build:
- Goal: Verify the dependency is resolved correctly.
- Action: Run a build or sync command to ensure the new dependency doesn't break the build.
- Command:
./gradlew assembleDebug(or relevant task).
Guidelines
- Approval First: Do not modify files before getting confirmation from the user (unless in a fully autonomous mode where this is pre-approved).
- No Hardcoding: Never put version numbers directly in
build.gradle.ktsfiles. Always use the version catalog (libs.versions.toml).